MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Adding GlobalFileUsage |
move to gadget |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 3: | Line 3: | ||
/************************************************************************/ | /************************************************************************/ | ||
/* for [[dev:GlobalFileUsage]] */ | /* for [[w:c:dev:GlobalFileUsage]] */ | ||
window.globalFileUsageConfig = { | window.globalFileUsageConfig = { | ||
'lang': [' | 'lang': ['pl', 'ru', 'vi', 'zh'], | ||
'auto_show': false | 'auto_show': false | ||
} | |||
// Modifying redirect button from WikiEditor's source mode | |||
mw.hook('ext.CodeMirror.ready').add(() => { | |||
$( '#wpTextbox1' ).on('wikiEditor-toolbar-buildSection-advanced', ( event, section ) => { | |||
// The exact paths are available in `jquery.wikiEditor.toolbar.config.js` file of the extension | |||
section.groups.insert.tools.redirect.action.options.pre = '#REDIRECT [['; | |||
section.groups.insert.tools.redirect.action.options.post = ']]\n\n[[Category:Redirect Pages]]'; | |||
}); | |||
}); | |||
// Fix the search field not updating when ctrl+f with text selected (should be removed when/if fandom fixes it in native) | |||
if (['edit', 'submit'].includes(mw.config.get('wgAction'))) { | |||
mw.hook('ext.CodeMirror.ready').add((cmDOM, cm)=>{ | |||
cmDOM.find('.cm-content').get(0).addEventListener('keydown', (e)=>{ | |||
if (e.key.toLowerCase()==='f' && e.ctrlKey) { | |||
const | |||
selected = cm.view.state.sliceDoc( | |||
cm.view.state.selection.main.from, | |||
cm.view.state.selection.main.to | |||
), | |||
search = cmDOM.find('.cdx-text-input__input[name="search"]'); | |||
if (search.length>0 && selected.length>0) { search.val(selected); } | |||
} | |||
}, { capture: true }); | |||
}); | |||
} | } | ||
Latest revision as of 18:47, 14 July 2026
/************************************************************************/
/* Any JavaScript here will be loaded for all users on every page load. */
/************************************************************************/
/* for [[w:c:dev:GlobalFileUsage]] */
window.globalFileUsageConfig = {
'lang': ['pl', 'ru', 'vi', 'zh'],
'auto_show': false
}
// Modifying redirect button from WikiEditor's source mode
mw.hook('ext.CodeMirror.ready').add(() => {
$( '#wpTextbox1' ).on('wikiEditor-toolbar-buildSection-advanced', ( event, section ) => {
// The exact paths are available in `jquery.wikiEditor.toolbar.config.js` file of the extension
section.groups.insert.tools.redirect.action.options.pre = '#REDIRECT [[';
section.groups.insert.tools.redirect.action.options.post = ']]\n\n[[Category:Redirect Pages]]';
});
});
// Fix the search field not updating when ctrl+f with text selected (should be removed when/if fandom fixes it in native)
if (['edit', 'submit'].includes(mw.config.get('wgAction'))) {
mw.hook('ext.CodeMirror.ready').add((cmDOM, cm)=>{
cmDOM.find('.cm-content').get(0).addEventListener('keydown', (e)=>{
if (e.key.toLowerCase()==='f' && e.ctrlKey) {
const
selected = cm.view.state.sliceDoc(
cm.view.state.selection.main.from,
cm.view.state.selection.main.to
),
search = cmDOM.find('.cdx-text-input__input[name="search"]');
if (search.length>0 && selected.length>0) { search.val(selected); }
}
}, { capture: true });
});
}