跳转到内容

User:Liangent/Scripts/EditToolbarThunks.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
if (window.jQuery) {
    window.oldToolbarItems = {
        'old': {
            label: 'Old',
            type: 'toolbar',
            groups: {
                'old': {
                    tools: {}
                }
            }
        }
    };
    var convertDropdown = function(optionList) {
        var list = {};
        jQuery.each(optionlist, function() {
            list[this.id] = {
                label: this.text,
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: this.tagOpen,
                        peri: this.sampleText,
                        post: this.tagClose
                    }
                }
            };
        });
        return list;
    };
    window.addDropdownMenu = function(name, label, optionList) {
        window.oldToolbarItems['old'].groups['old'].tools[name] = {
            label: label,
            type: 'select',
            list: convertDropdown(optionlist)
        };
    };
    window.addEditButton = function(name, options) {
        window.oldToolbarItems['old'].groups['old'].tools[name] = {
            label: options.speedTip,
            type: 'button',
            icon: '../../../../../../wiki/Special:FilePath/' + options.src.slice(5),
            action: {
                type: 'encapsulate',
                options: {
                    pre: this.tagOpen,
                    peri: this.sampleText,
                    post: this.tagClose
                }
            }
        };
    };
    addOnloadHook(function() {
        if (window.editToolbarConfiguration) {
            jQuery.extend(true, window.editToolbarConfiguration, window.oldToolbarItems);
        }
    });
}