“MediaWiki:Common.js”的版本间的差异
跳到导航
跳到搜索
| 第26行: | 第26行: | ||
mw.hook('wikipage.content').add(waitForMathJax); | mw.hook('wikipage.content').add(waitForMathJax); | ||
$(function(){ | |||
//当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失 | |||
$(function () { | |||
$(window).scroll(function(){ | |||
if ($(window).scrollTop()>100){ | |||
$("#back-to-top").fadeIn(1500); | |||
} | |||
else | |||
{ | |||
$("#back-to-top").fadeOut(1500); | |||
} | |||
}); | |||
//当点击跳转链接后,回到页面顶部位置 | |||
$("#back-to-top").click(function(){ | |||
if ($('html').scrollTop()) { | |||
$('html').animate({ scrollTop: 0 }, 100);//动画效果 | |||
return false; | |||
} | |||
$('body').animate({ scrollTop: 0 }, 100); | |||
return false; | |||
}); | |||
}); | |||
}); | |||
2021年11月24日 (三) 21:18的版本
/* 这里的任何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);
$(function(){
//当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失
$(function () {
$(window).scroll(function(){
if ($(window).scrollTop()>100){
$("#back-to-top").fadeIn(1500);
}
else
{
$("#back-to-top").fadeOut(1500);
}
});
//当点击跳转链接后,回到页面顶部位置
$("#back-to-top").click(function(){
if ($('html').scrollTop()) {
$('html').animate({ scrollTop: 0 }, 100);//动画效果
return false;
}
$('body').animate({ scrollTop: 0 }, 100);
return false;
});
});
});