Common.js: Difference between revisions
No edit summary |
No edit summary |
||
Line 62: | Line 62: | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: ' | group: 'extra', | ||
tools: { | tools: { | ||
"blockquote": { | "blockquote": { | ||
Line 81: | Line 81: | ||
$( '#free_text' ).wikiEditor( 'addToToolbar', { | $( '#free_text' ).wikiEditor( 'addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: ' | group: 'extra', | ||
tools: { | tools: { | ||
"blockquote": { | "blockquote": { | ||
Line 103: | Line 103: | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: ' | group: 'extra', | ||
tools: { | tools: { | ||
"category": { | "category": { | ||
Line 123: | Line 123: | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: ' | group: 'extra', | ||
tools: { | tools: { | ||
"bailii": { | "bailii": { | ||
Line 143: | Line 143: | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: ' | group: 'extra', | ||
tools: { | tools: { | ||
"offline": { | "offline": { | ||
label: ' | label: 'Judgment available offline', | ||
type: 'button', | type: 'button', | ||
icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0c/Toolbar_no_wiki.png', | icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0c/Toolbar_no_wiki.png', | ||
Line 163: | Line 163: | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: ' | group: 'extra', | ||
tools: { | tools: { | ||
"online": { | "online": { | ||
label: ' | label: 'Judgment available on MHLO', | ||
type: 'button', | type: 'button', | ||
icon: 'https://upload.wikimedia.org/wikipedia/commons/3/33/Toolbar_welcome.png', | icon: 'https://upload.wikimedia.org/wikipedia/commons/3/33/Toolbar_welcome.png', |
Latest revision as of 23:19, 12 December 2024
/* Any JavaScript here will be loaded for all users on every page load. */ /* Ping when tick that a "To do" has been done */ $( ".ping" ).on( "click", function() { const audio = new Audio("/media/Ping.mp3"); audio.play(); }); /* Hide some CategoryTree text */ $(document).ready(function() { $("span:contains('(empty)')").hide(); }); /* 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 () { /* New group */ mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { $textarea.wikiEditor( 'addToToolbar', { section: 'advanced', groups: { extra: { label: 'Extra' } } } ); } ); /* <Blockquote> button */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'extra', 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>" } } } } } ); $( '#free_text' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'extra', 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: 'extra', 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: 'extra', 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: 'extra', tools: { "offline": { label: 'Judgment 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: 'extra', tools: { "online": { label: 'Judgment 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]]" } } } } } ); /* em dash */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'extra', tools: { "online": { label: 'em dash', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/Button_hr.png', action: { type: 'encapsulate', options: { pre: "—", } } } } } ); /* en dash */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'extra', tools: { "online": { label: 'en dash', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/4/41/Button_hr_halfwidth.png', action: { type: 'encapsulate', options: { pre: "–", } } } } } ); }; /* 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 ); } } ); }