MediaWiki:Common.js

来自PRTS
跳转到导航 跳转到搜索

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */

//右侧目录
$().ready(function(){
    var b = $("<div id='rightToc' style='opacity: 0;'><div id='rtocbt'>目<br/>录</div></div>");
    b.append($('#toc').children('ul').clone().removeAttr("style"));
    $("#toc").after(b);
    var IsAnim=false;
    b.ready(function(){
        $("#rightToc").children("ul").wrap("<div id='rtoculw'></div>");
        $("#rtoculw").children("ul").attr('id','rtocul');
        $("#rightToc").css("marginRight",-$("#rtoculw").outerWidth());
        $('#rtocbt').on('mouseover',function(){
            if(IsAnim){
                return;
            }
            IsAnim=true;
            $("#rightToc").animate({
                marginRight:'5px'
            },"fast",function() {
                IsAnim=false;
                $('#rightToc').addClass('rtshow');
                $('#rightToc').removeClass('rthide');
            });
        });
        $($("#rtoculw")[0]).on('mouseleave',function(){
            if(IsAnim){
                return;
            }
            IsAnim=true;
            $("#rightToc").animate({
                marginRight:-$("#rtoculw").outerWidth()
            },"fast",function(){
                IsAnim=false;
                $('#rightToc').addClass('rthide');
                $('#rightToc').removeClass('rtshow');
            });
        });
        $("#rightToc").css('opacity','1');
    });
});

//黑幕
$('.heimu a').on("click", function() {
if (!$(this).closest('.heimu').is(':active, :focus')) return false;
});

/* 回到顶部 */
$(function() {
    var txt = " ",
        btn = $('<div/>', {
            'text': txt,
            'attr': {
                'title': txt,
                'class': 'backToTop'
            },
            'css': {
                'user-select': 'none'
            },
            'on': {
                'click': function() {
                    $("html, body").animate({
                        scrollTop: 0
                    }, 120);
                }
            }
        }).appendTo(document.body);
    $(window).on('scroll', function() {
        $(document).scrollTop() > 0 ? btn.fadeIn() : btn.fadeOut();
    }).scroll();
});

// 百度推送
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();

/*@cc_on document.write('\x3Cscript id="_iealwn_js" src="https://support.dmeng.net/ie-alert-warning/latest.js">\x3C/script>'); @*/