Difference between revisions of "MediaWiki:Common.js"
m (Replaced content with "→Any JavaScript here will be loaded for all users on every page load.: ") |
|||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
+ | |||
+ | var customizeToolbar = function () { | ||
+ | /* Your code goes here */ | ||
+ | |||
+ | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
+ | 'sections': { | ||
+ | 'snippets': { | ||
+ | 'type': 'booklet', | ||
+ | 'label': 'Useful Codes', | ||
+ | 'pages': { | ||
+ | 'section-xml': { | ||
+ | 'label': 'SPL Tags', | ||
+ | 'layout': 'characters', | ||
+ | 'characters': [ | ||
+ | '<references/>', | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<ref>', | ||
+ | 'peri': '', | ||
+ | 'post': '</ref>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<ref></ref>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<poem>', | ||
+ | 'peri': '', | ||
+ | 'post': '</poem>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<poem></poem>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<center>', | ||
+ | 'peri': '', | ||
+ | 'post': '</center>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<center></center>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<font size="" color="red">', | ||
+ | 'peri': '', | ||
+ | 'post': '</font>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Font Red>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<font size="" color="green">', | ||
+ | 'peri': '', | ||
+ | 'post': '</font>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Font Green>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<font size="" color="blue">', | ||
+ | 'peri': '', | ||
+ | 'post': '</font>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Font Blue>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<font size="" color="orange">', | ||
+ | 'peri': '', | ||
+ | 'post': '</font>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Font Orange>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<font size="" color="maroon">', | ||
+ | 'peri': '', | ||
+ | 'post': '</font>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Font Maroon>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<font size="" color="purple">', | ||
+ | 'peri': '', | ||
+ | 'post': '</font>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Font Purple>' | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | 'section-links': { | ||
+ | 'label': 'Wikilinks', | ||
+ | 'layout': 'characters', | ||
+ | 'characters': [ | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '[[Category:', | ||
+ | 'peri': '', | ||
+ | 'post': ']]' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '[[Category:]]' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '[[File:', | ||
+ | 'peri': '', | ||
+ | 'post': ']]' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '[[File:]]' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '{{#ev:youtube|', | ||
+ | 'peri': 'Video ID', | ||
+ | 'post': '|center|315|caption}}' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '{{Youtube}}' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '{{#Display:', | ||
+ | 'peri': 'URL', | ||
+ | 'post': '|Width without PX|Height without PX}}' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '{{Embed Scribed or PPT or PDF}}' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<gallery>', | ||
+ | 'peri': '', | ||
+ | 'post': '</gallery>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Gallery>' | ||
+ | }, | ||
+ | { | ||
+ | 'action': { | ||
+ | 'type': 'encapsulate', | ||
+ | 'options': { | ||
+ | 'pre': '<hovergallery maxhoverwidth=400 maxhoverheight=300>', | ||
+ | 'peri': '', | ||
+ | 'post': '</hovergallery>' | ||
+ | } | ||
+ | }, | ||
+ | 'label': '<Hovergallery>' | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } ); | ||
+ | |||
+ | }; | ||
+ | |||
+ | /* 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 ); | ||
+ | } | ||
+ | } ); | ||
+ | } |
Revision as of 14:50, 18 May 2020
sh: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/* Any JavaScript here will be loaded for all users on every page load. */
var customizeToolbar = function () {
/* Your code goes here */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'snippets': {
'type': 'booklet',
'label': 'Useful Codes',
'pages': {
'section-xml': {
'label': 'SPL Tags',
'layout': 'characters',
'characters': [
'<references/>',
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<ref>',
'peri': '',
'post': '</ref>'
}
},
'label': '<ref></ref>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<poem>',
'peri': '',
'post': '</poem>'
}
},
'label': '<poem></poem>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<center>',
'peri': '',
'post': '</center>'
}
},
'label': '<center></center>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="red">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Red>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="green">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Green>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="blue">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Blue>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="orange">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Orange>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="maroon">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Maroon>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="purple">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Purple>'
}
]
},
'section-links': {
'label': 'Wikilinks',
'layout': 'characters',
'characters': [
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '[[Category:',
'peri': '',
'post': ']]'
}
},
'label': '[[Category:]]'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '[[File:',
'peri': '',
'post': ']]'
}
},
'label': '[[File:]]'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '{{#ev:youtube|',
'peri': 'Video ID',
'post': '|center|315|caption}}'
}
},
'label': '{{Youtube}}'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '{{#Display:',
'peri': 'URL',
'post': '|Width without PX|Height without PX}}'
}
},
'label': '{{Embed Scribed or PPT or PDF}}'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<gallery>',
'peri': '',
'post': '</gallery>'
}
},
'label': '<Gallery>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<hovergallery maxhoverwidth=400 maxhoverheight=300>',
'peri': '',
'post': '</hovergallery>'
}
},
'label': '<Hovergallery>'
}
]
}
}
}
}
} );
};
/* 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 );
}
} );
}