Участник:Karaby/common.js: различия между версиями

Материал из Буквицы
Перейти к навигации Перейти к поиску
мНет описания правки
мНет описания правки
Строка 8: Строка 8:
             'type': 'select',
             'type': 'select',
             'list': {
             'list': {
                  'blank-user-1' : { // Вставить ...
                'blank-user-1' : { // Вставить ...
                       'label': 'Просмотрено de visu',
                       'label': 'Просмотрено de visu',
                       'action':  {
                       'action':  {
Строка 18: Строка 18:
                           }       
                           }       
                       }
                       }
                  }
                }
             }
             }
         }
         }
     }
     }
   }
   } );
};
};



Версия от 08:35, 15 сентября 2020

var customizeToolbar = function () {
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
    'section': 'advanced',
    'group': 'blanks',
    'tools':  {
        'blank-user': {
            'label': 'Мои инструменты',
            'type': 'select',
            'list': {
                'blank-user-1' : { // Вставить ...
                      'label': 'Просмотрено de visu',
                      'action':   {
                          'type': 'encapsulate',
                          'options': {
                              'pre': '',
                              'peri': '', // <== сюда курсор (текущее выделение)
                              'post': '{{e02|vc|dv}}',
                          }       
                      }
                }
            }
        }
    }
  } );
};




/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
/*
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
*/

if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
        mw.loader.using( 'user.options', function () {
                if ( mw.user.options.get('usebetatoolbar') ) {
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                                $(document).ready( customizeToolbar );
                        } );
                }
        } );
}


/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
/*
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
*/