“User:Bhsd/widget/songposition.js”的版本间差异

无编辑摘要
/*global mw, $, OO*/
(() => {
let popup, label;
function main($content) {
function prepare() {
const label = $('<span>');
mw.loader.using( 'oojs-ui-core' ).then(() => {
const popup = new OO.ui.PopupWidget({$content: label, classes: ['member-popup'], padded: true, width: null});
popup.$element.appendTo( 'body' );
$content.find( '.member-symbol' ).each(function() { this.dataset.title = this.title; })
.removeAttr( 'title' ).attr('tabIndex', -1).on('mouseenter focus', function() {
const self = $(this);
label.text( self.data('title') );
popup.setFloatableContainer( self ).toggle(true);
}).on('mouseleave blur', () => { popup.toggle(false); });
});
}
function main($content) {
$content.find( '.member-symbol' ).each(function() { this.dataset.title = this.title; }).removeAttr( 'title' )
.removeAttr( 'title' ).attr('tabIndex', -1).on('mouseenter focus', function() {
const self = $(this);
label.text( self.data('title') );
popup.toggle( true popup).setFloatableContainer( self ).toggle(true);
}).on('mouseleave blur', () => { popup.toggle(false); });
}
console.log( 'setInterval: 等待jQuery加载完毕' );
clearInterval(jqueryTimer);
console.log(`End setInterval: jQuery加载完毕,用时 ${Date.now() - timerStart} ms`);
prepare();
mw.hook( 'wikipage.content' ).add($content => { main($content); });
}, 500);
16,874

个编辑