LLWiki正在建设中,欢迎加入我们!
“MediaWiki:Gadget-site-lib.js”的版本间差异
跳转到导航
跳转到搜索
小 |
|||
/**
* @Function: 生成一个
* @Dependencies: oojs-ui-core, ext.gadget.site-styles
* @Param {Object[]} options, 形如{text,
* @Param {String} text, 文本,必须独一无二
* @Param {String} icon, FontAwesome的图标名称(仅限fas类,可选)
* @Param {Object} data, 数据(可选,默认为text)
* @Param {String} href, 链接(可选)
* @Param {Function} click, 单击事件(可选)
* @Param {Object}
* @Return {OO.ui.MenuSelectWidget}
*/
mw.menu = function(options,
const hasIcon = options.some(function(
menu = new OO.ui.MenuSelectWidget( $.extend({ classes: ['site-menu'], hideWhenOutOfView: false,
// 不使用OO.ui.HtmlSnippet,防止污染label属性
if (hasIcon) { widget.$label.
}, config) );
options.filter(function(e) { return e.selected; }).forEach(function(e) { menu.selectItemByLabel( e.text ); });
if (!hasClick)
const option = options.find(function(e) { e.text == item.getLabel(); });
if (option.href) { location.href = option.href; }
▲ setSelected: function(child) {
▲ return this;
});
return
};
|