MediaWiki:Gadget-GrAnnotations.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 306: | Line 306: | ||
// ════════════════════════════════════════════════════════════════════ | // ════════════════════════════════════════════════════════════════════ | ||
function showFab(rect) { | |||
if (!rect) return; | |||
var fabW, fabH, top, left; | |||
if (_mobile) { | |||
fabW = 180; fabH = 46; | |||
top = rect.top + window.scrollY - fabH - 14; | |||
top = clamp(top, 8, window.innerHeight - fabH - 8); | left = rect.left + rect.width / 2 - fabW / 2; | ||
left = clamp(left, 8, window.innerWidth | top = clamp(top, window.scrollY + 8, window.scrollY + window.innerHeight - fabH - 8); | ||
$fab.css({top: top+'px', left: left+'px'}).addClass('gra-fab-visible'); | left = clamp(left, 8, window.innerWidth - fabW - 8); | ||
$fab.css({ position: 'absolute', top: top + 'px', left: left + 'px' }) | |||
.addClass('gra-fab-visible'); | |||
return; | |||
} | } | ||
fabW = 46; fabH = 126; | |||
top = rect.top + (rect.height / 2) - (fabH / 2); | |||
left = rect.right + 10; | |||
if (left + fabW > window.innerWidth - 8) left = rect.left - fabW - 10; | |||
top = clamp(top, 8, window.innerHeight - fabH - 8); | |||
left = clamp(left, 8, window.innerWidth - fabW - 8); | |||
$fab.css({ top: top + 'px', left: left + 'px' }).addClass('gra-fab-visible'); | |||
} | |||
// ════════════════════════════════════════════════════════════════════ | // ════════════════════════════════════════════════════════════════════ | ||
// MOBILE | // MOBILE TOOLBAR | ||
// ════════════════════════════════════════════════════════════════════ | // ════════════════════════════════════════════════════════════════════ | ||
function showMobileBar() { showFab(_selRect); } | |||
function hideMobileBar() { } | |||
function hideActions() { hideFab(); } | |||
// ════════════════════════════════════════════════════════════════════ | // ════════════════════════════════════════════════════════════════════ | ||
// WRAP SELECTION — null-safe version | // WRAP SELECTION — null-safe version | ||
| Line 640: | Line 647: | ||
function wireEvents() { | function wireEvents() { | ||
document.addEventListener('contextmenu', function(e) { | |||
var tag = e.target.tagName; | |||
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return; | |||
var c = document.querySelector(CONTENT_SEL); | |||
if (c && c.contains(e.target)) e.preventDefault(); | |||
}, { passive: false }); | |||
/* ── Desktop mouseup ── */ | /* ── Desktop mouseup ── */ | ||