LLWiki正在建设中,欢迎加入我们!
“User:Bhsd/widget/songposition.js”的版本间差异
跳转到导航
跳转到搜索
小 |
小 |
||
第2行: | 第2行: | ||
// 用于[[Widget:Songposition]],可以使用ES6语法 |
// 用于[[Widget:Songposition]],可以使用ES6语法 |
||
"use strict"; |
"use strict"; |
||
/*global mw, $ |
/*global mw, $*/ |
||
(() => { |
(() => { |
||
let popup, label; |
|||
function prepare() { |
|||
label = $('<span>'); |
|||
⚫ | |||
popup = new OO.ui.PopupWidget({$content: label, classes: ['member-popup'], padded: true, width: null}); |
|||
popup.$element.appendTo( 'body' ); |
|||
⚫ | |||
} |
|||
function main($content) { |
|||
$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.toggle( true ).setFloatableContainer( self ); |
|||
}).on('mouseleave blur', () => { popup.toggle(false); }); |
|||
} |
|||
console.log( 'setInterval: 等待jQuery加载完毕' ); |
console.log( 'setInterval: 等待jQuery加载完毕' ); |
||
const timerStart = Date.now(), |
const timerStart = Date.now(), |
||
第26行: | 第10行: | ||
clearInterval(jqueryTimer); |
clearInterval(jqueryTimer); |
||
console.log(`End setInterval: jQuery加载完毕,用时 ${Date.now() - timerStart} ms`); |
console.log(`End setInterval: jQuery加载完毕,用时 ${Date.now() - timerStart} ms`); |
||
mw.widget = mw.widget || {}; |
|||
mw. |
if (mw.widget.songposition) { return; } |
||
⚫ | |||
mw.tipsy($('body'), '.member-symbol', {classes: ['member-popup']}); |
|||
⚫ | |||
mw.widget.songposition = true; |
|||
}, 500); |
}, 500); |
||
}) (); |
}) (); |
2021年1月11日 (一) 02:17的版本
//<nowiki> // 用于[[Widget:Songposition]],可以使用ES6语法 "use strict"; /*global mw, $*/ (() => { console.log( 'setInterval: 等待jQuery加载完毕' ); const timerStart = Date.now(), jqueryTimer = setInterval(() => { if (!window.jQuery) { return; } clearInterval(jqueryTimer); console.log(`End setInterval: jQuery加载完毕,用时 ${Date.now() - timerStart} ms`); mw.widget = mw.widget || {}; if (mw.widget.songposition) { return; } mw.loader.using(['oojs-ui-core', 'ext.gadget.site-lib']).then(() => { mw.tipsy($('body'), '.member-symbol', {classes: ['member-popup']}); }); mw.widget.songposition = true; }, 500); }) (); //</nowiki> // [[category:jQuery小部件]] {{DEFAULTSORT:Songposition}}