User:Gryllida/js/addCatButton.js

/*



mw.loader.using(['mediawiki.api'], function {	"use strict";	// == WikiEditor codes ==	var customizeToolbar = function  {		// add a category button		$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'insert', 'tools': { 'addCategory': { label: 'Add as a category', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/6/64/Add_category_toolbar_button.svg/22px-Add_category_toolbar_button.svg.png', action: { type: 'encapsulate', 'options': { 'pre': '[[Category:',			               'post': ']]' }					}				}			}		} );	};	/* 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 (T54542) if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) { $.when(					mw.loader.using( 'ext.wikiEditor' ), $.ready				).then( customizeToolbar ); }		} );	}	// == WikiEditor codes end ==

});