Remove obsolete parts from overlay
This commit is contained in:
+5
-17
@@ -4,10 +4,10 @@
|
||||
// low-level focus/Escape/bfcache patterns from modal.js rather than that
|
||||
// component's panel chrome.
|
||||
//
|
||||
// openOverlay(node, opts) MOVES `node` (an existing rail <aside>) into the
|
||||
// overlay body and restores it to its original DOM position on close, so the
|
||||
// rail keeps its state (expanded tree folders, rendered TOC). Only one overlay
|
||||
// is open at a time.
|
||||
// openOverlay(node) MOVES `node` (an existing rail <aside>) into the overlay
|
||||
// body and restores it to its original DOM position on close, so the rail keeps
|
||||
// its state (expanded tree folders, rendered TOC). Only one overlay is open at
|
||||
// a time.
|
||||
(function () {
|
||||
var overlay = null;
|
||||
var bodyEl = null;
|
||||
@@ -16,7 +16,6 @@
|
||||
var placeholder = null; // marks where to restore it
|
||||
var prevFocus = null;
|
||||
var onKeydown = null;
|
||||
var onCloseCb = null; // opts.onClose of the currently hosted node
|
||||
|
||||
function build() {
|
||||
overlay = document.createElement('div');
|
||||
@@ -51,13 +50,11 @@
|
||||
overlay.appendChild(bodyEl);
|
||||
}
|
||||
|
||||
function open(node, opts) {
|
||||
function open(node) {
|
||||
if (overlay && overlay.parentNode) close();
|
||||
if (!overlay) build();
|
||||
opts = opts || {};
|
||||
|
||||
prevFocus = document.activeElement;
|
||||
onCloseCb = typeof opts.onClose === 'function' ? opts.onClose : null;
|
||||
hosted = node;
|
||||
placeholder = document.createComment('overlay-slot');
|
||||
node.parentNode.insertBefore(placeholder, node);
|
||||
@@ -72,9 +69,6 @@
|
||||
document.addEventListener('keydown', onKeydown);
|
||||
|
||||
setTimeout(function () { closeBtn.focus(); }, 0);
|
||||
|
||||
if (typeof opts.onOpen === 'function') opts.onOpen();
|
||||
return { close: close };
|
||||
}
|
||||
|
||||
function close() {
|
||||
@@ -98,12 +92,6 @@
|
||||
if (toRestore && toRestore.focus) {
|
||||
try { toRestore.focus(); } catch (e) {}
|
||||
}
|
||||
|
||||
// Fires after the node is back in its original spot, so the callback
|
||||
// sees the final DOM.
|
||||
var cb = onCloseCb;
|
||||
onCloseCb = null;
|
||||
if (cb) cb();
|
||||
}
|
||||
|
||||
// Belt-and-suspenders bfcache guard: force the overlay closed (restoring
|
||||
|
||||
Reference in New Issue
Block a user