打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
弃权者留言 | 贡献
无编辑摘要
弃权者留言 | 贡献
无编辑摘要
 
(未显示同一用户的3个中间版本)
第40行: 第40行:
                 var $labelWrapper = $('<div class="TabLabel"></div>');
                 var $labelWrapper = $('<div class="TabLabel"></div>');
                 var $contentWrapper = $('<div class="TabContent"></div>');
                 var $contentWrapper = $('<div class="TabContent"></div>');
                 $tabItems.each(function(i) {
                 $tabItems.each(function() {
                     var $item = $(this);
                     var $item = $(this);
                     var $label = $item.find('> .TabLabelText');
                     var $label = $item.find('> .TabLabelText');
                     var $contentBox = $item.find('> .TabContentText');
                     var $contentBox = $item.find('> .TabContentText');
                    if (i === 0) { $label.addClass('selected'); $contentBox.addClass('selected'); }
                     $label.on('click', function() {
                     $label.on('click', function() {
                        var isSelected = $(this).hasClass('selected');
                         $labelWrapper.find('.TabLabelText').removeClass('selected');
                         $labelWrapper.find('.TabLabelText').removeClass('selected');
                         $contentWrapper.find('.TabContentText').removeClass('selected');
                         $contentWrapper.find('.TabContentText').removeClass('selected');
                         $(this).addClass('selected');
                         if (!isSelected) {
                        $contentBox.addClass('selected');
                            $(this).addClass('selected');
                            $contentBox.addClass('selected');
                        }
                     });
                     });
                     $labelWrapper.append($label);
                     $labelWrapper.append($label);
第56行: 第58行:
                 $tabsContainer.empty().append($labelWrapper).append($contentWrapper).addClass('tabs-initialized');
                 $tabsContainer.empty().append($labelWrapper).append($contentWrapper).addClass('tabs-initialized');
             });
             });
 
           
             $content.find('.nav-pill-btn').on('click', function() {
             $content.find('.nav-pill-btn').on('click', function() {
                var match = $(this).attr('class').match(/mw-customtoggle-game(\d+)/);
    var match = $(this).attr('class').match(/mw-customtoggle-game(\d+)/);
                if (!match) return;
    if (!match) return;
                var $myContent = $('#mw-customcollapsible-game' + match[1]);
    var clickedNum = match[1];
                if ($myContent.hasClass('mw-collapsed')) {
    var $btn = $(this);
                    $('.nav-pill-content:not(.mw-collapsed)').each(function() {
    setTimeout(function() {
                        var otherNum = this.id.replace('mw-customcollapsible-game', '');
        var $myContent = $('#mw-customcollapsible-game' + clickedNum);
                        $('.mw-customtoggle-game' + otherNum).first().trigger('click');
        if (!$myContent.hasClass('mw-collapsed')) {
                    });
            $('.nav-pill-content:not(.mw-collapsed)').each(function() {
                }
                if (this.id !== 'mw-customcollapsible-game' + clickedNum) {
            });
                    var otherNum = this.id.replace('mw-customcollapsible-game', '');
                    $('.mw-customtoggle-game' + otherNum).first().trigger('click');
                }
            });
        }
    }, 0);
    setTimeout(function() {
        $btn[0].scrollIntoView({ behavior: 'smooth', block: 'nearest' });
    }, 300);
});
         });
         });
     });
     });
});
});

2026年5月10日 (日) 10:56的最新版本

$(function() {
    function getTooltip() {
        var $tip = $('#custom-notetip-popup');
        if (!$tip.length) {
            $tip = $('<div id="custom-notetip-popup"></div>').appendTo('body');
        }
        return $tip;
    }

    mw.loader.using('jquery.makeCollapsible').then(function() {
        mw.hook('wikipage.content').add(function($content) {
            $content.find('.mw-collapsible').makeCollapsible();

            $content.on('mouseenter', '.mw-custom-notetip', function() {
                var text = $(this).attr('data-notetip');
                if (!text) return;
                var $tooltip = getTooltip();
                $tooltip.text(text).show();
                var rect = this.getBoundingClientRect();
                var tipHeight = $tooltip.outerHeight();
                var tipWidth = $tooltip.outerWidth();
                var scrollY = window.scrollY;
                var scrollX = window.scrollX;
                var top = rect.top - tipHeight < 20
                    ? scrollY + rect.bottom + 10
                    : scrollY + rect.top - tipHeight - 10;
                var left = scrollX + rect.left + (rect.width / 2) - (tipWidth / 2);
                var winWidth = $(window).width();
                if (left < 10) left = 10;
                if (left + tipWidth > winWidth - 10) left = winWidth - tipWidth - 10;
                $tooltip.css({ top: top + 'px', left: left + 'px' });
            }).on('mouseleave', '.mw-custom-notetip', function() {
                getTooltip().hide();
            });

            $content.find('.Tabs:not(.tabs-initialized)').each(function() {
                var $tabsContainer = $(this);
                var $tabItems = $tabsContainer.find('> .Tab');
                if (!$tabItems.length) return;
                var $labelWrapper = $('<div class="TabLabel"></div>');
                var $contentWrapper = $('<div class="TabContent"></div>');
                $tabItems.each(function() {
                    var $item = $(this);
                    var $label = $item.find('> .TabLabelText');
                    var $contentBox = $item.find('> .TabContentText');
                    $label.on('click', function() {
                        var isSelected = $(this).hasClass('selected');
                        $labelWrapper.find('.TabLabelText').removeClass('selected');
                        $contentWrapper.find('.TabContentText').removeClass('selected');
                        if (!isSelected) {
                            $(this).addClass('selected');
                            $contentBox.addClass('selected');
                        }
                    });
                    $labelWrapper.append($label);
                    $contentWrapper.append($contentBox);
                });
                $tabsContainer.empty().append($labelWrapper).append($contentWrapper).addClass('tabs-initialized');
            });
            
            $content.find('.nav-pill-btn').on('click', function() {
    			var match = $(this).attr('class').match(/mw-customtoggle-game(\d+)/);
			    if (!match) return;
			    var clickedNum = match[1];
			    var $btn = $(this);
			    setTimeout(function() {
			        var $myContent = $('#mw-customcollapsible-game' + clickedNum);
			        if (!$myContent.hasClass('mw-collapsed')) {
			            $('.nav-pill-content:not(.mw-collapsed)').each(function() {
			                if (this.id !== 'mw-customcollapsible-game' + clickedNum) {
			                    var otherNum = this.id.replace('mw-customcollapsible-game', '');
			                    $('.mw-customtoggle-game' + otherNum).first().trigger('click');
			                }
			            });
			        }
			    }, 0);
			    setTimeout(function() {
			        $btn[0].scrollIntoView({ behavior: 'smooth', block: 'nearest' });
			    }, 300);
			});
        });
    });
});