User:Xeno/global.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// extra edit buttons
/*global jQuery, mediaWiki */
( function ( mw, $ ) {
'use strict';
var addExtraButtons = function(){
    if(!mw.toolbar) return;
	mw.toolbar.addButton( {
		imageFile: '//upload.wikimedia.org/wikipedia/commons/5/5b/Button_check.png',
		speedTip: 'Done',
		tagOpen: '*{{done}}',
		tagClose: ' ~~' + '~~',
		imageId: 'button-done'
	} );
	mw.toolbar.addButton( {
		imageFile: '//upload.wikimedia.org/wikipedia/commons/e/e4/Bouton_Vandale3.png',
		speedTip: 'Not done',
		tagOpen: '*{{notdone}}',
		tagClose: ' ~~' + '~~',
		imageId: 'button-not-done'
	} );

	/* If you want more buttons, copy and adapt the examples above and paste the modified version before this comment */

};

if( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options', function () {
		if ( ! mw.user.options.get( 'usebetatoolbar' ) ) {
			mw.loader.using( 'mediawiki.action.edit', function(){
				$( addExtraButtons );
			} );
		}
	} );
}

}( mediaWiki, jQuery ) );