MediaWiki:Gadget-ScrollUpButton.js:修订间差异

删除的内容 添加的内容
修复:图标 URL 回退显式域名,节流优化
修复:ES5 兼容,移除展开运算符
第14行:
$('html, body').stop(true, true).animate({ scrollTop: h }, 500);
}
 
var baseCss = {
display: 'none',
position: 'fixed',
right: '18px',
cursor: 'pointer',
opacity: '0.7',
width: '40px',
zIndex: 9999,
'-moz-user-select': 'none',
'-webkit-user-select': 'none',
'user-select': 'none',
transition: 'opacity 0.2s',
};
 
function makeBtn(id, onClick, extraCss) {
var css = $.extend({}, baseCss, extraCss);
return $('<img>')
.addClass('noprint')
.attr({ id: id, src: icon, draggable: 'false' })
.css({css)
display: 'none',
position: 'fixed',
right: '18px',
cursor: 'pointer',
opacity: '0.7',
width: '40px',
zIndex: 9999,
'-moz-user-select': 'none',
'-webkit-user-select': 'none',
'user-select': 'none',
transition: 'opacity 0.2s',
...extraCss
})
.on('mouseenter', function () { this.style.opacity = '1'; })
.on('mouseleave', function () { this.style.opacity = '0.7'; })
第64行 ⟶ 第66行:
 
if (isVector2022) {
try { mql.addListeneraddEventListener('change', onWidthChange); }
try {
catch (_) { mql.addEventListeneraddListener('change', onWidthChange); }
} catch (_) {
mql.addListener(onWidthChange);
}
onWidthChange(mql);
}
第74行 ⟶ 第73行:
function onScroll() {
var y = $window.scrollTop() || 0;
 
if (y > 200 && !visible) {
visible = true;
第82行 ⟶ 第80行:
$elements.fadeOut(300);
}
 
if (
(mw.config.get('wgGEHelpPanelEnabled') && $('#mw-ge-help-panel-cta-button').length) ||
$('#cat_a_lot').length || $('#proveit').length || $('.wordcount').length
$('#proveit').length ||
$('.wordcount').length
) {
setLeft(10);
第98行 ⟶ 第93行:
$window.on('scroll', function () {
if (!ticking) {
requestAnimationFrame(function () { onScroll(); ticking = false; });
onScroll();
ticking = false;
});
ticking = true;
}
});
 
onScroll();
});