User:Tol/VECN.js
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* <nowiki>
VisualEditor Citation Needed (VECN)
This comes with no warranties of any kind, including any implied warranties.
This work (all content on this page) is licensed under:
* The Creative Commons Attribution-ShareAlike 3.0 [https://creativecommons.org/licenses/by-sa/3.0/] (CC BY-SA 3.0) license;
* The Creative Commons Attribution-ShareAlike 4.0 [https://creativecommons.org/licenses/by-sa/4.0/] (CC BY-SA 4.0) license;
* The GNU Lesser General Public License [https://www.gnu.org/copyleft/lgpl.html] (LGPL), version 3 or any later version.
* The GNU Free Documentation License [http://www.gnu.org/licenses/fdl-1.3.html] (GFDL), version 1.2 or any later version, with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/
function cn_make() {
var cn_template = [ {
type: 'mwTransclusionInline',
attributes: {
mw: {
parts: [ {
template: {
target: {
href: 'Template:Citation needed',
wt: 'Citation needed'
},
params: {
date: {
wt: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'
}
}
}
} ]
}
}
}, {
type: '/mwTransclusionInline'
} ];
ve.ui.commandRegistry.register(
new ve.ui.Command(
'tol_vecn_command',
'content',
'insert',
{
args: [ cn_template, false, true ],
supportedSelections: [ 'linear' ]
} )
);
function cn_tool() {
cn_tool.parent.apply( this, arguments );
}
OO.inheritClass( cn_tool, ve.ui.MWTransclusionDialogTool );
cn_tool.static.name = 'tol_vecn_tool';
cn_tool.static.group = 'object';
cn_tool.static.title = 'Citation needed';
cn_tool.static.commandName = 'tol_vecn_command';
cn_tool.static.icon = 'reference';
ve.ui.toolFactory.register( cn_tool );
}
mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init' ).then( function () {
mw.libs.ve.addPlugin ( function () {
return mw.loader.using( [ 'ext.visualEditor.core', 'ext.visualEditor.mwwikitext', 'ext.visualEditor.mwtransclusion' ] )
.then( function () {
cn_make();
} );
} );
} );
// </nowiki>