MediaWiki:Common.js/edit.js

/*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) */ // function addExtraButtons { var tools = [ // Generic editing tasks {     imageId: 'button-add-category', imageFile: '//doomwiki.org/w/images/1/11/Button_category.png', speedTip: 'Add a category', tagOpen: '[[Category:',     tagClose: ']]', sampleText: 'categoryname', onUpload: true },  {      imageId: 'button-code-tag', imageFile: '//doomwiki.org/w/images/2/23/Button_code.png', speedTip: 'Insert inline code', tagOpen: '', sampleText: 'code' onUpload: true },  {      imageId: 'button-timeline-link', imageFile: '//doomwiki.org/w/images/4/40/Button_timeline.png', speedTip: 'Create a Timeline link', tagOpen: '', sampleText: 'year' onUpload: true },  {      imageId: 'button-link-wikipedia', imageFile: '//doomwiki.org/w/images/8/8a/Button_wikipedia_link.png', speedTip: 'Link to an article on Wikipedia', tagOpen: '', sampleText: 'article|linktext' onUpload: true },  // 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: ,     tagClose: , sampleText: 'Example.png' onUpload: false },  {      imageId: 'button-gallery', imageFile: '//doomwiki.org/w/images/c/cc/Button_gallery_silk.png', speedTip: 'Insert a picture gallery', tagOpen: '\n', sampleText: 'Example.png|Caption1' onUpload: false },  {      imageId: 'button-movie', imageFile: '//doomwiki.org/w/images/c/c1/Button_movie.png', speedTip: 'Embed a YouTube video', tagOpen: '', sampleText: 'videoid' onUpload: false },  // Table buttons {     imageId: 'button-pretty-table', imageFile: '//doomwiki.org/w/images/0/04/Button_array.png', speedTip: 'Insert a pretty table', tagOpen: '{| \n|-\n|', tagClose: '\n|}', sampleText: '' onUpload: true },  {      imageId: 'button-pretty-sortable', imageFile: '//doomwiki.org/w/images/b/b5/Button_tablesort.png', speedTip: 'Insert a sortable table', tagOpen: '{| \n|-\n|', tagClose: '\n|}', sampleText: '' onUpload: true },  // Citations and references {     imageId: 'button-insert-reflink', imageFile: '//doomwiki.org/w/images/2/2b/Button_ref_inscription.png', speedTip: 'Insert a generic reference', tagOpen: ' ', sampleText: 'footnote' onUpload: false },  {      imageId: 'button-cite-web', imageFile: '//doomwiki.org/w/images/9/91/Button_cite_web.png', speedTip: 'Insert a webpage reference', tagOpen: '', sampleText: '' onUpload: false },  {      imageId: 'button-insert-references', imageFile: '//doomwiki.org/w/images/9/9a/Button_references.png', speedTip: 'Create a References section', tagOpen: '==References==\n ', tagClose: '\n', sampleText: '' onUpload: false },  // Archiving {     imageId: 'button-archive-link', imageFile: '//doomwiki.org/w/images/5/53/Button_brokenlink.png', speedTip: 'Archive a broken link', tagOpen: '', sampleText: 'original link' onUpload: false },  {      imageId: 'button-archive-citeweb', imageFile: '//doomwiki.org/w/images/3/32/Button_brokencite.png', speedTip: 'Archive a broken web citation', tagOpen: '', sampleText: '' onUpload: false },  // 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: false }  ];

var toolbar, onUpload; if(mw.config.get('wgCanonicalSpecialPageName') === 'Upload') { onUpload = true; toolbar = mw.libs.uploadToolbar; } else { onUpload = false; toolbar = mw.toolbar; }  for(var i = 0; i < tools.length; i++) { if(tools[i].onUpload == onUpload) mw.toolbar.addButton(tools[i]); } }

mw.loader.using('user.options', function {   // This can be the string "0" if the user disabled the preference (52542)   if(mw.user.options.get('usebetatoolbar') != 1 && mw.user.options.get('showtoolbar') == 1) {      $.when( mw.loader.using('mediawiki.action.edit' /*'mediawiki.toolbar'*/), // UPDATE ME FOR MediaWiki 1.25! $.ready ).then(addExtraButtons);  } }); //