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 () { |
||
isSelecting = true; |
|||
}, true); |
|||
| ⚫ | |||
isSelecting = false; |
|||
scheduleUpdateDelayed(); |
|||
}, true); |
}, true); |
||
document.addEventListener(' |
document.addEventListener('mousemove', onSelectMove, true); |
||
document.addEventListener(' |
document.addEventListener('touchstart', function () { |
||
isSelecting = 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); |
||
| ⚫ | |||
| ⚫ | |||
window.addEventListener('focus', startPolling); |
window.addEventListener('focus', startPolling); |
||
window.addEventListener('blur', stopPolling); |
window.addEventListener('blur', stopPolling); |
||