MediaWiki:Common.js/edit.js
From DoomWiki.org
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences.
/*global mw */ /*jshint strict: false, browser: true, jquery: true */ /** * Extra toolbar options * * Description: Adds extra buttons to the editing toolbar. * * Maintainers: [[User:Quasar]] (derived from https://en.wikipedia.org/wiki/MediaWiki:Common.js/edit.js) */ // <nowiki> function addExtraButtons() { var TOOL_ONEDIT = 0x01; var TOOL_ONUPLOAD = 0x02; var TOOL_ONCENTRAL = 0x04; var TOOL_ONBOTH = (TOOL_ONEDIT | TOOL_ONUPLOAD); var tools = [ // Generic editing tasks { imageId: 'mw-editbutton-signature', speedTip: 'Your signature with timestamp', tagOpen: '--~~~~', tagClose: '', sampleText: '', onUpload: TOOL_ONCENTRAL }, { imageId: 'button-add-category', imageFile: '//doomwiki.org/w/images/1/11/Button_category.png', speedTip: 'Add a category', tagOpen: '[[Category:', tagClose: ']]', sampleText: 'categoryname', onUpload: TOOL_ONBOTH }, { imageId: 'button-code-tag', imageFile: '//doomwiki.org/w/images/2/23/Button_code.png', speedTip: 'Insert inline code', tagOpen: '{{c|', tagClose: '}}', sampleText: 'code', onUpload: TOOL_ONBOTH }, { imageId: 'button-timeline-link', imageFile: '//doomwiki.org/w/images/4/40/Button_timeline.png', speedTip: 'Create a Timeline link', tagOpen: '{{timeline|', tagClose: '}}', sampleText: 'year', onUpload: TOOL_ONBOTH }, { imageId: 'button-link-wikipedia', imageFile: '//doomwiki.org/w/images/8/8a/Button_wikipedia_link.png', speedTip: 'Link to an article on Wikipedia', tagOpen: '{{wp|', tagClose: '}}', sampleText: 'article|linktext', onUpload: TOOL_ONBOTH }, // Image and video buttons { imageId: 'button-image-right', imageFile: '//doomwiki.org/w/images/2/29/Button_image_right.png', speedTip: 'Insert a right-aligned thumbnail', tagOpen: '[[File:', tagClose: '|thumb|right|description]]', sampleText: 'Example.png', onUpload: TOOL_ONEDIT }, { imageId: 'button-gallery', imageFile: '//doomwiki.org/w/images/c/cc/Button_gallery_silk.png', speedTip: 'Insert a picture gallery', tagOpen: '\n<gallery>\n', tagClose: '\n</gallery>', sampleText: 'Example.png|Caption1', onUpload: TOOL_ONEDIT }, { imageId: 'button-movie', imageFile: '//doomwiki.org/w/images/c/c1/Button_movie.png', speedTip: 'Embed a YouTube video', tagOpen: '{{youtube|', tagClose: '|description}}', sampleText: 'videoid', onUpload: TOOL_ONEDIT }, { imageId: 'button-fileinfo', imageFile: '//doomwiki.org/w/images/b/b5/Button_fileinfo.png', speedTip: 'Insert FileInfo template', tagOpen: '{{FileInfo\n|description=\n|date=\n|source=\n|author=\n|permission=\n', tagClose: '}}', sampleText: '', onUpload: TOOL_ONUPLOAD }, // Table buttons { imageId: 'button-pretty-table', imageFile: '//doomwiki.org/w/images/0/04/Button_array.png', speedTip: 'Insert a pretty table', tagOpen: '{| {{prettytable}}\n|-\n|', tagClose: '\n|}', sampleText: '', onUpload: TOOL_ONBOTH }, { imageId: 'button-pretty-sortable', imageFile: '//doomwiki.org/w/images/b/b5/Button_tablesort.png', speedTip: 'Insert a sortable table', tagOpen: '{| {{prettySortable}}\n|-\n|', tagClose: '\n|}', sampleText: '', onUpload: TOOL_ONBOTH }, // Citations and references { imageId: 'button-insert-reflink', imageFile: '//doomwiki.org/w/images/2/2b/Button_ref_inscription.png', speedTip: 'Insert a generic reference', tagOpen: '<ref>', tagClose: '</ref>', sampleText: 'footnote', onUpload: TOOL_ONEDIT }, { imageId: 'button-cite-web', imageFile: '//doomwiki.org/w/images/9/91/Button_cite_web.png', speedTip: 'Insert a webpage reference', tagOpen: '{{cite web|author=|title=|url=|publication=|publishdate=|accessdate=', tagClose: '}}', sampleText: '', onUpload: TOOL_ONEDIT }, { imageId: 'button-insert-references', imageFile: '//doomwiki.org/w/images/9/9a/Button_references.png', speedTip: 'Create a References section', tagOpen: '==References==\n<references />', tagClose: '\n', sampleText: '', onUpload: TOOL_ONEDIT }, // Archiving { imageId: 'button-archive-link', imageFile: '//doomwiki.org/w/images/5/53/Button_brokenlink.png', speedTip: 'Archive a broken link', tagOpen: '{{archived link|', tagClose: '|title|archive link|archived at}}', sampleText: 'original link', onUpload: TOOL_ONEDIT }, { imageId: 'button-archive-citeweb', imageFile: '//doomwiki.org/w/images/3/32/Button_brokencite.png', speedTip: 'Archive a broken web citation', tagOpen: '{{cite web archived|author=|title=|url=|publication=|publishdate=|accessdate=|archiveurl=|archivedat=', tagClose: '}}', sampleText: '', onUpload: TOOL_ONEDIT }, // Magic words and stuff { imageId: 'button-redirect', imageFile: '//doomwiki.org/w/images/c/c8/Button_redirect.png', speedTip: 'Redirect this article to another', tagOpen: '#REDIRECT [[', tagClose: ']]', sampleText: 'pagename', onUpload: TOOL_ONEDIT } ]; var toolbar, toolFlags; if(mw.config.get('wgCanonicalSpecialPageName') === 'Upload') { toolFlags = TOOL_ONUPLOAD; toolbar = mw.libs.uploadToolbar; } else { // pages we want to add a signature button on which aren't in talk spaces var pagesWithSigButton = [ 'Doom_Wiki:Central_Processing', 'Doom_Wiki:Information_removal_requests', 'Doom_Wiki:Grants_of_permission' ]; toolFlags = TOOL_ONEDIT; if(pagesWithSigButton.indexOf(mw.config.get('wgPageName')) !== -1) toolFlags |= TOOL_ONCENTRAL; // add signature button toolbar = mw.toolbar; } for(var i = 0; i < tools.length; i++) { if((tools[i].onUpload & toolFlags) !== 0) toolbar.addButton(tools[i]); } } mw.loader.using('user.options', function () { // This can be the string "0" if the user disabled the preference ([[bugzilla:52542#c3]]) if(mw.user.options.get('usebetatoolbar') != 1 && mw.user.options.get('showtoolbar') == 1) { var deps; if(mw.config.get('wgCanonicalSpecialPageName') === 'Upload') deps = [ 'mediawiki.toolbar', 'ext.gadget.UploadToolbar' ]; else deps = [ 'mediawiki.toolbar' ]; $.when( mw.loader.using(deps), $.ready ).then(addExtraButtons); } }); // </nowiki>