“MediaWiki:Common.js”的版本间的差异
跳到导航
跳到搜索
第47行: | 第47行: | ||
}); | }); | ||
}); | }); | ||
}); | |||
//悬停的卡片 | |||
function qxmgTip(){ | |||
$(document).on('mouseover','.j-qxmgtip',function(){ | |||
$tip = $(this).find('.mgtip-tip'); | |||
$tip.show(); | |||
//修复图片不加载 | |||
$(window).scrollTop($(window).scrollTop()-1).scrollTop($(window).scrollTop()+1); | |||
$(this).on('mousemove',function(e){ | |||
var _oleft = $(this).offset().left, | |||
_otop = $(this).offset().top, | |||
_wt = $(window).scrollTop() + $(window).outerHeight(), | |||
_wl = $(window).scrollLeft() + $(window).outerWidth(), | |||
_left = e.pageX - _oleft + 15, | |||
_top = e.pageY - _otop + 15, | |||
_targetWidth = $tip.outerWidth(), | |||
_targetHeight = $tip.outerHeight(); | |||
if( _left + _oleft + _targetWidth > _wl ){ | |||
_left -= _targetWidth + 30; | |||
} | |||
if( _top + _otop + _targetHeight > _wt ){ | |||
_top -= _targetHeight + 30; | |||
} | |||
$tip.css({ | |||
left: _left, | |||
top: _top | |||
}); | |||
}); | |||
$(this).on('mouseout',function(){ | |||
$tip.hide(); | |||
$(this).off('mousemove').off('mouseout'); | |||
}); | |||
}); | |||
} | |||
$(document).ready(function() { | |||
setInterval('AutoScroll("#scrollDiv")',5000); | |||
//图片载入效果 | |||
$('img').on('appear', function(e){ | |||
var that = $(this); | |||
that.css('opacity',0); | |||
setTimeout(function(){ | |||
that.css('transition','opacity 1s').css('opacity',1); | |||
}, 1); | |||
}); | |||
//End of 图片载入效果 | |||
//悬停的卡片 | |||
qxmgTip(); | |||
}); | }); |
2021年11月26日 (五) 19:26的版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ $(self.document).ready(function () { function Event_Break() { return false; } $( 'button, .No_Select' ).attr('unSelectable', 'on').css({ '-moz-user-select': '-moz-none', '-khtml-user-select': 'none', '-webkit-user-select': 'none', '-o-user-select': 'none', '-ms-user-select': 'none', 'user-select': 'none', '-webkit-touch-callout': 'none' }).bind('selectStart', Event_Break).bind('contextmenu', Event_Break); }); // 官方文档:添加MediaWiki:Common.js: function waitForMathJax($content) { if (typeof MathJax === 'undefined') { setTimeout(function () { waitForMathJax($content); }, 1000); } else { MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute(); } } mw.hook('wikipage.content').add(waitForMathJax); $(document).ready(function(){ //首先将#back-to-top隐藏 $("#back-to-top").hide(); //当滚动条的位置处于距顶部600像素以下时,跳转链接出现,否则消失 $(function () { $(window).scroll(function(){ if ($(window).scrollTop()>600){ $("#back-to-top").fadeIn(500); }else{ $("#back-to-top").fadeOut(500); } }); //当点击跳转链接后,回到页面顶部位置 $("#back-to-top").click(function(){ $('body,html').animate({scrollTop:0},500); return false; }); }); }); //悬停的卡片 function qxmgTip(){ $(document).on('mouseover','.j-qxmgtip',function(){ $tip = $(this).find('.mgtip-tip'); $tip.show(); //修复图片不加载 $(window).scrollTop($(window).scrollTop()-1).scrollTop($(window).scrollTop()+1); $(this).on('mousemove',function(e){ var _oleft = $(this).offset().left, _otop = $(this).offset().top, _wt = $(window).scrollTop() + $(window).outerHeight(), _wl = $(window).scrollLeft() + $(window).outerWidth(), _left = e.pageX - _oleft + 15, _top = e.pageY - _otop + 15, _targetWidth = $tip.outerWidth(), _targetHeight = $tip.outerHeight(); if( _left + _oleft + _targetWidth > _wl ){ _left -= _targetWidth + 30; } if( _top + _otop + _targetHeight > _wt ){ _top -= _targetHeight + 30; } $tip.css({ left: _left, top: _top }); }); $(this).on('mouseout',function(){ $tip.hide(); $(this).off('mousemove').off('mouseout'); }); }); } $(document).ready(function() { setInterval('AutoScroll("#scrollDiv")',5000); //图片载入效果 $('img').on('appear', function(e){ var that = $(this); that.css('opacity',0); setTimeout(function(){ that.css('transition','opacity 1s').css('opacity',1); }, 1); }); //End of 图片载入效果 //悬停的卡片 qxmgTip(); });