LLWiki正在建设中,欢迎加入我们!
User:Bhsd/widget/sif-song-table.js
跳转到导航
跳转到搜索
注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件。
//<nowiki> // 用于[[Widget:Sif-song-table]],可以使用ES6语法 /** * @Function: 用于[[LoveLive!学园偶像祭歌曲列表]]的表格折叠 * @Author: [[User:Bhsd]] */ "use strict"; /* global mw, $ */ (() => { let isMobile; const formatData = (ele) => ele.textContent.toLowerCase().replace(/[^a-z0-9]/g, ''), main = ($content) => { const $dropdown = $content.find( '.sif-song-table .tabs-content' ) .attr({lang: 'ja', style: 'height: auto !important; left: -1000000px;'}); if ($dropdown.length === 0) { return; } console.log('Hook: wikipage.content, 开始折叠SIF歌曲列表的下拉选单'); // 手机版的下拉菜单解析有误 if (isMobile) { $dropdown.append(function() { return $(this).next(); }); } $dropdown.parent().one('mouseenter', function() { const $this = $(this), $menu = $this.children( '.tabs-content' ); $this.css('width', $this.children( '.tabs-content' ).width()); $menu.css('height', $menu.height()); }); $dropdown.find( 'li' ).not(function() { return $(this).closest( '.sif-song-table' ).find( `[data-${formatData( this )}]` ).length; }).remove(); }, handler = () => { mw.widget = mw.widget || {}; if (mw.widget.sifSongTable) { return; } isMobile = mw.config.get('skin') == 'minerva'; mw.hook( 'wikipage.content' ).add( main ); $('#bodyContent').on('click', '.sif-song-table .tabs-content', function(e) { const option = e.target, lvl = formatData( option ); $(this).css('left', '-1000000px').prev().text( option.textContent ).closest( '.sif-song-table' ) .find( '.sif-song-option' ).html(function() { const data = this.dataset[lvl] || ''; return [data.replace(/\D/g, '') || '/', data.endsWith( 'swing' ) ? $('<i>', {class: 'swing'}) : null]; }); }).on('mouseenter', '.sif-song-table .tabs-label', function() { $(this).next().css('left', ''); }); mw.widget.sifSongTable = true; }; if (window.jQuery) { handler(); } else { window.addEventListener('jquery', handler); } }) (); //</nowiki> // [[category:jQuery小部件]] {{DEFAULTSORT:Sif-song-table}}