MediaWiki:Gadget-GrAnnotations.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 79: | Line 79: | ||
' <span class="gra-icon gra-icon-search" aria-hidden="true"></span>', | ' <span class="gra-icon gra-icon-search" aria-hidden="true"></span>', | ||
' <span class="gra-fab-btn-label">Search</span>', | ' <span class="gra-fab-btn-label">Search</span>', | ||
' </button>', | |||
' <button class="gra-fab-btn gra-fab-btn-dismiss" id="gra-fab-dismiss" type="button" aria-label="Dismiss">', | |||
' <span class="gra-icon gra-icon-dismiss" aria-hidden="true">\u2715</span>', | |||
' <span class="gra-fab-btn-label">Close</span>', | |||
' </button>', | ' </button>', | ||
'</div>', | '</div>', | ||
| Line 243: | Line 247: | ||
var fabW, fabH, top, left; | var fabW, fabH, top, left; | ||
if (_mobile) { | if (_mobile) { | ||
/* Docked as a fixed bar below the reader toolbar. | |||
/* | All positioning is handled by CSS via .gra-fab-mobile-docked, | ||
so it never collides with the native selection menu and never | |||
clips at screen edges or causes horizontal scroll. */ | |||
$fab.css({ position: '', top: '', left: '', visibility: '' }) | |||
.addClass('gra-fab-visible gra-fab-mobile-docked'); | |||
$fab.css({ position: ' | |||
.addClass('gra-fab-visible'); | |||
return; | return; | ||
} | } | ||
| Line 267: | Line 264: | ||
} | } | ||
function hideFab() { $fab.removeClass('gra-fab-visible'); } | function hideFab() { $fab.removeClass('gra-fab-visible gra-fab-mobile-docked'); } | ||
function hideActions() { hideFab(); } | function hideActions() { hideFab(); } | ||
| Line 647: | Line 644: | ||
else if (q) { $(document).trigger($.Event('keydown', {ctrlKey:true, key:'k', keyCode:75})); } | else if (q) { $(document).trigger($.Event('keydown', {ctrlKey:true, key:'k', keyCode:75})); } | ||
}); | }); | ||
/* ── Dismiss button: hide toolbar + clear selection (mobile) ── */ | |||
(function () { | |||
var dismissEl = document.getElementById('gra-fab-dismiss'); | |||
if (!dismissEl) return; | |||
function doDismiss(e) { | |||
e.preventDefault(); e.stopPropagation(); | |||
hideActions(); | |||
_selRange = null; _selText = ''; _selRect = null; | |||
if (window.getSelection) { | |||
var s = window.getSelection(); | |||
if (s && s.removeAllRanges) s.removeAllRanges(); | |||
} | |||
} | |||
dismissEl.addEventListener('touchend', doDismiss, { passive: false }); | |||
dismissEl.addEventListener('click', doDismiss); | |||
}()); | |||
/* Feedback composer */ | /* Feedback composer */ | ||