MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 3: | Line 3: | ||
/* 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. */ | ||
mw.loader.using(['mediawiki.util']).done(function () | mw.loader.using(['mediawiki.util']).done(function () { | ||
/* Include in the wiki the following JavaScript pages */ | |||
// MediaWiki:Sandbox.js | |||
importScript('MediaWiki:Sandbox.js'); | |||
// MediaWiki:Countdown.js | |||
// importScript('MediaWiki:Countdown.js'); | |||
// Widget:Rescue Password Generator/script.js | |||
importScript('Widget:Rescue_Password_Generator/script.js'); | |||
/* a11y */ | /* a11y */ | ||
$("a.mw-wiki-logo").attr("title", "Mystery Dungeon Franchise Wiki"); | $("a.mw-wiki-logo").attr("title", "Mystery Dungeon Franchise Wiki"); | ||
Line 11: | Line 20: | ||
// https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization | // https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization | ||
/* Check if we're editing a page. */ | /* Check if we're editing a page. */ | ||
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { | if (['edit', 'submit'].indexOf(mw.config.get( 'wgAction' )) !== -1) { | ||
// Add a hook handler. | // Add a hook handler. | ||
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { | mw.hook('wikiEditor.toolbarReady').add(function ($textarea) { | ||
// Configure a new toolbar entry on the given $textarea jQuery object. | // Configure a new toolbar entry on the given $textarea jQuery object. | ||
$textarea.wikiEditor( 'addToToolbar', { | $textarea.wikiEditor( 'addToToolbar', { | ||
Line 25: | Line 33: | ||
} | } | ||
} | } | ||
} ); | }); | ||
$textarea.wikiEditor( 'addToToolbar', { | $textarea.wikiEditor( 'addToToolbar', { | ||
section: 'characters', | section: 'characters', | ||
Line 36: | Line 44: | ||
} | } | ||
} | } | ||
} ); | }); | ||
} ); | }); | ||
} | } | ||
// Minify imported stylesheets and scripts | // Minify imported stylesheets and scripts | ||
importArticles( | mw.hook('wikiEditor.importArticles').add(function () { | ||
{ | importArticles( | ||
{ | |||
type: 'script', | |||
articles: [ | |||
'MediaWiki:Sandbox.js', | |||
'Widget:Rescue_Password_Generator/script.js' | |||
] | |||
}, | |||
{ | |||
type: 'style', | |||
articles: [ | |||
'Mediawiki:Sandbox.css', | |||
'Mediawiki:Templates.css' | |||
] | |||
); | } | ||
); | |||
}); | |||
}); | }); |
Revision as of 20:29, 21 April 2024
/* global mw, $ */
/* jshint strict:false, browser:true, esversion: 10 */
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using(['mediawiki.util']).done(function () {
/* Include in the wiki the following JavaScript pages */
// MediaWiki:Sandbox.js
importScript('MediaWiki:Sandbox.js');
// MediaWiki:Countdown.js
// importScript('MediaWiki:Countdown.js');
// Widget:Rescue Password Generator/script.js
importScript('Widget:Rescue_Password_Generator/script.js');
/* a11y */
$("a.mw-wiki-logo").attr("title", "Mystery Dungeon Franchise Wiki");
/* end a11y */
// https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
/* Check if we're editing a page. */
if (['edit', 'submit'].indexOf(mw.config.get( 'wgAction' )) !== -1) {
// Add a hook handler.
mw.hook('wikiEditor.toolbarReady').add(function ($textarea) {
// Configure a new toolbar entry on the given $textarea jQuery object.
$textarea.wikiEditor( 'addToToolbar', {
section: 'characters',
pages: {
gametitles: {
layout: 'characters',
label: 'Game Titles',
characters: ['{{Shiren|Shiren the Wanderer 3 - The Sleeping Princess and the Karakuri Mansion}}', '{{Pkmn|Pokémon Mystery Dungeon: Red and Blue Rescue Team}}', '{{Pkmn|Pokémon Mystery Dungeon: Gates to Infinity}}', '{{Pkmn|Pokémon Super Mystery Dungeon}}', '{{Pkmn|Pokémon Mystery Dungeon: Rescue Team DX}}']
}
}
});
$textarea.wikiEditor( 'addToToolbar', {
section: 'characters',
pages: {
consolelogos: {
layout: 'characters',
label: 'Console Logos',
characters: ['{{ConsoleLogo|Wii|small}}', '{{ConsoleLogo|3DS|small}}', '{{ConsoleLogo|DS|small}}', '{{ConsoleLogo|GBA|small}}', '{{ConsoleLogo|GB|small}}']
}
}
});
});
}
// Minify imported stylesheets and scripts
mw.hook('wikiEditor.importArticles').add(function () {
importArticles(
{
type: 'script',
articles: [
'MediaWiki:Sandbox.js',
'Widget:Rescue_Password_Generator/script.js'
]
},
{
type: 'style',
articles: [
'Mediawiki:Sandbox.css',
'Mediawiki:Templates.css'
]
}
);
});
});