From f124942f122b08aac3295b1699e6d448ba2c9d08 Mon Sep 17 00:00:00 2001 From: raveren Date: Thu, 7 Mar 2024 16:54:46 +0200 Subject: [PATCH] Expand all nodes when pressing ctrl+f. --- resources/compiled/sage.js | 2 +- resources/js/base.js | 97 +++++++++++++++++++++++-------------- sage.phar | Bin 186616 -> 186577 bytes 3 files changed, 61 insertions(+), 38 deletions(-) diff --git a/resources/compiled/sage.js b/resources/compiled/sage.js index 5c861f3..fe13d83 100644 --- a/resources/compiled/sage.js +++ b/resources/compiled/sage.js @@ -1 +1 @@ -if("undefined"==typeof _sageInitialized){const a={t:[],i:-(_sageInitialized=1),o:function(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)},u:function(e,t){Array.prototype.slice.call(document.querySelectorAll(e),0).forEach(t)},l:function(e,t){return!!e.classList&&e.classList.contains(t=void 0===t?"_sage-show":t)},g:function(e,t){e.classList.add(t=void 0===t?"_sage-show":t)},v:function(e,t){return e.classList.remove(t=void 0===t?"_sage-show":t),e},next:function(e){for(;(e=e.nextElementSibling)&&"DD"!==e.tagName;);return e},toggle:function(e,t){(t=void 0===t?a.l(e):t)?a.v(e):a.g(e);let n=a.next(e);n&&1===n.childNodes.length&&(n=n.childNodes[0].childNodes[0])&&a.l(n,"_sage-parent")&&a.toggle(n,t)},_:function(e,t){const n=a.next(e),i=n.getElementsByClassName("_sage-parent");let o=i.length;for(void 0===t&&(t=a.l(e));o--;)a.toggle(i[o],t);a.toggle(e,t)},h:function(e){var t=document.getElementsByClassName("_sage-parent");let n=t.length;for(var i=a.l(e.parentNode);n--;)a.toggle(t[n],i)},m:function(e){let t,n=e,i=0;for(a.v(e.parentNode.getElementsByClassName("_sage-active-tab")[0],"_sage-active-tab"),e.className="_sage-active-tab";n=n.previousSibling;)1===n.nodeType&&i++;t=e.parentNode.nextSibling.childNodes;for(let e=0;eli:not(._sage-active-tab)",function(e){0===e.offsetWidth&&0===e.offsetHeight||a.t.push(e)})},tag:function(e){return"<"+e+">"},A: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.k?1:t.k;t.k=-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)})},C:{D: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.C.D(t),!1}}};window.addEventListener("click",function(e){let t=e.target,n=t.tagName;if(a.p(t)){if("DFN"===n)a.o(t),t=t.parentNode;else if("VAR"===n)t=t.parentNode,n=t.tagName;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.m(t),-1!==a.i&&a.T()),!1;if("NAV"===n)return"FOOTER"===t.parentNode.tagName?(t=t.parentNode,a.toggle(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)})},C:{D:function(e){var t="_sage-focused",n=document.querySelector("."+t);if(n&&s._(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},F:function(e,t){return e?--t<0&&(t=s.t.length-1):++t>=s.t.length&&(t=0),s.C.D(t),!1}}};window.addEventListener("click",function(e){let t=e.target,n=t.tagName;if(s.p(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.m(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 - if (_sage.currentPlus !== -1) _sage.fetchVisiblePluses(); + if (_sage.currentPlus !== -1) { + _sage.fetchVisiblePluses(); + } } }, 300); } @@ -268,7 +272,9 @@ if (typeof _sageInitialized === 'undefined') { return false; } else if (_sage.hasClass(target, '_sage-parent')) { _sage.toggle(target); - if (_sage.currentPlus !== -1) _sage.fetchVisiblePluses(); + if (_sage.currentPlus !== -1) { + _sage.fetchVisiblePluses(); + } return false; } else if (_sage.hasClass(target, '_sage-ide-link')) { fetch(target.href); @@ -289,29 +295,38 @@ if (typeof _sageInitialized === 'undefined') { } }, false); - window.addEventListener("dblclick", function (e) { + window.addEventListener('dblclick', function (e) { const target = e.target; - if (!_sage.isSibling(target)) return; + if (!_sage.isSibling(target)) { + return; + } if (target.tagName === 'NAV') { target._sageTimer = 2; - _sage.toggleAll(target); - if (_sage.currentPlus !== -1) _sage.fetchVisiblePluses(); + _sage.toggleAll(_sage.hasClass(target)); + if (_sage.currentPlus !== -1) { + _sage.fetchVisiblePluses(); + } e.stopPropagation(); } }, false); // keyboard navigation 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 (["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 - , shiftKey = e.shiftKey + const keyCode = e.keyCode; let i = _sage.currentPlus; + // user pressed ctrl+f + if (keyCode === 70 && e.ctrlKey) { + _sage.toggleAll(true); + return; + } + + // do nothing if alt/ctrl key is pressed or if we're actually typing somewhere + if (['INPUT', 'TEXTAREA'].includes(e.target.tagName) || e.altKey || e.ctrlKey) { + return; + } if (keyCode === 9) { // TAB jumps out of navigation _sage.keyCallBacks.cleanup(-1); @@ -327,7 +342,9 @@ if (typeof _sageInitialized === 'undefined') { return false; } } else { - if (i === -1) return; + if (i === -1) { + return; + } if (keyCode === 38) { // ARROW UP : moves up return _sage.keyCallBacks.moveCursor(true, i); @@ -398,7 +415,7 @@ if (typeof _sageInitialized === 'undefined') { } }; - window.addEventListener("load", function () { // colorize microtime results relative to others + window.addEventListener('load', function () { // colorize microtime results relative to others const elements = Array.prototype.slice.call(document.querySelectorAll('._sage-microtime'), 0); let min = Infinity , max = -Infinity; @@ -406,8 +423,12 @@ if (typeof _sageInitialized === 'undefined') { elements.forEach(function (el) { const val = parseFloat(el.innerHTML); - if (min > val) min = val; - if (max < val) max = val; + if (min > val) { + min = val; + } + if (max < val) { + max = val; + } }); elements.forEach(function (el) { @@ -421,7 +442,9 @@ if (typeof _sageInitialized === 'undefined') { // debug purposes only, removed in minified source function clg(i) { - if (!window.console) return; + if (!window.console) { + return; + } const l = arguments.length; let o = 0; while (o < l) console.log(arguments[o++]) diff --git a/sage.phar b/sage.phar index 21843c419493af0d4252aa8e8166da4a2a5186eb..706cc0d01e255ff7d682fea8f5416fb696b45ce9 100644 GIT binary patch delta 1500 zcmZ`(O-x)>6lP8lCT%JNYfW3V%n&E z-#Op8@5$<(pI7%>)~kCzFDrZhuK#&y+YSUHt7k4&RR2{|yp+}w?b?@BmG=kp6N7H? z>T#$M4Zpf7J|0Slsvlf#apfo1zI9EF3|XsaSr8)p%}{#Bp{qn7kitf(tI zX2m6+Vf!RT=AdpDeyyFK1I6WH;)`pbxDiN;#r;eauEA-%?7t3YtMD?RE8Zj@H@&1D zo45{r=sS1=E>}Cgh9pgl+0L(Tz%)8r=HUXG^?5ji=HWcFp*gSstA`{5*`YrW@@N_* zS)7Z?V>FJWA1%Onj5BWnk>gNJYUw-~2$4vAJ#UwB&Xv!na4krX=r=dvt^G`$K#@q+ zIHh=d`v$z4rdfmuatkQJUAhII)G&1%LyAS2YT&p<(;^&2_Xms6hLgyMdyBBI!tp&= z1Yf5VivL?ElBRqzZPg-~qFkk@>YzgWo=_C2FwwOHjg=0Ha4~pB%q+nhShKJMFQIvA z8S2oGWt&K589dK1HL2Jcq?GJu%h1}vNj8&6<0f(S9Xi#M8l(1R88{h3R%{N+&V4?v zj`Fnm8lA$;NGhHniBgl%TJZ?$HFA_Qty5|Afy6i^xg4&!$uV4>wlWFgwK{_wxefcz zSx)DH5Z)Rc$Wpe-)E>1@@r3*aArZXmQF|2>3`amDBU@y{RwmqHqiv7R&I@9mjC>FjPm+rioe~r*BmYRKm>VU_qJxXz z3LJA8;=L6h{qn8U*BkLDK5~252AQ_Sl{3N-#ns{;WdN6BdV5DD;`H_miYvPIcm?h@ z9Qk%L|6}M+f8nc{li?SCpLzI4=E3UY#HFs;-Ru6TH;4;@tL&Em delta 1555 zcmaJ>Uuau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