MediaWiki:Common.js
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.
/* Any JavaScript here will be loaded for all users on every page load. */ /* TreeAndMenu: Opening a tree to the current page */ $(document).ready( function() { $('#tree').bind('fancytreeinit', function(event, data) { data.tree.makeTitleVisible(); }); }); /* Can't remember */ $("#resourcesquery table").addClass("responsive"); /* Haven't a clue */ function citationDownload(filename, text) { var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } /* Page Forms: so can't edit coordinates field directly (have to use map) */ $( function() { $('.pfCoordsInput').prop('readonly', true); // $('.pfUpdateMap').hide(); } ); /* WikiEditor toolbar customisation: see https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization */ var customizeToolbar = function () { /* <Blockquote> button */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'format', tools: { "blockquote": { label: 'Blockquote', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/f/fd/Toolbar_blockquote.png', action: { type: 'encapsulate', options: { pre: "<blockquote>", post: "</blockquote>" } } } } } ); /* [[Category:]] button */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { "category": { label: 'Category', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/2/28/Toolbaricon_category.png', action: { type: 'encapsulate', options: { pre: "[[Category:", post: "]]" } } } } } ); /* {{#bailii:}} button */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { "bailii": { label: 'Bailii', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/d/dd/P_writing_icon.svg', action: { type: 'encapsulate', options: { pre: "{{#bailii:", post: "}}" } } } } } ); /* [[Category:Judgment available offline]] button */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { "offline": { label: 'J available offline', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0c/Toolbar_no_wiki.png', action: { type: 'replace', options: { pre: "[[Category:", post: "Judgment available offline]]" } } } } } ); /* [[Category:Judgment available on MHLO]] button */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { "online": { label: 'J available on MHLO', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/3/33/Toolbar_welcome.png', action: { type: 'replace', options: { pre: "[[Category:", post: "Judgment available on MHLO]]" } } } } } ); }; /* 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 ); } } ); }