打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

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

MediaWiki界面页面
删除的内容 添加的内容
Maintenance script留言 | 贡献
记录最近选区并延迟显示
Maintenance script留言 | 贡献
为未加载 CSS 提供可见性兜底
 
(未显示同一用户的1个中间版本)
第20行: 第20行:
.appendTo('body');
.appendTo('body');
}
}

function ensureVisibleStyles() {
var el = $counter[0];
if (!el) {
return;
}
var computed = window.getComputedStyle(el);
if (computed.position !== 'static') {
return;
}
$counter.css({
position: 'fixed',
bottom: '24px',
right: '24px',
padding: '6px 10px',
fontSize: '12px',
borderRadius: '4px',
background: 'var(--color-surface-0, rgba(255, 255, 255, 0.85))',
border: '1px solid var(--border-color-base, #aaa)',
color: 'var(--color-base, #333)',
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.2)',
backdropFilter: 'blur(4px)',
zIndex: 2147483647,
pointerEvents: 'none'
});
}

ensureVisibleStyles();


var rafId = null;
var rafId = null;
第25行: 第53行:
var lastText = '';
var lastText = '';
var lastTime = 0;
var lastTime = 0;
var isSelecting = false;


function getSelectionText() {
function getSelectionText() {
第90行: 第119行:
window.clearInterval(pollTimer);
window.clearInterval(pollTimer);
pollTimer = null;
pollTimer = null;
}

function onSelectMove() {
if (!isSelecting) {
return;
}
scheduleUpdate();
}
}


第101行: 第137行:
});
});
document.addEventListener('mousedown', function () {
document.addEventListener('mousedown', function () {
$counter.hide();
isSelecting = true;
}, true);
document.addEventListener('mouseup', function () {
isSelecting = false;
scheduleUpdateDelayed();
}, true);
}, true);
document.addEventListener('mouseup', scheduleUpdateDelayed, true);
document.addEventListener('mousemove', onSelectMove, true);
document.addEventListener('mouseup', scheduleUpdateDelayed);
document.addEventListener('touchstart', function () {
isSelecting = true;
}, { passive: true, capture: true });
document.addEventListener('touchmove', onSelectMove, { passive: true, capture: true });
document.addEventListener('touchend', function () {
isSelecting = false;
scheduleUpdateDelayed();
}, { passive: true, capture: true });
document.addEventListener('keyup', scheduleUpdate);
document.addEventListener('keyup', scheduleUpdate);
document.addEventListener('touchend', scheduleUpdateDelayed, { passive: true, capture: true });
document.addEventListener('pointerup', scheduleUpdateDelayed, true);
window.addEventListener('focus', startPolling);
window.addEventListener('focus', startPolling);
window.addEventListener('blur', stopPolling);
window.addEventListener('blur', stopPolling);