No edit summary
Tag: Manual revert
No edit summary
Tag: Reverted
Line 1: Line 1:
/**
* 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 2.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:Gadget-refToolbarBase.js]]
* @author: [[User:Mr.Z-man]]
* @author: [[User:Kaldari]]
*/
/* jshint browser: true, camelcase: true, curly: true, eqeqeq: true */
/* global $, mw */
(function () {
(function () {
'use strict';
    'use strict';


function initializeRefTools() {
    function loadScript(url) {
        return $.ajax({
            url: url,
            dataType: 'script',
            cache: true
        });
    }


// 2010 wikitext editor
    function initializeRefTools() {
mw.hook('wikiEditor.toolbarReady').add(() => {
        mw.hook('wikiEditor.toolbarReady').add(function () {
// TODO:
            loadScript(
// * Explicitly declare global variables from [[MediaWiki:RefToolbar.js]] using window.*
                '/w/index.php?title=MediaWiki:Gadget-refToolbarBase.js&action=raw&ctype=text/javascript'
// * Move [[MediaWiki:RefToolbar.js]] to [[MediaWiki:Gadget-refToolbarDialogs.js]]
            ).then(function () {
// * Create the module 'ext.gadget.refToolbarDialogs' depending on 'ext.gadget.refToolbarBase'
                return loadScript(
// * Replace the code below by mw.loader.load( 'ext.gadget.refToolbarDialogs' );
                    '/w/index.php?title=MediaWiki:RefToolbar.js&action=raw&ctype=text/javascript'
mw.loader.using('ext.gadget.refToolbarBase', () => {
                );
mw.loader.load('/w/index.php?title=MediaWiki:RefToolbar.js&action=raw&ctype=text/javascript');
            });
});
window.refToolbarInstalled = true;
});


// 2006 legacy toolbar
            window.refToolbarInstalled = true;
mw.hook('mw.toolbar').add(() => {
        });
mw.loader.load('/w/index.php?title=MediaWiki:RefToolbarLegacy.js&action=raw&ctype=text/javascript');
window.refToolbarInstalled = true;
});
}


if (/^(edit|submit)$/.test(mw.config.get('wgAction')) &&
        mw.hook('mw.toolbar').add(function () {
mw.config.get('wgPageContentModel') === 'wikitext' &&
            loadScript(
!$('#wpTextbox1[readonly]').length &&
                '/w/index.php?title=MediaWiki:RefToolbarLegacy.js&action=raw&ctype=text/javascript'
!window.refToolbarInstalled
            );
) {
$(initializeRefTools);
}


            window.refToolbarInstalled = true;
        });
    }
    if (
        /^(edit|submit)$/.test(mw.config.get('wgAction')) &&
        mw.config.get('wgPageContentModel') === 'wikitext' &&
        !$('#wpTextbox1[readonly]').length &&
        !window.refToolbarInstalled
    ) {
        $(initializeRefTools);
    }
}());
}());

Revision as of 19:39, 24 September 2026

(function () {
    'use strict';

    function loadScript(url) {
        return $.ajax({
            url: url,
            dataType: 'script',
            cache: true
        });
    }

    function initializeRefTools() {
        mw.hook('wikiEditor.toolbarReady').add(function () {
            loadScript(
                '/w/index.php?title=MediaWiki:Gadget-refToolbarBase.js&action=raw&ctype=text/javascript'
            ).then(function () {
                return loadScript(
                    '/w/index.php?title=MediaWiki:RefToolbar.js&action=raw&ctype=text/javascript'
                );
            });

            window.refToolbarInstalled = true;
        });

        mw.hook('mw.toolbar').add(function () {
            loadScript(
                '/w/index.php?title=MediaWiki:RefToolbarLegacy.js&action=raw&ctype=text/javascript'
            );

            window.refToolbarInstalled = true;
        });
    }

    if (
        /^(edit|submit)$/.test(mw.config.get('wgAction')) &&
        mw.config.get('wgPageContentModel') === 'wikitext' &&
        !$('#wpTextbox1[readonly]').length &&
        !window.refToolbarInstalled
    ) {
        $(initializeRefTools);
    }
}());