User:Krinkle/insertVectorButtons.js
Appearance
From Meta, a Wikimedia project coordination wiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/** * Insert Vector Buttons * * @author Krinkle, 2010–2015 * @revision 2015年03月25日 * @source https://meta.wikimedia.org/wiki/User:Krinkle/Scripts/insertVectorButtons * * This script is released in the public domain. */ if($.fn.wikiEditor&&typeofkCustomMainInsertButton==='undefined'&&(mw.config.get('wgAction')=='edit'||mw.config.get('wgAction')=='submit')){ window.kCustomMainInsertButton=function(imageId,imageFile,speedTip,tagOpen,tagClose,sampleText,callback){ // Reason for the a[b]-method instead of the much shorter a.b-method // is to dynamically set the object name imageId varwikiOptions={'section':'main','group':'insert','tools':{}}; wikiOptions.tools[imageId]={ label:speedTip, type:'button', icon:imageFile, action:{ type:'callback', execute:function(){ $('#wpTextbox1').textSelection('encapsulateSelection',{ pre:tagOpen, peri:sampleText, post:tagClose }); if(callback){callback();} } } }; $('#wpTextbox1').wikiEditor('addToToolbar',wikiOptions); }; jQuery(function(){ if(typeofkCustomMainInsertButton_config!==undefined){ kCustomMainInsertButton_config(); } }); }else{ window.kCustomMainInsertButton=function(){}; }