From 38f8db2c532c553515554f23b695c430cba5e7ef Mon Sep 17 00:00:00 2001 From: Taufik Nurrohman Date: Sun, 23 Feb 2020 00:29:02 +0700 Subject: [PATCH] First Stable AJAX System --- README.md | 3 ++- panel/LICENSE | 4 +-- panel/engine/f/h.php | 4 +-- panel/engine/r/asset.php | 35 +++++++++++++------------- panel/engine/r/state/files/comment.php | 6 ++--- panel/engine/r/state/files/user.php | 2 +- panel/engine/r/state/files/x.php | 17 +++++++------ panel/engine/r/state/page.page.php | 4 +-- panel/engine/r/state/pages.php | 6 ++--- panel/lot/asset/js/panel.js | 8 +++--- panel/lot/asset/js/panel.min.js | 2 +- panel/lot/asset/js/panel/alert.js | 6 ++--- panel/lot/asset/js/panel/alert.min.js | 2 +- panel/lot/asset/js/panel/fetch.js | 25 +++++++++++++++++- panel/lot/asset/js/panel/fetch.min.js | 2 +- panel/lot/asset/js/panel/menu.js | 6 ++--- panel/lot/asset/js/panel/menu.min.js | 2 +- panel/lot/asset/js/panel/tab.js | 6 ++--- panel/lot/asset/js/panel/tab.min.js | 2 +- 19 files changed, 84 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 96279494..c775f4e2 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ Release Notes ### 2.2.0 - - **TODO:** AJAX system that allows other JavaScript extensions to listen to the AJAX loading and loaded events. + - Added generic JavaScript hook system for external extensions that can be used to enhance the core control panel features. + - Added AJAX system that allows other JavaScript extensions to listen to the AJAX loading and loaded events. - Fixed bug where users could not save the file content properly due to the automatic string evaluation by the `e` function. ### 2.1.6 diff --git a/panel/LICENSE b/panel/LICENSE index 1e50e89d..1bde9900 100644 --- a/panel/LICENSE +++ b/panel/LICENSE @@ -2,10 +2,10 @@ Use it for free, pay if you get paid. If you make a commercial product with this You have the right to determine the price of your project without any interference from me. You may be able to discuss this additional cost with your clients, honestly, without the need to keep anything confidential. I want everything to be transparent so that no one feels aggrieved. -I started this project as a way to get people to leave social media which tends to shape the habit of spamming. I miss the existence of bloggers in the past who like to display photos, poems and short stories, with various effects of animated cursors and snow falling on their blogs that really makes me dizzy. They might all have gone extinct. It was a beautiful past. But lately social media has dominated society because of the ease and speed provided, for free. +I started this project as a way to get people to leave social media which tends to shape the habit of spamming. I miss the existence of bloggers in the past who like to display photos, poems and short stories, with various effects of animated cursors and snow falling on their blogs that really makes me dizzy. They might all have gone extinct. It was a beautiful past. Note: If you are from Indonesia and are having problems with the current rupiah exchange rate against the dollar, you are allowed to consider 15 USD as 150,000 IDR. -Thank you. +Thank you 💕️ diff --git a/panel/engine/f/h.php b/panel/engine/f/h.php index 225d2987..f0140201 100644 --- a/panel/engine/f/h.php +++ b/panel/engine/f/h.php @@ -38,7 +38,7 @@ function description($in, $or = null) { } $out = [ 0 => 'p', - 1 => \w('' . \i(...("" !== $description ? (array) $description : (array) $or)) . '', ['a', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']), + 1 => \w('' . \i(...\array_values("" !== $description ? (array) $description : (array) $or)) . '', ['a', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']), 2 => [] ]; unset($in['tags']); @@ -148,7 +148,7 @@ function title($in, $i = -1, $or = null) { ]; $icon = \_\lot\x\panel\h\icon($in['icon'] ?? [null, null]); if (null !== $title && false !== $title) { - $title = \w('' . \i(...((array) $title)) . '', ['a', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']); + $title = \w('' . \i(...\array_values((array) $title)) . '', ['a', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']); } $out[1] = $icon[0] . $title . $icon[1]; unset($in['tags']); diff --git a/panel/engine/r/asset.php b/panel/engine/r/asset.php index a01a33a6..47ce421b 100644 --- a/panel/engine/r/asset.php +++ b/panel/engine/r/asset.php @@ -3,30 +3,29 @@ Hook::set('get', function() use($_) { Asset::let(); // Again: remove all asset(s) $f = __DIR__ . DS . '..' . DS . '..' . DS . 'lot' . DS . 'asset' . DS; - $dot = defined('DEBUG') && DEBUG ? '.' : '.min.'; + $z = defined('DEBUG') && DEBUG ? '.' : '.min.'; if (null !== State::get('x.scss')) { Asset::set($f . 'scss' . DS . 'panel.scss', 20); } else { - Asset::set($f . 'css' . DS . 'panel' . $dot . 'css', 20); + Asset::set($f . 'css' . DS . 'panel' . $z . 'css', 20); } - Asset::set($f . 'js' . DS . 'panel' . $dot . 'js', 20); - Asset::set($f . 'js' . DS . 'panel' . DS . 'alert' . $dot . 'js', 20.1); - // TODO: - // Asset::set($f . 'js' . DS . 'panel' . DS . 'fetch' . $dot . 'js', 20.1); - Asset::set($f . 'js' . DS . 'panel' . DS . 'menu' . $dot . 'js', 20.1); - Asset::set($f . 'js' . DS . 'panel' . DS . 'tab' . $dot . 'js', 20.1); - Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'query' . $dot . 'js', 20.2); - Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'source' . $dot . 'js', 20.2); - extract($GLOBALS); - $js = $_; - if (isset($js['f'])) { - $js['f'] = To::URL($js['f']); + Asset::set($f . 'js' . DS . 'panel' . $z . 'js', 20); + Asset::set($f . 'js' . DS . 'panel' . DS . 'alert' . $z . 'js', 20.1); + Asset::set($f . 'js' . DS . 'panel' . DS . 'fetch' . $z . 'js', 20.1); + Asset::set($f . 'js' . DS . 'panel' . DS . 'menu' . $z . 'js', 20.1); + Asset::set($f . 'js' . DS . 'panel' . DS . 'tab' . $z . 'js', 20.1); + Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'query' . $z . 'js', 20.2); + Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'source' . $z . 'js', 20.2); + extract($GLOBALS, EXTR_SKIP); + $data = $_; + if (isset($data['f'])) { + $data['f'] = To::URL($data['f']); } - if (isset($js['ff'])) { - $js['ff'] = To::URL($js['ff']); + if (isset($data['ff'])) { + $data['ff'] = To::URL($data['ff']); } // Remove sensitive data - unset($js['lot'], $js['user']); - Asset::script('window._=Object.assign(window._||{},' . json_encode($js) . ');', 0); + unset($data['lot'], $data['user']); + Asset::script('window._=Object.assign(window._||{},' . json_encode($data) . ');', 0); require __DIR__ . DS . 'layout.php'; }, 20); diff --git a/panel/engine/r/state/files/comment.php b/panel/engine/r/state/files/comment.php index 8cf47b42..923027f1 100644 --- a/panel/engine/r/state/files/comment.php +++ b/panel/engine/r/state/files/comment.php @@ -37,13 +37,13 @@ $create = is_dir($folder = Path::F($k)) && q(g($folder, 'archive,draft,page')) > 0; $pages[$k] = [ 'path' => $k, - 'title' => function($path) use($page) { + 'title' => function() use($page) { return S . _\lot\x\panel\h\w($page->author) . S; }, - 'description' => function($path) use($page) { + 'description' => function() use($page) { return S . _\lot\x\panel\h\w($page->content) . S; }, - 'image' => function($path) use($page) { + 'image' => function() use($page) { return $page->avatar(72); }, 'author' => $page['author'], diff --git a/panel/engine/r/state/files/user.php b/panel/engine/r/state/files/user.php index c987636e..1c209111 100644 --- a/panel/engine/r/state/files/user.php +++ b/panel/engine/r/state/files/user.php @@ -14,7 +14,7 @@ $v['link'] = 'draft' !== $page->x ? $page->url : null; $v['title'] = S . $page . S; $v['description'] = S . $page->user . S; - $v['image'] = function($path) use($page) { + $v['image'] = function() use($page) { // Load avatar asynchronously for best performance return $page->avatar(72); }; diff --git a/panel/engine/r/state/files/x.php b/panel/engine/r/state/files/x.php index ee7dd14d..d2373156 100644 --- a/panel/engine/r/state/files/x.php +++ b/panel/engine/r/state/files/x.php @@ -21,7 +21,7 @@ $index = $index = $_['f'] . DS . 'index.php'; $lot['desk']['lot']['form']['lot'][1]['lot']['tabs']['lot']['files']['lot']['files']['lot'][$index]['tasks']['l']['active'] = false; unset($lot['desk']['lot']['form']['lot'][1]['lot']['tabs']['lot']['files']['lot']['files']['lot'][$index]['tasks']['l']['url']); - + } if (2 === $i) { $GLOBALS['_']['lot']['bar']['lot'][0]['lot']['folder']['hidden'] = true; @@ -112,13 +112,16 @@ $page = new Page($k); $pages[$k] = [ 'path' => $k, - 'title' => _\lot\x\panel\h\w($page->title), - 'description' => _\lot\x\panel\h\w($page->description), + 'title' => function() use($page) { + return S . _\lot\x\panel\h\w($page->title) . S; + }, + 'description' => function() use($page) { + return S . _\lot\x\panel\h\w($page->description) . S; + }, 'type' => 'Page', 'url' => $before . 'g' . $after . '/1' . $url->query('&', ['tab' => ['info']]), - 'image' => function($path) { - // Load image asynchronously for the best performance - return (new Page($path))->image(72, 72, 50); + 'image' => function() use($page) { + return $page->image(72, 72, 50); }, 'time' => $page->time . "", 'tasks' => [ @@ -157,4 +160,4 @@ $lot['desk']['lot']['form']['lot'][0]['lot']['tasks']['lot']['blob']['icon'] = 'M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z'; $lot['desk']['lot']['form']['lot'][0]['lot']['tasks']['lot']['blob']['url'] = $url . $_['/'] . '::s::' . $_['path'] . $url->query('&', ['layout' => 'blob.x', 'tab' => false]) . $url->hash; -return $lot; \ No newline at end of file +return $lot; diff --git a/panel/engine/r/state/page.page.php b/panel/engine/r/state/page.page.php index c910b637..91961e60 100644 --- a/panel/engine/r/state/page.page.php +++ b/panel/engine/r/state/page.page.php @@ -52,8 +52,8 @@ return $_; } // Delete `kind.data` file if `data[kind]` field is empty - if (empty($lot['data']['kind'])) { - unlink(Path::F($_['f']) . DS . 'kind.data'); + if (empty($lot['data']['kind']) && $f = Path::F($_['f']) . DS . 'kind.data') { + unlink($f); return $_; } if (!is_dir($d = LOT . DS . 'tag')) { diff --git a/panel/engine/r/state/pages.php b/panel/engine/r/state/pages.php index b3e15459..81932a58 100644 --- a/panel/engine/r/state/pages.php +++ b/panel/engine/r/state/pages.php @@ -25,15 +25,15 @@ $create = $add && q(g($folder, 'archive,draft,page')) > 0; $pages[$k] = [ 'path' => $k, - 'title' => function($path) use($page) { + 'title' => function() use($page) { // Load title asynchronously for best performance return S . _\lot\x\panel\h\w($page->title) . S; }, - 'description' => function($path) use($page) { + 'description' => function() use($page) { // Load description asynchronously for best performance return S . _\lot\x\panel\h\w($page->description) . S; }, - 'image' => function($path) use($page) { + 'image' => function() use($page) { // Load image asynchronously for best performance return $page->image(72, 72, 50); }, diff --git a/panel/lot/asset/js/panel.js b/panel/lot/asset/js/panel.js index 99e84607..bfc4908f 100644 --- a/panel/lot/asset/js/panel.js +++ b/panel/lot/asset/js/panel.js @@ -1,6 +1,6 @@ (function(win, doc, _) { - var hooks = {}; + let hooks = {}; function isSet(x) { return 'undefined' !== typeof x; @@ -22,7 +22,7 @@ } if (isSet(hooks[name])) { if (isSet(fn)) { - for (var i = 0, j = hooks[name].length; i < j; ++i) { + for (let i = 0, j = hooks[name].length; i < j; ++i) { if (fn === hooks[name][i]) { hooks[name].splice(i, 1); } @@ -38,7 +38,7 @@ if (!isSet(hooks[name])) { return _; } - for (var i = 0, j = hooks[name].length; i < j; ++i) { + for (let i = 0, j = hooks[name].length; i < j; ++i) { hooks[name][i].apply(_, lot); } return _; @@ -59,7 +59,7 @@ }); _.on('let', function() { - var title = doc.querySelector('title'); + let title = doc.querySelector('title'); title = title.getAttribute('data-is-loading'); title && (doc.title = title); }); diff --git a/panel/lot/asset/js/panel.min.js b/panel/lot/asset/js/panel.min.js index c814398c..c7760596 100644 --- a/panel/lot/asset/js/panel.min.js +++ b/panel/lot/asset/js/panel.min.js @@ -1 +1 @@ -!function(e,t,n){function o(e){return Object.keys(e).length}function i(e){return"function"==typeof e}function r(e){return void 0!==e}var s={};n.on=function(e,t){r(s[e])||(s[e]={});var a=i(t)?t.name:"",c=o(s[e]);return a&&"anonymous"!==a?r(s[e][a])&&(a+="."+c):a=c,s[e][a]=t,n},n.off=function(e,t){if(!r(e))return s={},n;var o=i(t)?t.name:"";return r(t)&&o&&"anonymous"!==o?(delete s[e][o],n):(s[e]={},n)},n.fire=function(e,t,o){if(!r(s[e]))return n;if(r(o)){var a=i(o)?o.name:"";a&&"anonymous"!==a&&r(s[e][a])&&s[e][a].apply(n,t)}else for(var c in s[e])s[e][c].apply(n,t);return n},n.hooks=s,t.addEventListener("load",function(){n.fire("get")}),t.addEventListener("beforeunload",function(){n.fire("let")}),t.addEventListener("DOMContentLoaded",function(){n.fire("set")}),n.on("let",function(){var e=t.querySelector("title");e=e.getAttribute("data-loading-text"),e&&(t.title=e)})}(window,document,window._=window._||{}); +!function(e,t,n){let i={};function o(e){return void 0!==e}n.on=function(e,t){return o(i[e])||(i[e]=[]),o(t)&&i[e].push(t),n},n.off=function(e,t){if(!o(e))return i={},n;if(o(i[e]))if(o(t))for(let n=0,o=i[e].length;n]+>/gi,s=/\s?[a-z:]+(?:=['"][^'">]+['"])*/gi,i=t.match(n);if(i&&i.length&&(i=i[0].match(s),i.length&&(i.shift(),i.forEach(function(t){var e=t.trim().split("=");1===e.length?o.documentElement.setAttribute(e[0],!0):o.documentElement.setAttribute(e[0],e[1].slice(1,-1))}))),o.documentElement.innerHTML=t,this.log("load content",o.documentElement.attributes,o.documentElement.innerHTML.length),document.activeElement&&u(document,this.options.selectors,document.activeElement))try{document.activeElement.blur()}catch(r){}this.switchSelectors(this.options.selectors,o,document,e)},abortRequest:t("./lib/abort-request"),doRequest:t("./lib/send-request"),handleResponse:t("./lib/proto/handle-response"),loadUrl:function(t,e){e="object"==typeof e?d({},this.options,e):c(this.options),this.log("load href",t,e),this.abortRequest(this.request),l(document,"pjax:send",e),this.request=this.doRequest(t,e,this.handleResponse.bind(this))},afterAllSwitches:function(){var t=Array.prototype.slice.call(document.querySelectorAll("[autofocus]")).pop();t&&document.activeElement!==t&&t.focus(),this.options.selectors.forEach(function(t){n(document.querySelectorAll(t),function(t){o(t)})});var e=this.state;if(e.options.history&&(window.history.state||(this.lastUid=this.maxUid=r(),window.history.replaceState({url:window.location.href,title:document.title,uid:this.maxUid,scrollPos:[0,0]},document.title)),this.lastUid=this.maxUid=r(),window.history.pushState({url:e.href,title:e.options.title,uid:this.maxUid,scrollPos:[0,0]},e.options.title,e.href)),this.forEachSelectors(function(t){this.parseDOM(t)},this),l(document,"pjax:complete pjax:success",e.options),"function"==typeof e.options.analytics&&e.options.analytics(),e.options.history){var s=document.createElement("a");if(s.href=this.state.href,s.hash){var i=s.hash.slice(1);i=decodeURIComponent(i);var a=0,c=document.getElementById(i)||document.getElementsByName(i)[0];if(c&&c.offsetParent)do a+=c.offsetTop,c=c.offsetParent;while(c);window.scrollTo(0,a)}else e.options.scrollTo!==!1&&(e.options.scrollTo.length>1?window.scrollTo(e.options.scrollTo[0],e.options.scrollTo[1]):window.scrollTo(0,e.options.scrollTo))}else e.options.scrollRestoration&&e.options.scrollPos&&window.scrollTo(e.options.scrollPos[0],e.options.scrollPos[1]);this.state={numPendingSwitches:0,href:null,options:null}}},f.isSupported=t("./lib/is-supported"),f.isSupported())e.exports=f;else{var p=h;for(var m in f.prototype)f.prototype.hasOwnProperty(m)&&"function"==typeof f.prototype[m]&&(p[m]=h);e.exports=p}},{"./lib/abort-request":2,"./lib/events/on":4,"./lib/events/trigger":5,"./lib/execute-scripts":6,"./lib/foreach-els":7,"./lib/foreach-selectors":8,"./lib/is-supported":9,"./lib/parse-options":10,"./lib/proto/attach-form":11,"./lib/proto/attach-link":12,"./lib/proto/handle-response":13,"./lib/proto/log":14,"./lib/proto/parse-element":15,"./lib/send-request":16,"./lib/switches":18,"./lib/switches-selectors":17,"./lib/uniqueid":19,"./lib/util/clone":20,"./lib/util/contains":21,"./lib/util/extend":22,"./lib/util/noop":23}],2:[function(t,e){var o=t("./util/noop");e.exports=function(t){t&&t.readyState<4&&(t.onreadystatechange=o,t.abort())}},{"./util/noop":23}],3:[function(t,e){e.exports=function(t){var e=t.text||t.textContent||t.innerHTML||"",o=t.src||"",n=t.parentNode||document.querySelector("head")||document.documentElement,s=document.createElement("script");if(e.match("document.write"))return console&&console.log&&console.log("Script contains document.write. Can’t be executed correctly. Code skipped ",t),!1;if(s.type="text/javascript",s.id=t.id,""!==o&&(s.src=o,s.async=!1),""!==e)try{s.appendChild(document.createTextNode(e))}catch(i){s.text=e}return n.appendChild(s),(n instanceof HTMLHeadElement||n instanceof HTMLBodyElement)&&n.contains(s)&&n.removeChild(s),!0}},{}],4:[function(t,e){var o=t("../foreach-els");e.exports=function(t,e,n,s){e="string"==typeof e?e.split(" "):e,e.forEach(function(e){o(t,function(t){t.addEventListener(e,n,s)})})}},{"../foreach-els":7}],5:[function(t,e){var o=t("../foreach-els");e.exports=function(t,e,n){e="string"==typeof e?e.split(" "):e,e.forEach(function(e){var s;s=document.createEvent("HTMLEvents"),s.initEvent(e,!0,!0),s.eventName=e,n&&Object.keys(n).forEach(function(t){s[t]=n[t]}),o(t,function(t){var e=!1;t.parentNode||t===document||t===window||(e=!0,document.body.appendChild(t)),t.dispatchEvent(s),e&&t.parentNode.removeChild(t)})})}},{"../foreach-els":7}],6:[function(t,e){var o=t("./foreach-els"),n=t("./eval-script");e.exports=function(t){"script"===t.tagName.toLowerCase()&&n(t),o(t.querySelectorAll("script"),function(t){t.type&&"text/javascript"!==t.type.toLowerCase()||(t.parentNode&&t.parentNode.removeChild(t),n(t))})}},{"./eval-script":3,"./foreach-els":7}],7:[function(t,e){e.exports=function(t,e,o){return t instanceof HTMLCollection||t instanceof NodeList||t instanceof Array?Array.prototype.forEach.call(t,e,o):e.call(o,t)}},{}],8:[function(t,e){var o=t("./foreach-els");e.exports=function(t,e,n,s){s=s||document,t.forEach(function(t){o(s.querySelectorAll(t),e,n)})}},{"./foreach-els":7}],9:[function(t,e){e.exports=function(){return window.history&&window.history.pushState&&window.history.replaceState&&!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/)}},{}],10:[function(t,e){function o(){window._gaq&&_gaq.push(["_trackPageview"]),window.ga&&ga("send","pageview",{page:location.pathname,title:document.title})}var n=t("./switches");e.exports=function(t){return t=t||{},t.elements=t.elements||"a[href], form[action]",t.selectors=t.selectors||["title",".js-Pjax"],t.switches=t.switches||{},t.switchesOptions=t.switchesOptions||{},t.history=void 0===t.history?!0:t.history,t.analytics="function"==typeof t.analytics||t.analytics===!1?t.analytics:o,t.scrollTo=void 0===t.scrollTo?0:t.scrollTo,t.scrollRestoration=void 0!==t.scrollRestoration?t.scrollRestoration:!0,t.cacheBust=void 0===t.cacheBust?!0:t.cacheBust,t.debug=t.debug||!1,t.timeout=t.timeout||0,t.currentUrlFullReload=void 0===t.currentUrlFullReload?!1:t.currentUrlFullReload,t.switches.head||(t.switches.head=n.switchElementsAlt),t.switches.body||(t.switches.body=n.switchElementsAlt),t}},{"./switches":18}],11:[function(t,e){function o(t){for(var e=[],o=t.elements,n=0;n1||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey?"modifier":t.protocol!==window.location.protocol||t.host!==window.location.host?"external":t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")?"anchor":t.href===window.location.href.split("#")[0]+"#"?"anchor-empty":void 0}var n=t("../events/on"),s=t("../util/clone"),i="data-pjax-state",r=function(t,e){if(!a(e)){var n=s(this.options),r=o(t,e);if(r)return void t.setAttribute(i,r);if(e.preventDefault(),this.options.currentUrlFullReload&&t.href===window.location.href.split("#")[0])return t.setAttribute(i,"reload"),void this.reload();t.setAttribute(i,"load"),n.triggerElement=t,this.loadUrl(t.href,n)}},a=function(t){return t.defaultPrevented||t.returnValue===!1};e.exports=function(t){var e=this;t.setAttribute(i,""),n(t,"click",function(o){r.call(e,t,o)}),n(t,"keyup",function(o){13===o.keyCode&&r.call(e,t,o)}.bind(this))}},{"../events/on":4,"../util/clone":20}],13:[function(t,e){var o=t("../util/clone"),n=t("../uniqueid"),s=t("../events/trigger");e.exports=function(t,e,i,r){if(r=o(r||this.options),r.request=e,t===!1)return void s(document,"pjax:complete pjax:error",r);var a=window.history.state||{};window.history.replaceState({url:a.url||window.location.href,title:a.title||document.title,uid:a.uid||n(),scrollPos:[document.documentElement.scrollLeft||document.body.scrollLeft,document.documentElement.scrollTop||document.body.scrollTop]},document.title,window.location.href);var l=i;e.responseURL?i!==e.responseURL&&(i=e.responseURL):e.getResponseHeader("X-PJAX-URL")?i=e.getResponseHeader("X-PJAX-URL"):e.getResponseHeader("X-XHR-Redirected-To")&&(i=e.getResponseHeader("X-XHR-Redirected-To"));var c=document.createElement("a");c.href=l;var u=c.hash;c.href=i,u&&!c.hash&&(c.hash=u,i=c.href),this.state.href=i,this.state.options=r;try{this.loadContent(t,r)}catch(d){if(s(document,"pjax:error",r),this.options.debug)throw d;return console&&console.error&&console.error("Pjax switch fail: ",d),this.latestChance(i)}}},{"../events/trigger":5,"../uniqueid":19,"../util/clone":20}],14:[function(t,e){e.exports=function(){this.options.debug&&console&&("function"==typeof console.log?console.log.apply(console,arguments):console.log&&console.log(arguments))}},{}],15:[function(t,e){var o="data-pjax-state";e.exports=function(t){switch(t.tagName.toLowerCase()){case"a":t.hasAttribute(o)||this.attachLink(t);break;case"form":t.hasAttribute(o)||this.attachForm(t);break;default:throw"Pjax can only be applied on or
submit"}}},{}],16:[function(t,e){var o=t("./util/update-query-string");e.exports=function(t,e,n){e=e||{};var s,i=e.requestOptions||{},r=(i.requestMethod||"GET").toUpperCase(),a=i.requestParams||null,l=i.formData||null,c=null,u=new XMLHttpRequest,d=e.timeout||0;if(u.onreadystatechange=function(){4===u.readyState&&(200===u.status?n(u.responseText,u,t,e):0!==u.status&&n(null,u,t,e))},u.onerror=function(o){console.log(o),n(null,u,t,e)},u.ontimeout=function(){n(null,u,t,e)},a&&a.length)switch(s=a.map(function(t){return t.name+"="+t.value}).join("&"),r){case"GET":t=t.split("?")[0],t+="?"+s;break;case"POST":c=s}else l&&(c=l);return e.cacheBust&&(t=o(t,"t",Date.now())),u.open(r,t,!0),u.timeout=d,u.setRequestHeader("X-Requested-With","XMLHttpRequest"),u.setRequestHeader("X-PJAX","true"),u.setRequestHeader("X-PJAX-Selectors",JSON.stringify(e.selectors)),c&&"POST"===r&&!l&&u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(c),u}},{"./util/update-query-string":24}],17:[function(t,e){var o=t("./foreach-els"),n=t("./switches");e.exports=function(t,e,s,i,r,a){var l=[];s.forEach(function(s){var c=i.querySelectorAll(s),u=r.querySelectorAll(s);if(this.log&&this.log("Pjax switch",s,c,u),c.length!==u.length)throw"DOM doesn’t look the same on new loaded page: ’"+s+"’ - new "+c.length+", old "+u.length;o(c,function(o,i){var r=u[i];this.log&&this.log("newEl",o,"oldEl",r);var c=t[s]?t[s].bind(this,r,o,a,e[s]):n.outerHTML.bind(this,r,o,a);l.push(c)},this)},this),this.state.numPendingSwitches=l.length,l.forEach(function(t){t()})}},{"./foreach-els":7,"./switches":18}],18:[function(t,e){var o=t("./events/on");e.exports={outerHTML:function(t,e){t.outerHTML=e.outerHTML,this.onSwitch()},innerHTML:function(t,e){t.innerHTML=e.innerHTML,""===e.className?t.removeAttribute("class"):t.className=e.className,this.onSwitch()},switchElementsAlt:function(t,e){if(t.innerHTML=e.innerHTML,e.hasAttributes())for(var o=e.attributes,n=0;n=u&&r&&(r.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)}),a.forEach(function(t){t.className=t.className.replace(t.getAttribute("data-pjax-classes"),""),t.removeAttribute("data-pjax-classes")}),a=null,r=null,this.onSwitch()))}.bind(this);s=s||{},i.call(t.childNodes,function(t){r.push(t),t.classList&&!t.classList.contains("js-Pjax-remove")&&(t.hasAttribute("data-pjax-classes")&&(t.className=t.className.replace(t.getAttribute("data-pjax-classes"),""),t.removeAttribute("data-pjax-classes")),t.classList.add("js-Pjax-remove"),s.callbacks&&s.callbacks.removeElement&&s.callbacks.removeElement(t),s.classNames&&(t.className+=" "+s.classNames.remove+" "+(n.backward?s.classNames.backward:s.classNames.forward)),u++,o(t,c,d,!0))}),i.call(e.childNodes,function(t){if(t.classList){var e="";s.classNames&&(e=" js-Pjax-add "+s.classNames.add+" "+(n.backward?s.classNames.forward:s.classNames.backward)),s.callbacks&&s.callbacks.addElement&&s.callbacks.addElement(t),t.className+=e,t.setAttribute("data-pjax-classes",e),a.push(t),l.appendChild(t),u++,o(t,c,d,!0)}}),t.className=e.className,t.appendChild(l)}}},{"./events/on":4}],19:[function(t,e){e.exports=function(){var t=0;return function(){var e="pjax"+(new Date).getTime()+"_"+t;return t++,e}}()},{}],20:[function(t,e){e.exports=function(t){if(null===t||"object"!=typeof t)return t;var e=t.constructor();for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);return e}},{}],21:[function(t,e){e.exports=function(t,e,o){for(var n=0;ndiv>main","body>div>nav","body>svg","title"],switches:{"body>div>main":n,"body>div>nav":n,"body>svg":n,title:function(t,e){t.outerHTML=e.outerHTML,o.className=e.parentNode.parentNode.className,this.onSwitch()}},cacheBust:!1}),t.addEventListener("pjax:send",function(){e.fire("let")},!1),t.addEventListener("pjax:success",function(){e.fire("change")},!1)}(document,_); +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Pjax=t()}}(function(){return function(){return function t(e,o,n){function i(r,a){if(!o[r]){if(!e[r]){var l="function"==typeof require&&require;if(!a&&l)return l(r,!0);if(s)return s(r,!0);var c=Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var u=o[r]={exports:{}};e[r][0].call(u.exports,function(t){return i(e[r][1][t]||t)},u,u.exports,t,e,o,n)}return o[r].exports}for(var s="function"==typeof require&&require,r=0;r]+>/gi);if(n&&n.length&&((n=n[0].match(/\s?[a-z:]+(?:=['"][^'">]+['"])*/gi)).length&&(n.shift(),n.forEach(function(t){var e=t.trim().split("=");1===e.length?o.documentElement.setAttribute(e[0],!0):o.documentElement.setAttribute(e[0],e[1].slice(1,-1))}))),o.documentElement.innerHTML=t,this.log("load content",o.documentElement.attributes,o.documentElement.innerHTML.length),document.activeElement&&u(document,this.options.selectors,document.activeElement))try{document.activeElement.blur()}catch(t){}this.switchSelectors(this.options.selectors,o,document,e)}else l(document,"pjax:complete pjax:error",e)},abortRequest:t("./lib/abort-request"),doRequest:t("./lib/send-request"),handleResponse:t("./lib/proto/handle-response"),loadUrl:function(t,e){e="object"==typeof e?d({},this.options,e):c(this.options),this.log("load href",t,e),this.abortRequest(this.request),l(document,"pjax:send",e),this.request=this.doRequest(t,e,this.handleResponse.bind(this))},afterAllSwitches:function(){var t=Array.prototype.slice.call(document.querySelectorAll("[autofocus]")).pop();t&&document.activeElement!==t&&t.focus(),this.options.selectors.forEach(function(t){n(document.querySelectorAll(t),function(t){o(t)})});var e=this.state;if(e.options.history&&(window.history.state||(this.lastUid=this.maxUid=r(),window.history.replaceState({url:window.location.href,title:document.title,uid:this.maxUid,scrollPos:[0,0]},document.title)),this.lastUid=this.maxUid=r(),window.history.pushState({url:e.href,title:e.options.title,uid:this.maxUid,scrollPos:[0,0]},e.options.title,e.href)),this.forEachSelectors(function(t){this.parseDOM(t)},this),l(document,"pjax:complete pjax:success",e.options),"function"==typeof e.options.analytics&&e.options.analytics(),e.options.history){var i=document.createElement("a");if(i.href=this.state.href,i.hash){var s=i.hash.slice(1);s=decodeURIComponent(s);var a=0,c=document.getElementById(s)||document.getElementsByName(s)[0];if(c&&c.offsetParent)do{a+=c.offsetTop,c=c.offsetParent}while(c);window.scrollTo(0,a)}else!1!==e.options.scrollTo&&(e.options.scrollTo.length>1?window.scrollTo(e.options.scrollTo[0],e.options.scrollTo[1]):window.scrollTo(0,e.options.scrollTo))}else e.options.scrollRestoration&&e.options.scrollPos&&window.scrollTo(e.options.scrollPos[0],e.options.scrollPos[1]);this.state={numPendingSwitches:0,href:null,options:null}}},p.isSupported=t("./lib/is-supported"),p.isSupported())e.exports=p;else{var f=h;for(var m in p.prototype)p.prototype.hasOwnProperty(m)&&"function"==typeof p.prototype[m]&&(f[m]=h);e.exports=f}},{"./lib/abort-request":2,"./lib/events/on":4,"./lib/events/trigger":5,"./lib/execute-scripts":6,"./lib/foreach-els":7,"./lib/foreach-selectors":8,"./lib/is-supported":9,"./lib/parse-options":10,"./lib/proto/attach-form":11,"./lib/proto/attach-link":12,"./lib/proto/handle-response":13,"./lib/proto/log":14,"./lib/proto/parse-element":15,"./lib/send-request":16,"./lib/switches":18,"./lib/switches-selectors":17,"./lib/uniqueid":19,"./lib/util/clone":20,"./lib/util/contains":21,"./lib/util/extend":22,"./lib/util/noop":23}],2:[function(t,e){var o=t("./util/noop");e.exports=function(t){t&&t.readyState<4&&(t.onreadystatechange=o,t.abort())}},{"./util/noop":23}],3:[function(t,e){e.exports=function(t){var e=t.text||t.textContent||t.innerHTML||"",o=t.src||"",n=t.parentNode||document.querySelector("head")||document.documentElement,i=document.createElement("script");if(e.match("document.write"))return console&&console.log&&console.log("Script contains document.write. Can’t be executed correctly. Code skipped ",t),!1;if(i.type="text/javascript",i.id=t.id,""!==o&&(i.src=o,i.async=!1),""!==e)try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return n.appendChild(i),(n instanceof HTMLHeadElement||n instanceof HTMLBodyElement)&&n.contains(i)&&n.removeChild(i),!0}},{}],4:[function(t,e){var o=t("../foreach-els");e.exports=function(t,e,n,i){(e="string"==typeof e?e.split(" "):e).forEach(function(e){o(t,function(t){t.addEventListener(e,n,i)})})}},{"../foreach-els":7}],5:[function(t,e){var o=t("../foreach-els");e.exports=function(t,e,n){(e="string"==typeof e?e.split(" "):e).forEach(function(e){var i;(i=document.createEvent("HTMLEvents")).initEvent(e,!0,!0),i.eventName=e,n&&Object.keys(n).forEach(function(t){i[t]=n[t]}),o(t,function(t){var e=!1;t.parentNode||t===document||t===window||(e=!0,document.body.appendChild(t)),t.dispatchEvent(i),e&&t.parentNode.removeChild(t)})})}},{"../foreach-els":7}],6:[function(t,e){var o=t("./foreach-els"),n=t("./eval-script");e.exports=function(t){"script"===t.tagName.toLowerCase()&&n(t),o(t.querySelectorAll("script"),function(t){t.type&&"text/javascript"!==t.type.toLowerCase()||(t.parentNode&&t.parentNode.removeChild(t),n(t))})}},{"./eval-script":3,"./foreach-els":7}],7:[function(t,e){e.exports=function(t,e,o){return t instanceof HTMLCollection||t instanceof NodeList||t instanceof Array?Array.prototype.forEach.call(t,e,o):e.call(o,t)}},{}],8:[function(t,e){var o=t("./foreach-els");e.exports=function(t,e,n,i){i=i||document,t.forEach(function(t){o(i.querySelectorAll(t),e,n)})}},{"./foreach-els":7}],9:[function(t,e){e.exports=function(){return window.history&&window.history.pushState&&window.history.replaceState&&!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/)}},{}],10:[function(t,e){function o(){window._gaq&&_gaq.push(["_trackPageview"]),window.ga&&ga("send","pageview",{page:location.pathname,title:document.title})}var n=t("./switches");e.exports=function(t){return(t=t||{}).elements=t.elements||"a[href], form[action]",t.selectors=t.selectors||["title",".js-Pjax"],t.switches=t.switches||{},t.switchesOptions=t.switchesOptions||{},t.history=void 0===t.history||t.history,t.analytics="function"==typeof t.analytics||!1===t.analytics?t.analytics:o,t.scrollTo=void 0===t.scrollTo?0:t.scrollTo,t.scrollRestoration=void 0===t.scrollRestoration||t.scrollRestoration,t.cacheBust=void 0===t.cacheBust||t.cacheBust,t.debug=t.debug||!1,t.timeout=t.timeout||0,t.currentUrlFullReload=void 0!==t.currentUrlFullReload&&t.currentUrlFullReload,t.switches.head||(t.switches.head=n.switchElementsAlt),t.switches.body||(t.switches.body=n.switchElementsAlt),t}},{"./switches":18}],11:[function(t,e){var o=t("../events/on"),n=t("../util/clone"),i="data-pjax-state",s=function(t,e){if(!r(e)){var o=n(this.options);o.requestOptions={requestUrl:t.getAttribute("action")||window.location.href,requestMethod:t.getAttribute("method")||"GET"};var s=document.createElement("a");s.setAttribute("href",o.requestOptions.requestUrl);var a=function(t,e){return t.protocol!==window.location.protocol||t.host!==window.location.host?"external":t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")?"anchor":t.href===window.location.href.split("#")[0]+"#"?"anchor-empty":e.currentUrlFullReload&&t.href===window.location.href.split("#")[0]?"reload":void 0}(s,o);if(a)return void t.setAttribute(i,a);e.preventDefault(),"multipart/form-data"===t.enctype?o.requestOptions.formData=new FormData(t):o.requestOptions.requestParams=function(t){for(var e=[],o=t.elements,n=0;n1||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey?"modifier":t.protocol!==window.location.protocol||t.host!==window.location.host?"external":t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")?"anchor":t.href===window.location.href.split("#")[0]+"#"?"anchor-empty":void 0}(t,e);if(s)return void t.setAttribute(i,s);if(e.preventDefault(),this.options.currentUrlFullReload&&t.href===window.location.href.split("#")[0])return t.setAttribute(i,"reload"),void this.reload();t.setAttribute(i,"load"),o.triggerElement=t,this.loadUrl(t.href,o)}},r=function(t){return t.defaultPrevented||!1===t.returnValue};e.exports=function(t){var e=this;t.setAttribute(i,""),o(t,"click",function(o){s.call(e,t,o)}),o(t,"keyup",function(o){13===o.keyCode&&s.call(e,t,o)}.bind(this))}},{"../events/on":4,"../util/clone":20}],13:[function(t,e){var o=t("../util/clone"),n=t("../uniqueid"),i=t("../events/trigger");e.exports=function(t,e,s,r){if((r=o(r||this.options)).request=e,!1!==t){var a=window.history.state||{};window.history.replaceState({url:a.url||window.location.href,title:a.title||document.title,uid:a.uid||n(),scrollPos:[document.documentElement.scrollLeft||document.body.scrollLeft,document.documentElement.scrollTop||document.body.scrollTop]},document.title,window.location.href);var l=s;e.responseURL?s!==e.responseURL&&(s=e.responseURL):e.getResponseHeader("X-PJAX-URL")?s=e.getResponseHeader("X-PJAX-URL"):e.getResponseHeader("X-XHR-Redirected-To")&&(s=e.getResponseHeader("X-XHR-Redirected-To"));var c=document.createElement("a");c.href=l;var u=c.hash;c.href=s,u&&!c.hash&&(c.hash=u,s=c.href),this.state.href=s,this.state.options=r;try{this.loadContent(t,r)}catch(t){if(i(document,"pjax:error",r),this.options.debug)throw t;return console&&console.error&&console.error("Pjax switch fail: ",t),this.latestChance(s)}}else i(document,"pjax:complete pjax:error",r)}},{"../events/trigger":5,"../uniqueid":19,"../util/clone":20}],14:[function(t,e){e.exports=function(){this.options.debug&&console&&("function"==typeof console.log?console.log.apply(console,arguments):console.log&&console.log(arguments))}},{}],15:[function(t,e){var o="data-pjax-state";e.exports=function(t){switch(t.tagName.toLowerCase()){case"a":t.hasAttribute(o)||this.attachLink(t);break;case"form":t.hasAttribute(o)||this.attachForm(t);break;default:throw"Pjax can only be applied on or submit"}}},{}],16:[function(t,e){var o=t("./util/update-query-string");e.exports=function(t,e,n){var i,s=(e=e||{}).requestOptions||{},r=(s.requestMethod||"GET").toUpperCase(),a=s.requestParams||null,l=s.formData||null,c=null,u=new XMLHttpRequest,d=e.timeout||0;if(u.onreadystatechange=function(){4===u.readyState&&(200===u.status?n(u.responseText,u,t,e):0!==u.status&&n(null,u,t,e))},u.onerror=function(o){console.log(o),n(null,u,t,e)},u.ontimeout=function(){n(null,u,t,e)},a&&a.length)switch(i=a.map(function(t){return t.name+"="+t.value}).join("&"),r){case"GET":t=t.split("?")[0],t+="?"+i;break;case"POST":c=i}else l&&(c=l);return e.cacheBust&&(t=o(t,"t",Date.now())),u.open(r,t,!0),u.timeout=d,u.setRequestHeader("X-Requested-With","XMLHttpRequest"),u.setRequestHeader("X-PJAX","true"),u.setRequestHeader("X-PJAX-Selectors",JSON.stringify(e.selectors)),c&&"POST"===r&&!l&&u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(c),u}},{"./util/update-query-string":24}],17:[function(t,e){var o=t("./foreach-els"),n=t("./switches");e.exports=function(t,e,i,s,r,a){var l=[];i.forEach(function(i){var c=s.querySelectorAll(i),u=r.querySelectorAll(i);if(this.log&&this.log("Pjax switch",i,c,u),c.length!==u.length)throw"DOM doesn’t look the same on new loaded page: ’"+i+"’ - new "+c.length+", old "+u.length;o(c,function(o,s){var r=u[s];this.log&&this.log("newEl",o,"oldEl",r);var c=t[i]?t[i].bind(this,r,o,a,e[i]):n.outerHTML.bind(this,r,o,a);l.push(c)},this)},this),this.state.numPendingSwitches=l.length,l.forEach(function(t){t()})}},{"./foreach-els":7,"./switches":18}],18:[function(t,e){var o=t("./events/on");e.exports={outerHTML:function(t,e){t.outerHTML=e.outerHTML,this.onSwitch()},innerHTML:function(t,e){t.innerHTML=e.innerHTML,""===e.className?t.removeAttribute("class"):t.className=e.className,this.onSwitch()},switchElementsAlt:function(t,e){if(t.innerHTML=e.innerHTML,e.hasAttributes())for(var o=e.attributes,n=0;n=--u&&r&&(r.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)}),a.forEach(function(t){t.className=t.className.replace(t.getAttribute("data-pjax-classes"),""),t.removeAttribute("data-pjax-classes")}),a=null,r=null,this.onSwitch()))}.bind(this);i=i||{},s.call(t.childNodes,function(t){r.push(t),t.classList&&!t.classList.contains("js-Pjax-remove")&&(t.hasAttribute("data-pjax-classes")&&(t.className=t.className.replace(t.getAttribute("data-pjax-classes"),""),t.removeAttribute("data-pjax-classes")),t.classList.add("js-Pjax-remove"),i.callbacks&&i.callbacks.removeElement&&i.callbacks.removeElement(t),i.classNames&&(t.className+=" "+i.classNames.remove+" "+(n.backward?i.classNames.backward:i.classNames.forward)),u++,o(t,c,d,!0))}),s.call(e.childNodes,function(t){if(t.classList){var e="";i.classNames&&(e=" js-Pjax-add "+i.classNames.add+" "+(n.backward?i.classNames.forward:i.classNames.backward)),i.callbacks&&i.callbacks.addElement&&i.callbacks.addElement(t),t.className+=e,t.setAttribute("data-pjax-classes",e),a.push(t),l.appendChild(t),u++,o(t,c,d,!0)}}),t.className=e.className,t.appendChild(l)}}},{"./events/on":4}],19:[function(t,e){e.exports=function(){var t=0;return function(){var e="pjax"+(new Date).getTime()+"_"+t;return t++,e}}()},{}],20:[function(t,e){e.exports=function(t){if(null===t||"object"!=typeof t)return t;var e=t.constructor();for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);return e}},{}],21:[function(t,e){e.exports=function(t,e,o){for(var n=0;ndiv>main","body>div>nav","body>svg","title"],switches:{"body>div>main":n,"body>div>nav":n,"body>svg":n,title:function(t,e){t.outerHTML=e.outerHTML,o.className=e.parentNode.parentNode.className,this.onSwitch()}},cacheBust:!1}),i(),e.on("change",i),t.addEventListener("pjax:send",function(){e.fire("let")},!1),t.addEventListener("pjax:success",function(){e.fire("change")},!1)}(document,_); diff --git a/panel/lot/asset/js/panel/menu.js b/panel/lot/asset/js/panel/menu.js index f0a28d30..0d2d4106 100644 --- a/panel/lot/asset/js/panel/menu.js +++ b/panel/lot/asset/js/panel/menu.js @@ -12,7 +12,7 @@ doHide(0, e); } function onClickShow(e) { - var t = this, + let t = this, menu = t.nextElementSibling; doHide(menu, e); setTimeout(function() { @@ -25,11 +25,11 @@ } function onChange() { doc.removeEventListener('click', onClickHide); - var dropdowns = doc.querySelectorAll('.has\\:menu'); + let dropdowns = doc.querySelectorAll('.has\\:menu'); if (dropdowns.length) { doc.addEventListener('click', onClickHide, false); dropdowns.forEach(function($) { - var menu = $.querySelector('.lot\\:menu'); + let menu = $.querySelector('.lot\\:menu'); if (menu) { menu.previousElementSibling.addEventListener('click', onClickShow, false); } diff --git a/panel/lot/asset/js/panel/menu.min.js b/panel/lot/asset/js/panel/menu.min.js index 31d7a10b..650b79da 100644 --- a/panel/lot/asset/js/panel/menu.min.js +++ b/panel/lot/asset/js/panel/menu.min.js @@ -1 +1 @@ -!function(t,e,o){function n(t,o){e.querySelectorAll(".lot\\:menu.is\\:enter").forEach(function(e){e!==t&&o!==t.previousElementSibling&&(e.classList.remove("is:enter"),e.parentNode.classList.remove("is:active"),e.previousElementSibling.classList.remove("is:active"))})}function i(t){n(0,t)}function s(t){var e=this,o=e.nextElementSibling;n(o,t),setTimeout(function(){e.classList.toggle("is:active"),e.parentNode.classList.toggle("is:active"),o.classList.toggle("is:enter")},1),t.preventDefault(),t.stopPropagation()}function r(){e.removeEventListener("click",i);var t=e.querySelectorAll(".has\\:menu");t.length&&(e.addEventListener("click",i,!1),t.forEach(function(t){var e=t.querySelector(".lot\\:menu");e&&e.previousElementSibling.addEventListener("click",s,!1)}))}r(),o.on("change",r)}(window,document,_); +!function(e,t,i){function n(e,i){t.querySelectorAll(".lot\\:menu.is\\:enter").forEach(function(t){t!==e&&i!==e.previousElementSibling&&(t.classList.remove("is:enter"),t.parentNode.classList.remove("is:active"),t.previousElementSibling.classList.remove("is:active"))})}function s(e){n(0,e)}function l(e){let t=this,i=t.nextElementSibling;n(i,e),setTimeout(function(){t.classList.toggle("is:active"),t.parentNode.classList.toggle("is:active"),i.classList.toggle("is:enter")},1),e.preventDefault(),e.stopPropagation()}function o(){t.removeEventListener("click",s);let e=t.querySelectorAll(".has\\:menu");e.length&&(t.addEventListener("click",s,!1),e.forEach(function(e){let t=e.querySelector(".lot\\:menu");t&&t.previousElementSibling.addEventListener("click",l,!1)}))}o(),i.on("change",o)}(window,document,_); diff --git a/panel/lot/asset/js/panel/tab.js b/panel/lot/asset/js/panel/tab.js index da512b60..4d6a8e66 100644 --- a/panel/lot/asset/js/panel/tab.js +++ b/panel/lot/asset/js/panel/tab.js @@ -1,9 +1,9 @@ (function(win, doc, _) { function onChange() { - var tabs = doc.querySelectorAll('.lot\\:tab'), + let tabs = doc.querySelectorAll('.lot\\:tab'), replaceState = 'replaceState' in win.history, setAction = function($) { - var href = $.href; + let href = $.href; while ($ && $.nodeName.toLowerCase() !== 'form') { $ = $.parentNode; } @@ -11,7 +11,7 @@ }; if (tabs.length) { tabs.forEach(function($) { - var panes = [].slice.call($.children), + let panes = [].slice.call($.children), buttons = panes.shift().querySelectorAll('a'); function onClick(e) { if (!this.parentNode.classList.contains('has:link')) { diff --git a/panel/lot/asset/js/panel/tab.min.js b/panel/lot/asset/js/panel/tab.min.js index 526d5581..c267dcdc 100644 --- a/panel/lot/asset/js/panel/tab.min.js +++ b/panel/lot/asset/js/panel/tab.min.js @@ -1 +1 @@ -!function(t,e,o){function n(){var o=e.querySelectorAll(".lot\\:tab"),n="replaceState"in t.history,i=function(t){for(var e=t.href;t&&"form"!==t.nodeName.toLowerCase();)t=t.parentNode;t&&"form"===t.nodeName.toLowerCase()&&(t.action=e)};o.length&&o.forEach(function(e){function o(e){this.parentNode.classList.contains("has:link")||(this.classList.contains("not:active")||(r.forEach(function(t){t.parentNode.classList.remove("is:active"),s[t._index]&&s[t._index].classList.remove("is:active")}),this.parentNode.classList.add("is:active"),s[this._index]&&s[this._index].classList.add("is:active"),n&&t.history.replaceState({},"",this.href),i(this)),e.preventDefault())}var s=[].slice.call(e.children),r=s.shift().querySelectorAll("a");r.forEach(function(t,e){t._index=e,t.addEventListener("click",o,!1)})})}n(),o.on("change",n)}(window,document,_); +!function(e,t,i){function n(){let i=t.querySelectorAll(".lot\\:tab"),n="replaceState"in e.history,s=function(e){let t=e.href;for(;e&&"form"!==e.nodeName.toLowerCase();)e=e.parentNode;e&&"form"===e.nodeName.toLowerCase()&&(e.action=t)};i.length&&i.forEach(function(t){let i=[].slice.call(t.children),a=i.shift().querySelectorAll("a");function o(t){this.parentNode.classList.contains("has:link")||(this.classList.contains("not:active")||(a.forEach(function(e){e.parentNode.classList.remove("is:active"),i[e._index]&&i[e._index].classList.remove("is:active")}),this.parentNode.classList.add("is:active"),i[this._index]&&i[this._index].classList.add("is:active"),n&&e.history.replaceState({},"",this.href),s(this)),t.preventDefault())}a.forEach(function(e,t){e._index=t,e.addEventListener("click",o,!1)})})}n(),i.on("change",n)}(window,document,_);