LLWiki正在建设中,欢迎加入我们

“MediaWiki:Gadget-SettingsDialog.js”的版本间差异

跳转到导航 跳转到搜索
"use strict";
/* global OO, wgULS */
mw.messages.set( wgULS({'gadget-sd-title': '小工具设置', 'gadget-sd-notify': '您的设置已保存!'},
{'gadget-sd-titlesave': '小工具偏好設定保存', 'gadget-sd-notifycancel': '您的偏好設定已儲存!取消'}) );,
{'gadget-sd-title': '小工具偏好設定', 'gadget-sd-notify': '您的偏好設定已儲存!',
// constructor只添加一个CSS类,剩下的交给addTab方法逐一添加小工具或initialize方法生成html
'gadget-sd-save': '儲存', 'gadget-sd-cancel': '取消'}) );
// constructor只添加一个CSS类,剩下的交给addTab方法逐一添加小工具或initialize方法生成html
function SettingsDialog(config) {
config.classes = (config.classes || []).concat( 'settingsDialog' );
}
OO.inheritClass(SettingsDialog, OO.ui.ProcessDialog);
// initialize只创建一个OO.ui.IndexLayout对象,剩下的交给addTab方法填入内容
SettingsDialog.prototype.initialize = function() {
SettingsDialog.super.prototype.initialize.apply(this, arguments);
this.content = new OO.ui.IndexLayout();
this.gadgets.forEach(function(gadget) {
gadget.panel = new OO.ui.TabPanelLayout( gadget.name, {label: gadget.label} );
gadget.checkboxes.forEach(function(ele) {
ele.widget = new OO.ui.CheckboxInputWidget();
});
gadget.radios.forEach(function(ele) {
ele.widget = new OO.ui.RadioSelectInputWidget({options: ele.options});
});
gadget.panel.$element.append( gadget.checkboxes.map(function(ele) {
return new OO.ui.FieldLayout(ele.widget, {label: ele.label, align: 'inline', help: ele.help,
helpinline: true}).$element;
}) ).append( gadget.radios.map(function(ele) {
return new OO.ui.FieldLayout(ele.widget, {label: ele.label, align: 'inline', help: ele.help,
helpinline: true, classes: ['multioptions-wrap']}).$element;
}) );
});
this.clearOptions();
this.content.addTabPanels( this.gadgets.map(function(gadget) { return gadget.panel; }) );
};
SettingsDialog.prototype.getActionProcess = function(action) {
};
SettingsDialog.prototype.addTab = function(params) {
const gadgetsettings = {name:mw.gadgets[ params.name || params[0], label: params.label || params[1]{};
gadgetparams.checkboxes = (params.checkboxes || []).map(function(ele) {;
params.radios = params.radios || [];
return {data: ele.data || ele[0], label: ele.label || ele[1], default: ele.default || ele[2]};
thisparams.gadgetscheckboxes.forEach(function(gadgetele) {
ele.widget = new OO.ui.CheckboxInputWidget({selected: settings[ ele.data ]});
});
gadget.radios = (params.radios || []).mapforEach(function(ele) {
ele.widget = new OO.ui.RadioSelectInputWidgetRadioSelectWidgetInputWidget({options: ele.options, value: settings[ ele.data ]});
return {data: ele.data || ele[0], label: ele.label || ele[1], default: ele.default || ele[3],
options:delete ele.options || ele[2]};
});
gadgetparams.panel = new OO.ui.TabPanelLayout( gadgetparams.name, {label: gadgetparams.label} );
this.gadgets.push( gadget );
params.panel.$element.append( gadgetparams.checkboxes.forEachmap(function(ele) {
return new OO.ui.FieldLayout(ele.widget, {label: ele.label, align: 'inline', help: ele.help,
helpinline: true}).$element;
}) ).append( gadgetparams.radios.forEachmap(function(ele) {
return new OO.ui.FieldLayout(ele.widget, {label: ele.label, align: 'inline', help: ele.help,
helpinline: true, classes: ['multioptions-wrap']}).$element;
}) });
this.gadgets.push( gadgetparams );
};
SettingsDialog.prototype.removeTab = function(index) {
};
SettingsDialog.static = {name: 'settingsDialog', tagName: 'div', title: mw.msg('gadget-sd-title'),
actions: [{action: 'save', label: mw.msg('uploadgadget-dialog-buttonsd-save'), flags: ['primary', 'progressive']},
{action: 'cancel', label: mw.msg('uploadgadget-dialog-buttonsd-cancel'), flags: 'safe'}]
};
mw.settingsDialog = new SettingsDialog({});