li:not(._sage-active-tab)",function(e){0===e.offsetWidth&&0===e.offsetHeight||a.t.push(e)})},tag:function(e){return"<"+e+">"},C:function(e){let t;(t=window.open())&&(t.document.open(),t.document.write(a.tag("html")+a.tag("head")+"Sage β― ("+(new Date).toISOString()+")"+a.tag('meta charset="utf-8"')+document.getElementsByClassName("_sage-js")[0].outerHTML+document.getElementsByClassName("_sage-css")[0].outerHTML+a.tag("/head")+a.tag("body")+''+e.parentNode.outerHTML+"
"+a.tag("/body")),t.document.close())},I:function(e,n,t){const i=e.tBodies[0],o=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),a=void 0===t.T?1:t.T;t.T=-1*a,[].slice.call(e.tBodies[0].rows).sort(function(e,t){return a*o.compare(e.cells[n].textContent,t.cells[n].textContent)}).forEach(function(e){i.appendChild(e)})},A:{P:function(e){var t="_sage-focused",n=document.querySelector("."+t);if(n&&a.v(n,t),-1!==e){n=a.t[e];a.g(n,t);const i=function(e){return e.offsetTop+(e.offsetParent?i(e.offsetParent):0)};t=i(n)-window.innerHeight/2;window.scrollTo(0,t)}a.i=e},F:function(e,t){return e?--t<0&&(t=a.t.length-1):++t>=a.t.length&&(t=0),a.A.P(t),!1}}};window.addEventListener("click",function(e){let t=e.target,n=t.nodeName.toLowerCase();if(a.m(t)){if("dfn"===n)a.o(t),t=t.parentNode;else if("var"===n)t=t.parentNode,n=t.nodeName.toLowerCase();else if("th"===n)return e.ctrlKey||a.I(t.parentNode.parentNode.parentNode,t.cellIndex,t),!1;if("li"===n&&"_sage-tabs"===t.parentNode.className)return"_sage-active-tab"!==t.className&&(a.h(t),-1!==a.i&&a.k()),!1;if("nav"===n)return"footer"===t.parentNode.nodeName.toLowerCase()?(t=t.parentNode,a.l(t)?a.v(t):a.g(t)):setTimeout(function(){0e&&(n=e),ili:not(._sage-active-tab)",function(e){0===e.offsetWidth&&0===e.offsetHeight||s.t.push(e)})},tag:function(e){return"<"+e+">"},A:function(e){let t;(t=window.open())&&(t.document.open(),t.document.write(s.tag("html")+s.tag("head")+"Sage β― ("+(new Date).toISOString()+")"+s.tag('meta charset="utf-8"')+document.getElementsByClassName("_sage-js")[0].outerHTML+document.getElementsByClassName("_sage-css")[0].outerHTML+s.tag("/head")+s.tag("body")+''+e.parentNode.outerHTML+"
"+s.tag("/body")),t.document.close())},I:function(e,n,t){const i=e.tBodies[0],o=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),s=void 0===t.k?1:t.k;t.k=-1*s,[].slice.call(e.tBodies[0].rows).sort(function(e,t){return s*o.compare(e.cells[n].textContent,t.cells[n].textContent)}).forEach(function(e){i.appendChild(e)})},R:{C:function(e){var t="_sage-focused",n=document.querySelector("."+t);if(n&&s.v(n,t),-1!==e){n=s.t[e];s.g(n,t);const i=function(e){return e.offsetTop+(e.offsetParent?i(e.offsetParent):0)};t=i(n)-window.innerHeight/2;window.scrollTo(0,t)}s.i=e},D:function(e,t){return e?--t<0&&(t=s.t.length-1):++t>=s.t.length&&(t=0),s.R.C(t),!1}}};window.addEventListener("click",function(e){let t=e.target,n=t.tagName;if(s.m(t)){if("DFN"===n)s.o(t),t=t.parentNode;else if("VAR"===n)t=t.parentNode,n=t.tagName;else if("TH"===n)return e.ctrlKey||s.I(t.parentNode.parentNode.parentNode,t.cellIndex,t),!1;if("LI"===n&&"_sage-tabs"===t.parentNode.className)return"_sage-active-tab"!==t.className&&(s.h(t),-1!==s.i&&s.T()),!1;if("NAV"===n)return"FOOTER"===t.parentNode.tagName?(t=t.parentNode,s.toggle(t)):setTimeout(function(){0e&&(n=e),i when array("\n") is dumped
@@ -187,7 +187,6 @@ if (typeof _sageInitialized === 'undefined') {
const el = _sage.visiblePluses[i];
_sage.addClass(el, focusedClass);
-
const offsetTop = function (el) {
return el.offsetTop + (el.offsetParent ? offsetTop(el.offsetParent) : 0);
};
@@ -219,18 +218,18 @@ if (typeof _sageInitialized === 'undefined') {
window.addEventListener("click", function (e) {
let target = e.target
- , nodeName = target.nodeName.toLowerCase();
+ , tagName = target.tagName;
if (!_sage.isSibling(target)) return;
// auto-select name of variable
- if (nodeName === 'dfn') {
+ if (tagName === 'DFN') {
_sage.selectText(target);
target = target.parentNode;
- } else if (nodeName === 'var') { // stupid workaround for misc elements
+ } else if (tagName === 'VAR') { // stupid workaround for misc elements
target = target.parentNode; // to not stop event from further propagating
- nodeName = target.nodeName.toLowerCase()
- } else if (nodeName === 'th') {
+ tagName = target.tagName;
+ } else if (tagName === 'TH') {
if (!e.ctrlKey) {
_sage.sortTable(target.parentNode.parentNode.parentNode, target.cellIndex, target)
}
@@ -238,7 +237,7 @@ if (typeof _sageInitialized === 'undefined') {
}
// switch tabs
- if (nodeName === 'li' && target.parentNode.className === '_sage-tabs') {
+ if (tagName === 'LI' && target.parentNode.className === '_sage-tabs') {
if (target.className !== '_sage-active-tab') {
_sage.switchTab(target);
if (_sage.currentPlus !== -1) _sage.fetchVisiblePluses();
@@ -247,15 +246,11 @@ if (typeof _sageInitialized === 'undefined') {
}
// handle clicks on the navigation caret
- if (nodeName === 'nav') {
+ if (tagName === 'NAV') {
// special case for nav in footer
- if (target.parentNode.nodeName.toLowerCase() === 'footer') {
+ if (target.parentNode.tagName === 'FOOTER') {
target = target.parentNode;
- if (_sage.hasClass(target)) {
- _sage.removeClass(target)
- } else {
- _sage.addClass(target)
- }
+ _sage.toggle(target)
} else {
// ensure doubleclick has different behaviour, see below
setTimeout(function () {
@@ -282,7 +277,7 @@ if (typeof _sageInitialized === 'undefined') {
ajax.send();
} else if (_sage.hasClass(target, '_sage-popup-trigger')) {
let _sageContainer = target.parentNode;
- if (_sageContainer.nodeName.toLowerCase() === 'footer') {
+ if (_sageContainer.tagName === 'FOOTER') {
_sageContainer = _sageContainer.previousSibling;
} else {
while (_sageContainer && !_sage.hasClass(_sageContainer, '_sage-parent')) {
@@ -291,7 +286,7 @@ if (typeof _sageInitialized === 'undefined') {
}
_sage.openInNewWindow(_sageContainer);
- } else if (nodeName === 'pre' && e.detail === 3) { // triple click pre to select it all
+ } else if (tagName === 'PRE' && e.detail === 3) { // triple click pre to select it all
_sage.selectText(target);
}
}, false);
@@ -300,7 +295,7 @@ if (typeof _sageInitialized === 'undefined') {
const target = e.target;
if (!_sage.isSibling(target)) return;
- if (target.nodeName.toLowerCase() === 'nav') {
+ if (target.tagName === 'NAV') {
target._sageTimer = 2;
_sage.toggleAll(target);
if (_sage.currentPlus !== -1) _sage.fetchVisiblePluses();
@@ -312,7 +307,7 @@ if (typeof _sageInitialized === 'undefined') {
window.onkeydown = function (e) { // direct assignment is used to have priority over ex FAYT
// do nothing if alt/ctrl key is pressed or if we're actually typing somewhere
- if (e.target !== document.body || e.altKey || e.ctrlKey) return;
+ if (["INPUT", "TEXTAREA"].includes(e.target.tagName) || e.altKey || e.ctrlKey) return;
// todo use e.key https://www.toptal.com/developers/keycode
const keyCode = e.keyCode
@@ -320,7 +315,12 @@ if (typeof _sageInitialized === 'undefined') {
let i = _sage.currentPlus;
- if (keyCode === 68) { // 'd' : toggles navigation on/off
+ if (keyCode === 9) { // TAB jumps out of navigation
+ _sage.keyCallBacks.cleanup(-1);
+
+ return;
+ // todo 's' too
+ } else if (keyCode === 68) { // 'd' : toggles navigation on/off
if (i === -1) {
_sage.fetchVisiblePluses();
return _sage.keyCallBacks.moveCursor(false, i);
@@ -331,9 +331,7 @@ if (typeof _sageInitialized === 'undefined') {
} else {
if (i === -1) return;
- if (keyCode === 9) { // TAB : moves up/down depending on shift key
- return _sage.keyCallBacks.moveCursor(shiftKey, i);
- } else if (keyCode === 38) { // ARROW UP : moves up
+ if (keyCode === 38) { // ARROW UP : moves up
return _sage.keyCallBacks.moveCursor(true, i);
} else if (keyCode === 40) { // ARROW DOWN : down
return _sage.keyCallBacks.moveCursor(false, i);
@@ -341,10 +339,10 @@ if (typeof _sageInitialized === 'undefined') {
}
- let _sageNode = _sage.visiblePluses[i];
- if (_sageNode.nodeName.toLowerCase() === 'li') { // we're on a trace tab
+ let currentNav = _sage.visiblePluses[i];
+ if (currentNav.tagName === 'LI') { // we're on a trace tab
if (keyCode === 32 || keyCode === 13) { // SPACE/ENTER
- _sage.switchTab(_sageNode);
+ _sage.switchTab(currentNav);
_sage.fetchVisiblePluses();
return _sage.keyCallBacks.moveCursor(true, i);
} else if (keyCode === 39) { // arrows
@@ -354,37 +352,48 @@ if (typeof _sageInitialized === 'undefined') {
}
}
- _sageNode = _sageNode.parentNode; // simple dump
+ // we are on a regular/footer [+]
+
+ currentNav = currentNav.parentNode; // simple dump
+
+ if (currentNav.tagName === 'FOOTER') {
+ if (keyCode === 32 || keyCode === 13) { // SPACE/ENTER : toggles
+ _sage.toggle(currentNav);
+
+ return false;
+ }
+ }
+
if (keyCode === 32 || keyCode === 13) { // SPACE/ENTER : toggles
- _sage.toggle(_sageNode);
+ _sage.toggle(currentNav);
_sage.fetchVisiblePluses();
return false;
} else if (keyCode === 39 || keyCode === 37) { // ARROW LEFT/RIGHT : respectively hides/shows and traverses
- const visible = _sage.hasClass(_sageNode);
+ const visible = _sage.hasClass(currentNav);
const hide = keyCode === 37;
if (visible) {
- _sage.toggleChildren(_sageNode, hide); // expand/collapse all children if immediate ones are showing
+ _sage.toggleChildren(currentNav, hide); // expand/collapse all children if immediate ones are showing
} else {
if (hide) { // LEFT
// traverse to parent and THEN hide
do {
- _sageNode = _sageNode.parentNode
- } while (_sageNode && _sageNode.nodeName.toLowerCase() !== 'dd');
+ currentNav = currentNav.parentNode
+ } while (currentNav && currentNav.tagName !== 'DD');
- if (_sageNode) {
- _sageNode = _sageNode.previousElementSibling;
+ if (currentNav) {
+ currentNav = currentNav.previousElementSibling;
i = -1;
- const parentPlus = _sageNode.querySelector('nav');
+ const parentPlus = currentNav.querySelector('nav');
while (parentPlus !== _sage.visiblePluses[++i]) {
}
_sage.keyCallBacks.cleanup(i)
} else { // we are at root
- _sageNode = _sage.visiblePluses[i].parentNode;
+ currentNav = _sage.visiblePluses[i].parentNode;
}
}
- _sage.toggle(_sageNode, hide);
+ _sage.toggle(currentNav, hide);
}
_sage.fetchVisiblePluses();
return false;
diff --git a/sage.phar b/sage.phar
index fa19061..9d3297f 100644
Binary files a/sage.phar and b/sage.phar differ
diff --git a/tests/all/plainDisplayTest.php b/tests/all/plainDisplayTest.php
index 2e19137..7700257 100644
--- a/tests/all/plainDisplayTest.php
+++ b/tests/all/plainDisplayTest.php
@@ -1,11 +1,6 @@
'far',
'bar' => [