MediaWiki:Common.js: Difference between revisions
From IFWiki
mNo edit summary |
(Add autofocus to the search box unless some other element already has it) |
||
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. */ | ||
// Add autofocus to the search box unless some other element already has it | |||
$(document).ready(function() { | |||
setTimeout(function() { | |||
if (!document.activeElement || document.activeElement === document.body) { | |||
$('#searchInput').focus(); | |||
} | |||
}, 100); // Delay for 100ms to allow initial focus to settle | |||
}); | |||
/* Dark mode exception */ | /* Dark mode exception */ |
Latest revision as of 23:34, 1 March 2025
/* Any JavaScript here will be loaded for all users on every page load. */
// Add autofocus to the search box unless some other element already has it
$(document).ready(function() {
setTimeout(function() {
if (!document.activeElement || document.activeElement === document.body) {
$('#searchInput').focus();
}
}, 100); // Delay for 100ms to allow initial focus to settle
});
/* Dark mode exception */
$("#mw-navbar").addClass("mw-no-invert");
// See 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.
/* Remove button for <big> */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section': 'advanced',
'group': 'size',
'tool': 'big'
});
/* Remove button for <small> */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section': 'advanced',
'group': 'size',
'tool': 'small'
});
/* Remove <ref> button as we don't use the Cite extension */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section': 'main',
'group': 'insert',
'tool': 'reference'
});
/* Remove link button as we'll include it in the dropdown */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section': 'main',
'group': 'insert',
'tool': 'link'
});
/ * Add "Insert link" dropdown list */
$textarea.wikiEditor( 'addToToolbar', {
section: 'main',
groups: {
'insert': {
tools: {
'links': {
label: 'Insert link',
type: 'select',
list: {
'live-link': {
label: 'Live link - using IFWiki\'s link template',
action: {
type: 'encapsulate',
options: {
pre: '{{link | url=',
post: ' | archive= | text= }}'
}
}
},
'dead-link': {
label: 'Dead link - using IFWiki\'s link template',
action: {
type: 'encapsulate',
options: {
pre: '{{link | deadurl=',
post: ' | archive= | text= }}'
}
}
},
'standard-link': {
label: 'Standard link - using wiki markup',
labelMsg: 'wikieditor-toolbar-tool-link',
action: {
type: 'dialog',
module: 'insert-link'
}
}
}
}
}
}
}
} );
} );
}