Gadget:oouiup.js:修订间差异

添加42字节 、​ 2023年7月30日 (星期日)
// Edit via Wikiplus
(// Edit via Wikiplus)
 
(// Edit via Wikiplus)
 
(未显示同一用户的6个中间版本)
第1行: 第1行:
$(function() {
$( function () {
    var body = document.body,
const body = document.body,
        html = document.documentElement;
html = document.documentElement;
    var innerWidth = window.innerWidth;
const innerWidth = window.innerWidth;
    var scrollbarWidth;
var scrollbarWidth;
    switch ("scroll") {
if($(".backToTop").length > 0) { // 已经加载了仿论坛版本
        case getComputedStyle(body).overflowY:
return;
            scrollbarWidth = innerWidth - body.clientWidth;
}
            break;
switch ( 'scroll' ) {
        case getComputedStyle(html).overflowY:
case getComputedStyle( body ).overflowY:
            scrollbarWidth = innerWidth - html.clientWidth;
scrollbarWidth = innerWidth - body.clientWidth;
            break;
break;
        default:
case getComputedStyle( html ).overflowY:
            var backup = body.style.overflowY;
scrollbarWidth = innerWidth - html.clientWidth;
            body.style.overflowY = "scroll";
break;
            scrollbarWidth = innerWidth - body.clientWidth;
default:
            body.style.overflowY = backup;
const backup = body.style.overflowY;
    }
body.style.overflowY = 'scroll';
var btnObj = new OO.ui.ButtonWidget({
scrollbarWidth = innerWidth - body.clientWidth;
  icon: 'collapse',
body.style.overflowY = backup;
  label: "ABC",
}
  title: "TIT",
const btnObj = new OO.ui.ButtonWidget( {
  invisibleLabel: true,
icon: 'collapse',
  classes: ['backToTop']
label: '返回顶部',
})
title: '返回顶部',
var btn=btnObj.$element;
invisibleLabel: true,
btn.appendTo('body')
classes: [ 'backToTop' ]
    if (scrollbarWidth === 0) {
} );
        btn.css("right", "20px"); // 修复新版 Chrome 的自动隐藏式滚动条导致的按钮被覆盖 chrome://flags/#overlay-scrollbars
btnObj.on( 'click', function () {
    }
$( 'html, body' ).animate( {
    $(window).on("scroll", function() {
scrollTop: 0
        $(document).scrollTop() > 0 ? btn.fadeIn() : btn.fadeOut();
}, 120 );
    }).scroll();
}
});
);
const $btn = btnObj.$element;
$btn.appendTo( 'body' );
if ( scrollbarWidth === 0 ) {
$btn.css( 'right', '20px' );
}
window.onscroll = function () {
if ( document.scrollingElement.scrollTop > 0 ) {
$btn.fadeIn();
} else {
$btn.fadeOut();
}
};
window.onscroll();
} );
维护员、​界面管理员、​巡查员、​监督员、​小部件编辑者
3,469

个编辑