Difference between revisions of "MediaWiki:Common.js"
Line 2: | Line 2: | ||
var customizeToolbar = function () { | var customizeToolbar = function () { | ||
− | |||
− | |||
− | |||
− | |||
// To add a booklet section: | // To add a booklet section: | ||
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { |
Revision as of 10:17, 4 September 2018
/* Any JavaScript here will be loaded for all users on every page load. */ var customizeToolbar = function () { // To add a booklet section: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'sections': { 'info': { 'type': 'booklet', 'label': 'Info' 'pages': { 'colors': { 'layout': 'table', 'label': 'Colors', 'headings': [ { text: 'Name' }, // or use textMsg for localization, see also above { text: 'Temperature' }, { text: 'Swatch' } ], 'rows': [ { 'name': { text: 'Red' }, 'temp': { text: 'Warm' }, 'swatch': { html: '<div style="width:10px;height:10px;background-color:red;">' } }, { 'name': { text: 'Blue' }, 'temp': { text: 'Cold' }, 'swatch': { html: '<div style="width:10px;height:10px;background-color:blue;">' } }, { 'name': { text: 'Silver' }, 'temp': { text: 'Neutral' }, 'swatch': { html: '<div style="width:10px;height:10px;background-color:silver;">' } } ] } } } } } ); }; /* 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' ), $.ready ).then( customizeToolbar ); } } ); }