User:Bhsd/widget/songposition.js

< User:Bhsd‎ | widget
Bhsd讨论 | 贡献2020年12月12日 (六) 05:24的版本

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
//<nowiki>
// 用于[[Widget:Songposition]],可以使用ES6语法
"use strict";
/*global mw, $, OO*/
(() => {
    function main($content) {
        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); });
        });
    }
    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.hook( 'wikipage.content' ).add($content => { main($content); });
    }, 500);
}) ();
//</nowiki>
// [[category:jQuery小部件]] {{DEFAULTSORT:Songposition}}