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

更新了mw.menu()方法
(更新了mw.menu()方法)
}) );
let items = [], $table;
const $menu = mw.menu([ {text: "µ's", data: 'muse'}, {colortext: '#e4007fAqours', namedata: 'museaqours'}},
{text: 'AqoursSaint Snow', data: {color:'saint snow'#32aaff'}}, {text: mw.msg( 'Saintgadget-ma-niji' Snow'), data: {color: '#cb3935nijigaku'}},
{text: mw.msg('Liella!', data: 'gadget-ma-nijiliella'}, ){text: 'SIF', data: 'sif'}, {colortext: '#f39800AS', namedata: 'nijigakuas'}},
], {}, 1),
{text: 'Liella!', data: {color: '#a5469c', name: 'liella'}},
$menu = menu.$element,
{text: 'SIF', data: {color: '#77d2af'}}, {text: 'AS', data: {color: '#ff91af'}}
colors = { muse: '#e4007f', aqours: '#32aaff', 'saint snow': '#cb3935', nijigaku: '#f39800', liella: '#a5469c',
], {}, 1),
sif: '#77d2af', as: '#ff91af'
},
dict = {ll: 'muse', llss: 'aqours', llspst: 'liella'},
getName = (ele) => $(ele).data( 'name' ) || ele.textContent.toLowerCase(),
findSelected = (name) => [...$menu.children()].find(ele => getName( ele ) == (dict[name] || name)),
writeText = () => {
const wikitext = items.map(ele =>
} else { $table = $('.mw-parser-output table'); }
mw.loader.addStyleTag( '.mainpage-flex td:last-child { width: calc(' + width + 'px - 1.2em); }' );
$menu.on('clickchoose', 'a',option function()=> {
$menu.prev( '.mainpage-tag' ).css('background-color', $colors[ option.getData(this).data( 'color' )]);
items[ $menu.closest( 'tr' ).index() ][0] = getNameoption.getData( this );
});
$table.on('dblclick', 'td:first-child', function() {
$menu.appendTo( this );
$menu.setSelected(const findSelected(name = items[ $(this).parent().index() ][0].toLowerCase() ) ).open();
menu.selectItemByData( dict[name] || name );
menu.toggle( true );
}).on('dblclick', 'td:last-child', function() {
const $this = $(this),
16,874

个编辑