LLWiki正在建设中,欢迎加入我们!
“User:Masanaga/widget/ac-song-table.js”的版本间差异
跳转到导航
跳转到搜索
(并未投入实用的用户脚本) 标签:移动版网页编辑 移动版编辑 |
|||
第47行: | 第47行: | ||
}) (); |
}) (); |
||
//</nowiki> |
//</nowiki> |
||
// [[category:jQuery小部件]] {{DEFAULTSORT:ac-song-table}} |
2021年6月30日 (三) 12:26的最新版本
//<nowiki> // 用于[[Widget:ac-song-table]],可以使用ES6语法 /** * @Function: 用于[[LoveLive!学园偶像祭~after school ACTIVITY~ Wai-Wai! Home Meeting!!歌曲列表]]的表格折叠 * @Author: [[User:Bhsd]],由[[User:Masanaga]]在[[User:Bhsd]]的[[User:Bhsd/widget/sif-song-table.js]]的基础上进行了针对[[oveLive!学园偶像祭~after school ACTIVITY~]]的特化修改。 */ "use strict"; /* global mw, $ */ (() => { let isMobile; const formatData = (ele) => ele.textContent.toLowerCase().replace(/[^a-z0-9]/g, ''), main = ($content) => { const $dropdown = $content.find( '.ac-song-table .tabs-content' ) .attr({lang: 'ja', style: 'height: auto !important; left: -1000000px;'}); if ($dropdown.length === 0) { return; } console.log('Hook: wikipage.content, 开始折叠ac歌曲列表的下拉选单'); // 手机版的下拉菜单解析有误 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( '.ac-song-table' ).find( `[data-${formatData( this )}]` ).length; }).remove(); }, handler = () => { mw.widget = mw.widget || {}; if (mw.widget.acSongTable) { return; } isMobile = mw.config.get('skin') == 'minerva'; mw.hook( 'wikipage.content' ).add( main ); $('#bodyContent').on('click', '.ac-song-table .tabs-content', function(e) { const option = e.target, lvl = formatData( option ); $(this).css('left', '-1000000px').prev().text( option.textContent ).closest( '.ac-song-table' ) .find( '.ac-song-option' ).html(function() { const data = this.dataset[lvl] || ''; return [data.replace(/\D/g, '') || '/', data.endsWith( 'swing' ) ? $('<i>', {class: 'swing'}) : null]; }); }).on('mouseenter', '.ac-song-table .tabs-label', function() { $(this).next().css('left', ''); }); mw.widget.acSongTable = true; }; if (window.jQuery) { handler(); } else { window.addEventListener('jquery', handler); } }) (); //</nowiki>