diff --git a/demo/onepage.html b/demo/onepage.html index 963619c0..7956352a 100644 --- a/demo/onepage.html +++ b/demo/onepage.html @@ -103,15 +103,15 @@

API

diff --git a/dist/core/offcanvas/mmenu.offcanvas.css b/dist/core/offcanvas/mmenu.offcanvas.css index 4a03e31e..5628759a 100644 --- a/dist/core/offcanvas/mmenu.offcanvas.css +++ b/dist/core/offcanvas/mmenu.offcanvas.css @@ -1,4 +1,4 @@ -:root{--mm-size:80%;--mm-min-size:240px;--mm-max-size:440px}.mm-menu--offcanvas{position:fixed;z-index:0;-webkit-transition-property:visibility;-o-transition-property:visibility;transition-property:visibility}.mm-menu--offcanvas:not(.mm-menu--opened){visibility:hidden;pointer-events:none}.mm-menu--offcanvas:not(.mm-menu--opened) *{visibility:inherit}.mm-page{-webkit-box-sizing:border-box;box-sizing:border-box;min-height:100vh;background:inherit}:where(.mm-slideout){position:relative;z-index:1;width:100%;-webkit-transition-duration:.4s;-o-transition-duration:.4s;transition-duration:.4s;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;-webkit-transition-property:width,-webkit-transform;transition-property:width,-webkit-transform;-o-transition-property:width,transform;transition-property:width,transform;transition-property:width,transform,-webkit-transform}.mm-wrapper--opened,.mm-wrapper--opened body{overflow:hidden}.mm-wrapper__blocker{background:#00000066}.mm-menu{--mm-translate-horizontal:0;--mm-translate-vertical:0}.mm-menu--position-left,.mm-menu--position-left-front{right:auto}.mm-menu--position-right,.mm-menu--position-right-front{left:auto}.mm-menu--position-left,.mm-menu--position-left-front,.mm-menu--position-right,.mm-menu--position-right-front{width:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-left-front{--mm-translate-horizontal:-100%}.mm-menu--position-right-front{--mm-translate-horizontal:100%}.mm-menu--position-top{bottom:auto}.mm-menu--position-bottom{top:auto}.mm-menu--position-bottom,.mm-menu--position-top{width:100%;height:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-top{--mm-translate-vertical:-100%}.mm-menu--position-bottom{--mm-translate-vertical:100%}.mm-menu--position-bottom,.mm-menu--position-left-front,.mm-menu--position-right-front,.mm-menu--position-top{z-index:2;-webkit-transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);-webkit-transition-property:visibility,-webkit-transform;transition-property:visibility,-webkit-transform;-o-transition-property:visibility,transform;transition-property:visibility,transform;transition-property:visibility,transform,-webkit-transform}.mm-menu--position-bottom.mm-menu--opened,.mm-menu--position-left-front.mm-menu--opened,.mm-menu--position-right-front.mm-menu--opened,.mm-menu--position-top.mm-menu--opened{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.mm-wrapper--position-left{--mm-translate-horizontal:clamp( +:root{--mm-size:80%;--mm-min-size:240px;--mm-max-size:440px}.mm-menu--offcanvas{position:fixed;z-index:0;-webkit-transition-property:visibility 0s linear .4s;-o-transition-property:visibility 0s linear .4s;transition-property:visibility 0s linear .4s}.mm-menu--offcanvas.mm-menu--opened{-webkit-transition-delay:0s;-o-transition-delay:0s;transition-delay:0s}.mm-menu--offcanvas:not(.mm-menu--opened){visibility:hidden;pointer-events:none}.mm-menu--offcanvas:not(.mm-menu--opened) *{visibility:inherit}.mm-page{-webkit-box-sizing:border-box;box-sizing:border-box;min-height:100vh;background:inherit}:where(.mm-slideout){position:relative;z-index:1;width:100%;-webkit-transition-duration:.4s;-o-transition-duration:.4s;transition-duration:.4s;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;-webkit-transition-property:width,-webkit-transform;transition-property:width,-webkit-transform;-o-transition-property:width,transform;transition-property:width,transform;transition-property:width,transform,-webkit-transform}.mm-wrapper--opened,.mm-wrapper--opened body{overflow:hidden}.mm-wrapper__blocker{background:#00000066}.mm-menu{--mm-translate-horizontal:0;--mm-translate-vertical:0}.mm-menu--position-left,.mm-menu--position-left-front{right:auto}.mm-menu--position-right,.mm-menu--position-right-front{left:auto}.mm-menu--position-left,.mm-menu--position-left-front,.mm-menu--position-right,.mm-menu--position-right-front{width:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-left-front{--mm-translate-horizontal:-100%}.mm-menu--position-right-front{--mm-translate-horizontal:100%}.mm-menu--position-top{bottom:auto}.mm-menu--position-bottom{top:auto}.mm-menu--position-bottom,.mm-menu--position-top{width:100%;height:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-top{--mm-translate-vertical:-100%}.mm-menu--position-bottom{--mm-translate-vertical:100%}.mm-menu--position-bottom,.mm-menu--position-left-front,.mm-menu--position-right-front,.mm-menu--position-top{z-index:2;-webkit-transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);-webkit-transition-property:visibility,-webkit-transform;transition-property:visibility,-webkit-transform;-o-transition-property:visibility,transform;transition-property:visibility,transform;transition-property:visibility,transform,-webkit-transform}.mm-menu--position-bottom.mm-menu--opened,.mm-menu--position-left-front.mm-menu--opened,.mm-menu--position-right-front.mm-menu--opened,.mm-menu--position-top.mm-menu--opened{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.mm-wrapper--position-left{--mm-translate-horizontal:clamp( var(--mm-min-size), var(--mm-size), var(--mm-max-size) diff --git a/dist/core/offcanvas/mmenu.offcanvas.js b/dist/core/offcanvas/mmenu.offcanvas.js index a501b2fa..224827a1 100644 --- a/dist/core/offcanvas/mmenu.offcanvas.js +++ b/dist/core/offcanvas/mmenu.offcanvas.js @@ -121,13 +121,12 @@ Mmenu.prototype.open = function () { } // Invoke "before" hook. this.trigger('open:before'); - var clsn = ['mm-wrapper--opened']; - this.node.wrpr.classList.add(...clsn); // Open this.node.menu.classList.add('mm-menu--opened'); this.node.wrpr.classList.add('mm-wrapper--opened'); Mmenu.node.blck.classList.add('mm-blocker--blocking'); // Focus the menu. + this.node.open = document.activeElement; this.node.menu.focus(); // Invoke "after" hook. this.trigger('open:after'); @@ -143,7 +142,7 @@ Mmenu.prototype.close = function () { this.node.wrpr.classList.remove('mm-wrapper--opened'); Mmenu.node.blck.classList.remove('mm-blocker--blocking'); // Focus opening link or page. - const focus = document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null; + const focus = this.node.open || document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null; (_a = focus) === null || _a === void 0 ? void 0 : _a.focus(); // Invoke "after" hook. this.trigger('close:after'); diff --git a/dist/mmenu.css b/dist/mmenu.css index db6f7a25..9faeafd3 100644 --- a/dist/mmenu.css +++ b/dist/mmenu.css @@ -7,7 +7,7 @@ * * License: CC-BY-NC-4.0 * http://creativecommons.org/licenses/by-nc/4.0/ - */:root{--mm-lineheight:22px}.mm-hidden{display:none!important}.mm-wrapper{overflow-x:hidden;position:relative}.mm-menu,.mm-menu *{-webkit-transition-property:none;-o-transition-property:none;transition-property:none;-webkit-transition-duration:.4s;-o-transition-duration:.4s;transition-duration:.4s;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.mm-blocker{--mm-blocker-visibility-delay:0.4s;--mm-blocker-opacity-delay:0s;display:block;position:absolute;bottom:100%;top:0;right:0;left:0;z-index:3;visibility:hidden;opacity:0;background:var(--mm-color-background);-webkit-transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),-webkit-transform .4s ease;transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),-webkit-transform .4s ease;-o-transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),transform .4s ease;transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),transform .4s ease;transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),transform .4s ease,-webkit-transform .4s ease}.mm-blocker--blocking{--mm-blocker-visibility-delay:0s;--mm-blocker-opacity-delay:0.4s;bottom:0;visibility:visible;opacity:.5;pointer-events:auto}.mm-blocker:focus-visible{opacity:.75}.mm-btn{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0;-ms-flex-negative:0;flex-shrink:0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;position:relative;width:50px;padding:0}.mm-btn--next,[dir=rtl] .mm-btn--prev{--mm-btn-rotate:135deg}.mm-btn--prev,[dir=rtl] .mm-btn--next{--mm-btn-rotate:-45deg}.mm-btn--next:after,.mm-btn--prev:before{content:"";display:block;position:absolute;top:0;bottom:0;width:8px;height:8px;margin:auto;-webkit-box-sizing:border-box;box-sizing:border-box;border:2px solid var(--mm-color-icon);border-bottom:none;border-right:none;-webkit-transform:rotate(var(--mm-btn-rotate));-ms-transform:rotate(var(--mm-btn-rotate));transform:rotate(var(--mm-btn-rotate))}.mm-btn--prev:before{inset-inline-start:23px}.mm-btn--next:after{inset-inline-end:23px}.mm-btn--close:before{content:"×";font-size:150%}.mm-btnreset{padding:0;background:0 0;border:none;cursor:pointer}.mm-divider{-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;position:-webkit-sticky;position:sticky;z-index:2;top:0;min-height:var(--mm-lineheight);padding:calc(((var(--mm-listitem-size) * .65) - var(--mm-lineheight)) * .5) 20px;font-size:75%;text-transform:uppercase;background:var(--mm-color-background);background-image:-webkit-gradient(linear,left top,left bottom,from(var(--mm-color-background-highlight)),to(var(--mm-color-background-highlight)));background-image:-o-linear-gradient(var(--mm-color-background-highlight),var(--mm-color-background-highlight));background-image:linear-gradient(var(--mm-color-background-highlight),var(--mm-color-background-highlight));opacity:1;-webkit-transition-property:opacity;-o-transition-property:opacity;transition-property:opacity}.mm-navbar:not(.mm-hidden)~.mm-listview .mm-divider{top:var(--mm-navbar-size)}:root{--mm-listitem-size:50px}.mm-listitem{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;position:relative;padding:0;margin:0;color:var(--mm-color-text);border-color:var(--mm-color-border)}.mm-listitem:after{content:"";border-color:inherit;border-bottom-width:1px;border-bottom-style:solid;display:block;position:absolute;inset-inline-start:20px;inset-inline-end:0;bottom:0}.mm-listitem__btn,.mm-listitem__text{padding:calc((var(--mm-listitem-size) - var(--mm-lineheight))/ 2) 0}.mm-listitem__text{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:10%;flex-basis:10%;display:block;padding-left:20px;padding-right:20px;-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mm-listitem__btn{display:block;position:relative;width:auto;-webkit-padding-end:50px;padding-inline-end:50px;border-color:inherit;background:rgba(3,2,1,0)}.mm-listitem__btn:not(.mm-listitem__text){border-left-width:1px;border-left-style:solid}.mm-listitem--selected>.mm-listitem__text{background:var(--mm-color-background-emphasis)}.mm-listitem--opened>.mm-listitem__btn,.mm-listitem--opened>.mm-panel{background:var(--mm-color-background-highlight)}.mm-listview{list-style:none;display:block;padding:0;margin:0}.mm-menu{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;padding:0;margin:0;position:absolute;top:0;right:0;bottom:0;left:0;z-index:0;-ms-scroll-chaining:none;overscroll-behavior:none;background:var(--mm-color-background);border-color:var(--mm-color-border);color:var(--mm-color-text);line-height:var(--mm-lineheight);-webkit-tap-highlight-color:var(--mm-color-background-emphasis);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.mm-menu ::-webkit-input-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu ::-moz-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu :-ms-input-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu ::-ms-input-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu ::placeholder{color:var(--mm-color-text-dimmed)}.mm-menu,.mm-menu *{-webkit-box-sizing:border-box;box-sizing:border-box}.mm-menu :focus,.mm-menu :focus-visible,.mm-menu:focus,.mm-menu:focus-visible{outline:0}.mm-menu a,.mm-menu button,.mm-menu label{color:inherit}.mm-menu a:focus,.mm-menu button:focus,.mm-menu label:focus{outline:0}.mm-menu a:focus-visible,.mm-menu button:focus-visible,.mm-menu label:focus-visible{outline:2px solid var(--mm-color-focusring);outline-offset:-5px}.mm-menu input:focus,.mm-menu input:focus-visible,.mm-menu select:focus,.mm-menu select:focus-visible,.mm-menu textarea:focus,.mm-menu textarea:focus-visible{outline:2px solid var(--mm-color-focusring);outline-offset:2px}.mm-menu a,.mm-menu a:active,.mm-menu a:hover,.mm-menu a:link,.mm-menu a:visited{text-decoration:none;color:inherit}:root{--mm-navbar-size:50px}.mm-navbar{display:-webkit-box;display:-ms-flexbox;display:flex;position:-webkit-sticky;position:sticky;top:0;z-index:2;min-height:var(--mm-navbar-size);padding-top:env(safe-area-inset-top);color:var(--mm-color-text-dimmed);text-align:center;opacity:1;background:var(--mm-color-background);border-bottom:1px solid var(--mm-color-border);-webkit-transition-property:opacity;-o-transition-property:opacity;transition-property:opacity}.mm-navbar>*{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-sizing:border-box;box-sizing:border-box}.mm-navbar__btn{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0}.mm-navbar__title{-webkit-box-flex:1;-ms-flex:1 1 50%;flex:1 1 50%;display:-webkit-box;display:-ms-flexbox;display:flex;padding:0 20px;overflow:hidden}.mm-navbar__title[href="#"]{pointer-events:none}.mm-navbar__title>span{-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mm-btn.mm-hidden+.mm-navbar__title:not(:last-child){-webkit-padding-start:60px;padding-inline-start:60px;-webkit-padding-end:10px;padding-inline-end:10px}.mm-btn:not(.mm-hidden)+.mm-navbar__title:last-child{-webkit-padding-start:10px;padding-inline-start:10px;-webkit-padding-end:60px;padding-inline-end:60px}.mm-panel{--mm-panel-child-offset:100%;--mm-panel-parent-offset:-30%;visibility:hidden;position:absolute;left:0;right:0;top:0;bottom:0;z-index:1;-webkit-overflow-scrolling:touch;overflow:hidden;overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:contain;color:var(--mm-color-text);border-color:var(--mm-color-border);background:var(--mm-color-background);-webkit-transform:translate3d(var(--mm-panel-child-offset),0,0);transform:translate3d(var(--mm-panel-child-offset),0,0);-webkit-transition-property:visibility,inset-inline-start,-webkit-transform;transition-property:visibility,inset-inline-start,-webkit-transform;-o-transition-property:visibility,transform,inset-inline-start;transition-property:visibility,transform,inset-inline-start;transition-property:visibility,transform,inset-inline-start,-webkit-transform}[dir=rtl] .mm-panel{--mm-panel-child-offset:-100%;--mm-panel-parent-offset:30%}.mm-panel:after{content:"";display:block;height:var(--mm-listitem-size)}.mm-panel:focus{outline:0}.mm-panel--opened{visibility:visible;z-index:2;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);-webkit-transition-delay:0s;-o-transition-delay:0s;transition-delay:0s}.mm-panel--parent{-webkit-transform:translate3d(var(--mm-panel-parent-offset),0,0);transform:translate3d(var(--mm-panel-parent-offset),0,0);z-index:0}.mm-panel--highest{z-index:3}.mm-menu--opened .mm-panel--noanimation{-webkit-transition:none!important;-o-transition:none!important;transition:none!important;-webkit-transition-duration:0s!important;-o-transition-duration:0s!important;transition-duration:0s!important}.mm-panel__content{padding:20px}.mm-panels{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;position:relative;height:100%;overflow:hidden;background:var(--mm-color-background);border-color:var(--mm-color-border);color:var(--mm-color-text)}.mm-panels:focus{outline:0}:root{--mm-toggle-size:34px}.mm-toggle{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-item-align:center;align-self:center;-webkit-box-flex:calc((var(--mm-toggle-size) * 1.75));-ms-flex:calc((var(--mm-toggle-size) * 1.75)) 0 0px;flex:calc((var(--mm-toggle-size) * 1.75)) 0 0;height:var(--mm-toggle-size);-webkit-margin-end:10px;margin-inline-end:10px;-webkit-appearance:none!important;-moz-appearance:none!important;appearance:none!important;border:none!important;border-radius:var(--mm-toggle-size);border:var(--mm-color-border);background:var(--mm-color-border);cursor:pointer;-webkit-transition-property:background-color;-o-transition-property:background-color;transition-property:background-color}.mm-toggle:before{content:"";aspect-ratio:1;margin:2px;border-radius:100%;background:var(--mm-color-background);-webkit-transition:-webkit-transform .4s ease;transition:-webkit-transform .4s ease;-o-transition:transform .4s ease;transition:transform .4s ease;transition:transform .4s ease,-webkit-transform .4s ease}.mm-toggle:checked{background:#4bd963}.mm-toggle:checked:before{-webkit-transform:translateX(calc(var(--mm-toggle-size) * .75));-ms-transform:translateX(calc(var(--mm-toggle-size) * .75));transform:translateX(calc(var(--mm-toggle-size) * .75))}[dir=rtl] .mm-toggle:checked:before{-webkit-transform:translateX(calc(var(--mm-toggle-size) * -.75));-ms-transform:translateX(calc(var(--mm-toggle-size) * -.75));transform:translateX(calc(var(--mm-toggle-size) * -.75))}.mm-listitem--vertical>.mm-panel{position:static;width:100%;padding:10px 0 10px 20px;-webkit-transform:none!important;-ms-transform:none!important;transform:none!important;-webkit-transition:none!important;-o-transition:none!important;transition:none!important}.mm-listitem--vertical>.mm-panel:after{content:none;display:none}.mm-listitem--vertical:not(.mm-listitem--opened)>.mm-panel{display:none}.mm-listitem--vertical.mm-listitem--opened>.mm-panel{visibility:visible}.mm-listitem--vertical>.mm-listitem__btn{height:var(--mm-listitem-size);bottom:auto}.mm-listitem--vertical .mm-listitem:last-child:after{border-color:transparent}.mm-listitem--opened>.mm-listitem__btn:after{-webkit-transform:rotate(225deg);-ms-transform:rotate(225deg);transform:rotate(225deg);right:19px}:root{--mm-size:80%;--mm-min-size:240px;--mm-max-size:440px}.mm-menu--offcanvas{position:fixed;z-index:0;-webkit-transition-property:visibility;-o-transition-property:visibility;transition-property:visibility}.mm-menu--offcanvas:not(.mm-menu--opened){visibility:hidden;pointer-events:none}.mm-menu--offcanvas:not(.mm-menu--opened) *{visibility:inherit}.mm-page{-webkit-box-sizing:border-box;box-sizing:border-box;min-height:100vh;background:inherit}:where(.mm-slideout){position:relative;z-index:1;width:100%;-webkit-transition-duration:.4s;-o-transition-duration:.4s;transition-duration:.4s;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;-webkit-transition-property:width,-webkit-transform;transition-property:width,-webkit-transform;-o-transition-property:width,transform;transition-property:width,transform;transition-property:width,transform,-webkit-transform}.mm-wrapper--opened,.mm-wrapper--opened body{overflow:hidden}.mm-wrapper__blocker{background:#00000066}.mm-menu{--mm-translate-horizontal:0;--mm-translate-vertical:0}.mm-menu--position-left,.mm-menu--position-left-front{right:auto}.mm-menu--position-right,.mm-menu--position-right-front{left:auto}.mm-menu--position-left,.mm-menu--position-left-front,.mm-menu--position-right,.mm-menu--position-right-front{width:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-left-front{--mm-translate-horizontal:-100%}.mm-menu--position-right-front{--mm-translate-horizontal:100%}.mm-menu--position-top{bottom:auto}.mm-menu--position-bottom{top:auto}.mm-menu--position-bottom,.mm-menu--position-top{width:100%;height:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-top{--mm-translate-vertical:-100%}.mm-menu--position-bottom{--mm-translate-vertical:100%}.mm-menu--position-bottom,.mm-menu--position-left-front,.mm-menu--position-right-front,.mm-menu--position-top{z-index:2;-webkit-transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);-webkit-transition-property:visibility,-webkit-transform;transition-property:visibility,-webkit-transform;-o-transition-property:visibility,transform;transition-property:visibility,transform;transition-property:visibility,transform,-webkit-transform}.mm-menu--position-bottom.mm-menu--opened,.mm-menu--position-left-front.mm-menu--opened,.mm-menu--position-right-front.mm-menu--opened,.mm-menu--position-top.mm-menu--opened{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.mm-wrapper--position-left{--mm-translate-horizontal:clamp( + */:root{--mm-lineheight:22px}.mm-hidden{display:none!important}.mm-wrapper{overflow-x:hidden;position:relative}.mm-menu,.mm-menu *{-webkit-transition-property:none;-o-transition-property:none;transition-property:none;-webkit-transition-duration:.4s;-o-transition-duration:.4s;transition-duration:.4s;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.mm-blocker{--mm-blocker-visibility-delay:0.4s;--mm-blocker-opacity-delay:0s;display:block;position:absolute;bottom:100%;top:0;right:0;left:0;z-index:3;visibility:hidden;opacity:0;background:var(--mm-color-background);-webkit-transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),-webkit-transform .4s ease;transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),-webkit-transform .4s ease;-o-transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),transform .4s ease;transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),transform .4s ease;transition:visibility .4s ease,bottom 0s ease var(--mm-blocker-visibility-delay),width .4s ease,opacity .4s ease var(--mm-blocker-opacity-delay),transform .4s ease,-webkit-transform .4s ease}.mm-blocker--blocking{--mm-blocker-visibility-delay:0s;--mm-blocker-opacity-delay:0.4s;bottom:0;visibility:visible;opacity:.5;pointer-events:auto}.mm-blocker:focus-visible{opacity:.75}.mm-btn{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0;-ms-flex-negative:0;flex-shrink:0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;position:relative;width:50px;padding:0}.mm-btn--next,[dir=rtl] .mm-btn--prev{--mm-btn-rotate:135deg}.mm-btn--prev,[dir=rtl] .mm-btn--next{--mm-btn-rotate:-45deg}.mm-btn--next:after,.mm-btn--prev:before{content:"";display:block;position:absolute;top:0;bottom:0;width:8px;height:8px;margin:auto;-webkit-box-sizing:border-box;box-sizing:border-box;border:2px solid var(--mm-color-icon);border-bottom:none;border-right:none;-webkit-transform:rotate(var(--mm-btn-rotate));-ms-transform:rotate(var(--mm-btn-rotate));transform:rotate(var(--mm-btn-rotate))}.mm-btn--prev:before{inset-inline-start:23px}.mm-btn--next:after{inset-inline-end:23px}.mm-btn--close:before{content:"×";font-size:150%}.mm-btnreset{padding:0;background:0 0;border:none;cursor:pointer}.mm-divider{-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;position:-webkit-sticky;position:sticky;z-index:2;top:0;min-height:var(--mm-lineheight);padding:calc(((var(--mm-listitem-size) * .65) - var(--mm-lineheight)) * .5) 20px;font-size:75%;text-transform:uppercase;background:var(--mm-color-background);background-image:-webkit-gradient(linear,left top,left bottom,from(var(--mm-color-background-highlight)),to(var(--mm-color-background-highlight)));background-image:-o-linear-gradient(var(--mm-color-background-highlight),var(--mm-color-background-highlight));background-image:linear-gradient(var(--mm-color-background-highlight),var(--mm-color-background-highlight));opacity:1;-webkit-transition-property:opacity;-o-transition-property:opacity;transition-property:opacity}.mm-navbar:not(.mm-hidden)~.mm-listview .mm-divider{top:var(--mm-navbar-size)}:root{--mm-listitem-size:50px}.mm-listitem{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;position:relative;padding:0;margin:0;color:var(--mm-color-text);border-color:var(--mm-color-border)}.mm-listitem:after{content:"";border-color:inherit;border-bottom-width:1px;border-bottom-style:solid;display:block;position:absolute;inset-inline-start:20px;inset-inline-end:0;bottom:0}.mm-listitem__btn,.mm-listitem__text{padding:calc((var(--mm-listitem-size) - var(--mm-lineheight))/ 2) 0}.mm-listitem__text{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:10%;flex-basis:10%;display:block;padding-left:20px;padding-right:20px;-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mm-listitem__btn{display:block;position:relative;width:auto;-webkit-padding-end:50px;padding-inline-end:50px;border-color:inherit;background:rgba(3,2,1,0)}.mm-listitem__btn:not(.mm-listitem__text){border-left-width:1px;border-left-style:solid}.mm-listitem--selected>.mm-listitem__text{background:var(--mm-color-background-emphasis)}.mm-listitem--opened>.mm-listitem__btn,.mm-listitem--opened>.mm-panel{background:var(--mm-color-background-highlight)}.mm-listview{list-style:none;display:block;padding:0;margin:0}.mm-menu{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;padding:0;margin:0;position:absolute;top:0;right:0;bottom:0;left:0;z-index:0;-ms-scroll-chaining:none;overscroll-behavior:none;background:var(--mm-color-background);border-color:var(--mm-color-border);color:var(--mm-color-text);line-height:var(--mm-lineheight);-webkit-tap-highlight-color:var(--mm-color-background-emphasis);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.mm-menu ::-webkit-input-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu ::-moz-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu :-ms-input-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu ::-ms-input-placeholder{color:var(--mm-color-text-dimmed)}.mm-menu ::placeholder{color:var(--mm-color-text-dimmed)}.mm-menu,.mm-menu *{-webkit-box-sizing:border-box;box-sizing:border-box}.mm-menu :focus,.mm-menu :focus-visible,.mm-menu:focus,.mm-menu:focus-visible{outline:0}.mm-menu a,.mm-menu button,.mm-menu label{color:inherit}.mm-menu a:focus,.mm-menu button:focus,.mm-menu label:focus{outline:0}.mm-menu a:focus-visible,.mm-menu button:focus-visible,.mm-menu label:focus-visible{outline:2px solid var(--mm-color-focusring);outline-offset:-5px}.mm-menu input:focus,.mm-menu input:focus-visible,.mm-menu select:focus,.mm-menu select:focus-visible,.mm-menu textarea:focus,.mm-menu textarea:focus-visible{outline:2px solid var(--mm-color-focusring);outline-offset:2px}.mm-menu a,.mm-menu a:active,.mm-menu a:hover,.mm-menu a:link,.mm-menu a:visited{text-decoration:none;color:inherit}:root{--mm-navbar-size:50px}.mm-navbar{display:-webkit-box;display:-ms-flexbox;display:flex;position:-webkit-sticky;position:sticky;top:0;z-index:2;min-height:var(--mm-navbar-size);padding-top:env(safe-area-inset-top);color:var(--mm-color-text-dimmed);text-align:center;opacity:1;background:var(--mm-color-background);border-bottom:1px solid var(--mm-color-border);-webkit-transition-property:opacity;-o-transition-property:opacity;transition-property:opacity}.mm-navbar>*{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-sizing:border-box;box-sizing:border-box}.mm-navbar__btn{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0}.mm-navbar__title{-webkit-box-flex:1;-ms-flex:1 1 50%;flex:1 1 50%;display:-webkit-box;display:-ms-flexbox;display:flex;padding:0 20px;overflow:hidden}.mm-navbar__title[href="#"]{pointer-events:none}.mm-navbar__title>span{-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mm-btn.mm-hidden+.mm-navbar__title:not(:last-child){-webkit-padding-start:60px;padding-inline-start:60px;-webkit-padding-end:10px;padding-inline-end:10px}.mm-btn:not(.mm-hidden)+.mm-navbar__title:last-child{-webkit-padding-start:10px;padding-inline-start:10px;-webkit-padding-end:60px;padding-inline-end:60px}.mm-panel{--mm-panel-child-offset:100%;--mm-panel-parent-offset:-30%;visibility:hidden;position:absolute;left:0;right:0;top:0;bottom:0;z-index:1;-webkit-overflow-scrolling:touch;overflow:hidden;overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:contain;color:var(--mm-color-text);border-color:var(--mm-color-border);background:var(--mm-color-background);-webkit-transform:translate3d(var(--mm-panel-child-offset),0,0);transform:translate3d(var(--mm-panel-child-offset),0,0);-webkit-transition-property:visibility,inset-inline-start,-webkit-transform;transition-property:visibility,inset-inline-start,-webkit-transform;-o-transition-property:visibility,transform,inset-inline-start;transition-property:visibility,transform,inset-inline-start;transition-property:visibility,transform,inset-inline-start,-webkit-transform}[dir=rtl] .mm-panel{--mm-panel-child-offset:-100%;--mm-panel-parent-offset:30%}.mm-panel:after{content:"";display:block;height:var(--mm-listitem-size)}.mm-panel:focus{outline:0}.mm-panel--opened{visibility:visible;z-index:2;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);-webkit-transition-delay:0s;-o-transition-delay:0s;transition-delay:0s}.mm-panel--parent{-webkit-transform:translate3d(var(--mm-panel-parent-offset),0,0);transform:translate3d(var(--mm-panel-parent-offset),0,0);z-index:0}.mm-panel--highest{z-index:3}.mm-menu--opened .mm-panel--noanimation{-webkit-transition:none!important;-o-transition:none!important;transition:none!important;-webkit-transition-duration:0s!important;-o-transition-duration:0s!important;transition-duration:0s!important}.mm-panel__content{padding:20px}.mm-panels{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;position:relative;height:100%;overflow:hidden;background:var(--mm-color-background);border-color:var(--mm-color-border);color:var(--mm-color-text)}.mm-panels:focus{outline:0}:root{--mm-toggle-size:34px}.mm-toggle{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-item-align:center;align-self:center;-webkit-box-flex:calc((var(--mm-toggle-size) * 1.75));-ms-flex:calc((var(--mm-toggle-size) * 1.75)) 0 0px;flex:calc((var(--mm-toggle-size) * 1.75)) 0 0;height:var(--mm-toggle-size);-webkit-margin-end:10px;margin-inline-end:10px;-webkit-appearance:none!important;-moz-appearance:none!important;appearance:none!important;border:none!important;border-radius:var(--mm-toggle-size);border:var(--mm-color-border);background:var(--mm-color-border);cursor:pointer;-webkit-transition-property:background-color;-o-transition-property:background-color;transition-property:background-color}.mm-toggle:before{content:"";aspect-ratio:1;margin:2px;border-radius:100%;background:var(--mm-color-background);-webkit-transition:-webkit-transform .4s ease;transition:-webkit-transform .4s ease;-o-transition:transform .4s ease;transition:transform .4s ease;transition:transform .4s ease,-webkit-transform .4s ease}.mm-toggle:checked{background:#4bd963}.mm-toggle:checked:before{-webkit-transform:translateX(calc(var(--mm-toggle-size) * .75));-ms-transform:translateX(calc(var(--mm-toggle-size) * .75));transform:translateX(calc(var(--mm-toggle-size) * .75))}[dir=rtl] .mm-toggle:checked:before{-webkit-transform:translateX(calc(var(--mm-toggle-size) * -.75));-ms-transform:translateX(calc(var(--mm-toggle-size) * -.75));transform:translateX(calc(var(--mm-toggle-size) * -.75))}.mm-listitem--vertical>.mm-panel{position:static;width:100%;padding:10px 0 10px 20px;-webkit-transform:none!important;-ms-transform:none!important;transform:none!important;-webkit-transition:none!important;-o-transition:none!important;transition:none!important}.mm-listitem--vertical>.mm-panel:after{content:none;display:none}.mm-listitem--vertical:not(.mm-listitem--opened)>.mm-panel{display:none}.mm-listitem--vertical.mm-listitem--opened>.mm-panel{visibility:visible}.mm-listitem--vertical>.mm-listitem__btn{height:var(--mm-listitem-size);bottom:auto}.mm-listitem--vertical .mm-listitem:last-child:after{border-color:transparent}.mm-listitem--opened>.mm-listitem__btn:after{-webkit-transform:rotate(225deg);-ms-transform:rotate(225deg);transform:rotate(225deg);right:19px}:root{--mm-size:80%;--mm-min-size:240px;--mm-max-size:440px}.mm-menu--offcanvas{position:fixed;z-index:0;-webkit-transition-property:visibility 0s linear .4s;-o-transition-property:visibility 0s linear .4s;transition-property:visibility 0s linear .4s}.mm-menu--offcanvas.mm-menu--opened{-webkit-transition-delay:0s;-o-transition-delay:0s;transition-delay:0s}.mm-menu--offcanvas:not(.mm-menu--opened){visibility:hidden;pointer-events:none}.mm-menu--offcanvas:not(.mm-menu--opened) *{visibility:inherit}.mm-page{-webkit-box-sizing:border-box;box-sizing:border-box;min-height:100vh;background:inherit}:where(.mm-slideout){position:relative;z-index:1;width:100%;-webkit-transition-duration:.4s;-o-transition-duration:.4s;transition-duration:.4s;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;-webkit-transition-property:width,-webkit-transform;transition-property:width,-webkit-transform;-o-transition-property:width,transform;transition-property:width,transform;transition-property:width,transform,-webkit-transform}.mm-wrapper--opened,.mm-wrapper--opened body{overflow:hidden}.mm-wrapper__blocker{background:#00000066}.mm-menu{--mm-translate-horizontal:0;--mm-translate-vertical:0}.mm-menu--position-left,.mm-menu--position-left-front{right:auto}.mm-menu--position-right,.mm-menu--position-right-front{left:auto}.mm-menu--position-left,.mm-menu--position-left-front,.mm-menu--position-right,.mm-menu--position-right-front{width:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-left-front{--mm-translate-horizontal:-100%}.mm-menu--position-right-front{--mm-translate-horizontal:100%}.mm-menu--position-top{bottom:auto}.mm-menu--position-bottom{top:auto}.mm-menu--position-bottom,.mm-menu--position-top{width:100%;height:clamp(var(--mm-min-size),var(--mm-size),var(--mm-max-size))}.mm-menu--position-top{--mm-translate-vertical:-100%}.mm-menu--position-bottom{--mm-translate-vertical:100%}.mm-menu--position-bottom,.mm-menu--position-left-front,.mm-menu--position-right-front,.mm-menu--position-top{z-index:2;-webkit-transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);transform:translate3d(var(--mm-translate-horizontal),var(--mm-translate-vertical),0);-webkit-transition-property:visibility,-webkit-transform;transition-property:visibility,-webkit-transform;-o-transition-property:visibility,transform;transition-property:visibility,transform;transition-property:visibility,transform,-webkit-transform}.mm-menu--position-bottom.mm-menu--opened,.mm-menu--position-left-front.mm-menu--opened,.mm-menu--position-right-front.mm-menu--opened,.mm-menu--position-top.mm-menu--opened{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.mm-wrapper--position-left{--mm-translate-horizontal:clamp( var(--mm-min-size), var(--mm-size), var(--mm-max-size) diff --git a/dist/mmenu.js b/dist/mmenu.js index 8e0fad35..d77cd0e9 100644 --- a/dist/mmenu.js +++ b/dist/mmenu.js @@ -1,4 +1,4 @@ -!function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var s={hooks:{},navbar:{add:!0,title:"Menu",titleLink:"parent"},slidingSubmenus:!0};var i={classNames:{divider:"Divider",nolistview:"NoListview",nopanel:"NoPanel",panel:"Panel",selected:"Selected",vertical:"Vertical"},language:null,panelNodetype:["ul","ol","div"],screenReader:{closeSubmenu:"Close submenu",openSubmenu:"Open submenu",toggleSubmenu:"Toggle submenu"}};const a=(e,t)=>{"object"!=o(e)&&(e={}),"object"!=o(t)&&(t={});for(let n in t)t.hasOwnProperty(n)&&(void 0===e[n]?e[n]=t[n]:"object"==o(e[n])&&a(e[n],t[n]));return e},o=e=>({}.toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase()),r=()=>"mm-"+l++;let l=0;const m=e=>"mm-clone-"==e.slice(0,9)?e:"mm-clone-"+e,c=e=>"mm-clone-"==e.slice(0,9)?e.slice(9):e,d={},h=(e,t)=>{void 0===d[t]&&(d[t]={}),a(d[t],e)};var p={"Close submenu":"بستن زیرمنو",Menu:"منو","Open submenu":"بازکردن زیرمنو","Toggle submenu":"سوییچ زیرمنو"},u={"Close submenu":"Submenu sluiten",Menu:"Menu","Open submenu":"Submenu openen","Toggle submenu":"Submenu wisselen"},f={"Close submenu":"Fechar submenu",Menu:"Menu","Open submenu":"Abrir submenu","Toggle submenu":"Alternar submenu"},b={"Close submenu":"Закрыть подменю",Menu:"Меню","Open submenu":"Открыть подменю","Toggle submenu":"Переключить подменю"},v={"Close submenu":"Zatvoriť submenu",Menu:"Menu","Open submenu":"Otvoriť submenu","Toggle submenu":"Prepnúť submenu"};const g=e=>{const t=e.split("."),n=document.createElement(t.shift());return n.classList.add(...t),n},L=(e,t)=>t.length?[].slice.call(e.querySelectorAll(t)):[],_=(e,t)=>{const n=Array.prototype.slice.call(e.children);return t?n.filter(e=>e.matches(t)):n},E=e=>e.filter(e=>!e.matches(".mm-hidden")),w=e=>{let t=[];return E(e).forEach(e=>{t.push(..._(e,"a.mm-listitem__text"))}),t.filter(e=>!e.matches(".mm-btn--next"))},y=(e,t,n)=>{e.matches("."+t)&&e.classList.add(n)};let P={};const S=(e,t,n)=>{"number"==typeof e&&(e="(min-width: "+e+"px)"),P[e]=P[e]||[],P[e].push({yes:t,no:n})},k=(e,t)=>{var n=t.matches?"yes":"no";for(let t=0;t{for(let e in P){let t=window.matchMedia(e);k(e,t),t.onchange=n=>{k(e,t)}}})(),this.trigger("init:after"),this}openPanel(e,t=!0,n=!0){if(e){if(e.matches(".mm-panel")||(e=e.closest(".mm-panel")),this.trigger("openPanel:before",[e,{animation:t,setfocus:n}]),e.parentElement.matches(".mm-listitem--vertical"))e.parentElement.classList.add("mm-listitem--opened");else{const s=_(this.node.pnls,".mm-panel--opened")[0];e.matches(".mm-panel--parent")&&s&&s.classList.add("mm-panel--highest");const i=["mm-panel--opened","mm-panel--parent"],a=[];t?i.push("mm-panel--noanimation"):a.push("mm-panel--noanimation"),_(this.node.pnls,".mm-panel").forEach(e=>{e.classList.add(...a),e.classList.remove(...i),e!==s&&e.classList.remove("mm-panel--highest")}),e.classList.add("mm-panel--opened");let o=L(this.node.pnls,"#"+e.dataset.mmParent)[0];for(;o;)o=o.closest(".mm-panel"),o.classList.add("mm-panel--parent"),o=L(this.node.pnls,"#"+o.dataset.mmParent)[0];n&&this.node.pnls.focus()}this.trigger("openPanel:after",[e,{animation:t,setfocus:n}])}}closePanel(e,t=!0,n=!0){if(e&&(e.matches(".mm-panel--opened")||e.parentElement.matches(".mm-listitem--opened"))){if(this.trigger("closePanel:before",[e]),e.parentElement.matches(".mm-listitem--vertical"))e.parentElement.classList.remove("mm-listitem--opened");else if(e.dataset.mmParent){const s=L(this.node.pnls,"#"+e.dataset.mmParent)[0];this.openPanel(s,t,n)}else{const s=_(this.node.pnls,".mm-panel--parent").pop();if(s&&s!==e)this.openPanel(s,t,n);else{const s=_(this.node.pnls,".mm-panel")[0];s&&s!==e&&this.openPanel(s,t,n)}}this.trigger("closePanel:after",[e])}}togglePanel(e){let t="openPanel";(e.parentElement.matches(".mm-listitem--opened")||e.matches(".mm-panel--opened"))&&(t="closePanel"),this[t](e)}setSelected(e){this.trigger("setSelected:before",[e]),L(this.node.menu,".mm-listitem--selected").forEach(e=>{e.classList.remove("mm-listitem--selected")}),e.classList.add("mm-listitem--selected"),this.trigger("setSelected:after",[e])}bind(e,t){this.hook[e]=this.hook[e]||[],this.hook[e].push(t)}trigger(e,t){if(this.hook[e])for(var n=0,s=this.hook[e].length;n{e.forEach(e=>{e.addedNodes.forEach(e=>{e.matches(this.conf.panelNodetype.join(", "))&&this._initListview(e)})})})),C(this,x,new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{this._initListitem(e)})})})),C(this,T,new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{(null==e?void 0:e.matches(this.conf.panelNodetype.join(", ")))&&this._initSubPanel(e)})})}))}_initAPI(){const e=this;this.API={},this._api.forEach(t=>{this.API[t]=function(){return e[t].apply(e,arguments)}}),this.node.menu.mmApi=this.API}_initHooks(){for(let e in this.opts.hooks)this.bind(e,this.opts.hooks[e])}_initAddons(){this.trigger("initAddons:before");for(let e in O.addons)O.addons[e].call(this);this.trigger("initAddons:after")}_initMenu(){this.trigger("initMenu:before"),this.node.wrpr=this.node.wrpr||this.node.menu.parentElement,this.node.wrpr.classList.add("mm-wrapper"),this.node.menu.classList.add("mm-menu"),this.node.menu.id=this.node.menu.id||r(),this.node.menu.setAttribute("tabindex","-1");const e=_(this.node.menu).filter(e=>e.matches(this.conf.panelNodetype.join(", ")));this.node.pnls=g("div.mm-panels"),this.node.menu.append(this.node.pnls),this.node.pnls.setAttribute("tabindex","-1"),e.forEach(e=>{this._initPanel(e)}),this.trigger("initMenu:after")}_initPanels(){this.trigger("initPanels:before"),this.node.menu.addEventListener("click",e=>{var t,n;const s=(null===(n=null===(t=e.target)||void 0===t?void 0:t.closest("a[href]"))||void 0===n?void 0:n.getAttribute("href"))||"";if("#"===s.slice(0,1))try{const t=L(this.node.menu,s)[0];t&&(e.preventDefault(),this.togglePanel(t))}catch(e){}},{capture:!0}),this.trigger("initPanels:after")}_initPanel(e){var t;if(!e.matches(".mm-panel")&&(y(e,this.conf.classNames.panel,"mm-panel"),y(e,this.conf.classNames.nopanel,"mm-nopanel"),!e.matches(".mm-nopanel"))){if(this.trigger("initPanel:before",[e]),e.id=e.id||r(),e.matches("ul, ol")){const t=g("div");t.id=e.id,e.removeAttribute("id"),[].slice.call(e.classList).filter(e=>"mm-"===e.slice(0,3)).forEach(n=>{t.classList.add(n),e.classList.remove(n)}),Object.keys(e.dataset).filter(e=>"mm"===e.slice(0,2)).forEach(n=>{t.dataset[n]=e.dataset[n],delete e.dataset[n]}),e.before(t),t.append(e),e=t}return e.classList.add("mm-panel"),(null===(t=e.parentElement)||void 0===t?void 0:t.matches(".mm-listitem--vertical"))||this.node.pnls.append(e),this._initNavbar(e),_(e,"ul, ol").forEach(e=>{this._initListview(e)}),N(this,M).observe(e,{childList:!0}),this.trigger("initPanel:after",[e]),e}}_initNavbar(e){if(_(e,".mm-navbar").length)return;let t=null,n=null;if(e.dataset.mmParent)for(t=L(this.node.pnls,"#"+e.dataset.mmParent)[0],n=t.closest(".mm-panel");n.closest(".mm-listitem--vertical");)n=n.parentElement.closest(".mm-panel");if(null==t?void 0:t.matches(".mm-listitem--vertical"))return;this.trigger("initNavbar:before",[e]);const s=g("div.mm-navbar");if(this.opts.navbar.add||s.classList.add("mm-hidden"),n){const e=g("a.mm-btn.mm-btn--prev.mm-navbar__btn");e.href="#"+n.id,e.title=this.i18n(this.conf.screenReader.closeSubmenu),s.append(e)}let i=null;t?i=_(t,".mm-listitem__text")[0]:n&&(i=L(n,'a[href="#'+e.id+'"]')[0]);const a=g("a.mm-navbar__title");switch(a.tabIndex=-1,a.ariaHidden="true",this.opts.navbar.titleLink){case"anchor":i&&(a.href=i.getAttribute("href"));break;case"parent":n&&(a.href="#"+n.id)}const o=g("span");var r;o.innerHTML=e.dataset.mmTitle||((r=i)?[].slice.call(r.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.nodeValue.trim()).join(" "):"")||this.i18n(this.opts.navbar.title)||this.i18n("Menu"),e.prepend(s),s.append(a),a.append(o),this.trigger("initNavbar:after",[e])}_initListview(e){["htmlulistelement","htmlolistelement"].includes(o(e))&&(e.matches(".mm-listview")||(y(e,this.conf.classNames.nolistview,"mm-nolistview"),e.matches(".mm-nolistview")||(this.trigger("initListview:before",[e]),e.classList.add("mm-listview"),_(e).forEach(e=>{this._initListitem(e)}),N(this,x).observe(e,{childList:!0}),this.trigger("initListview:after",[e]))))}_initListitem(e){["htmllielement"].includes(o(e))&&(e.matches(".mm-listitem")||(y(e,this.conf.classNames.divider,"mm-divider"),e.matches(".mm-divider")||(this.trigger("initListitem:before",[e]),e.classList.add("mm-listitem"),y(e,this.conf.classNames.selected,"mm-listitem--selected"),_(e,"a, span").forEach(e=>{e.classList.add("mm-listitem__text")}),_(e,this.conf.panelNodetype.join(", ")).forEach(e=>{this._initSubPanel(e)}),N(this,T).observe(e,{childList:!0}),this.trigger("initListitem:after",[e]))))}_initSubPanel(e){if(e.matches(".mm-panel"))return;const t=e.parentElement;(e.matches("."+this.conf.classNames.vertical)||!this.opts.slidingSubmenus)&&t.classList.add("mm-listitem--vertical"),t.id=t.id||r(),e.id=e.id||r(),t.dataset.mmChild=e.id,e.dataset.mmParent=t.id;let n=_(t,".mm-btn")[0];n||(n=g("a.mm-btn.mm-btn--next.mm-listitem__btn"),_(t,"a, span").forEach(e=>{e.matches("span")?(n.classList.add("mm-listitem__text"),n.innerHTML=e.innerHTML,t.insertBefore(n,e.nextElementSibling),e.remove()):t.insertBefore(n,e.nextElementSibling)}),n.title=this.i18n(this.conf.screenReader[t.matches(".mm-listitem--vertical")?"toggleSubmenu":"openSubmenu"])),n.href="#"+e.id,this._initPanel(e)}_initOpened(){this.trigger("initOpened:before");const e=L(this.node.pnls,".mm-listitem--selected").pop();let t=_(this.node.pnls,".mm-panel")[0];e&&(this.setSelected(e),t=e.closest(".mm-panel")),this.openPanel(t,!1,!1),this.trigger("initOpened:after")}i18n(e){return((e,t)=>"string"==typeof t&&void 0!==d[t]&&d[t][e]||e)(e,this.conf.language)}static i18n(e={},t=""){if(!e||!t)return d;h(e,t)}}M=new WeakMap,x=new WeakMap,T=new WeakMap,O.addons={},O.node={},O.vars={};var A={use:!0,position:"left"};var j={clone:!1,menu:{insertMethod:"prepend",insertSelector:"body"},page:{nodetype:"div",selector:null,noSelector:[]},screenReader:{closeMenu:"Close menu",openMenu:"Open menu"}};O.prototype.open=function(){if(!this.node.menu.matches(".mm-menu--opened")){this.trigger("open:before");this.node.wrpr.classList.add("mm-wrapper--opened"),this.node.menu.classList.add("mm-menu--opened"),this.node.wrpr.classList.add("mm-wrapper--opened"),O.node.blck.classList.add("mm-blocker--blocking"),this.node.menu.focus(),this.trigger("open:after")}},O.prototype.close=function(){var e;if(!this.node.menu.matches(".mm-menu--opened"))return;this.trigger("close:before"),this.node.menu.classList.remove("mm-menu--opened"),this.node.wrpr.classList.remove("mm-wrapper--opened"),O.node.blck.classList.remove("mm-blocker--blocking");null===(e=document.querySelector(`[href="#${this.node.menu.id}"]`)||this.node.page||null)||void 0===e||e.focus(),this.trigger("close:after")},O.prototype.setPage=function(e){var t=this.conf.offCanvas;if(!e){let n="string"==typeof t.page.selector?L(document.body,t.page.selector):_(document.body,t.page.nodetype);if(n=n.filter(e=>!e.matches(".mm-menu, .mm-wrapper__blocker")),t.page.noSelector.length&&(n=n.filter(e=>!e.matches(t.page.noSelector.join(", ")))),n.length>1){let e=g("div");n[0].before(e),n.forEach(t=>{e.append(t)}),n=[e]}e=n[0]}this.trigger("setPage:before",[e]),e.setAttribute("tabindex","-1"),e.classList.add("mm-page","mm-slideout"),e.id=e.id||r(),O.node.blck.setAttribute("href","#"+e.id),O.node.page=e,this.trigger("setPage:after",[e])};var H={fix:!0};const I="ontouchstart"in window||!!navigator.msMaxTouchPoints||!1;var q={close:!1,open:!1};var R={add:!1};var B={use:!1,top:[],bottom:[],position:"left",type:"default"};var D={add:!1,blockPanel:!0,visible:3};var F={breadcrumbs:{separator:"/",removeFirst:!1}};function $(){this.opts.navbars=this.opts.navbars||[],this.conf.navbars=this.conf.navbars||{},a(this.conf.navbars,F);let e=this.opts.navbars;if(void 0!==e&&(e instanceof Array||(e=[e]),e.length)){var t={};e.forEach(e=>{if(!(e=function(e){return"boolean"==typeof e&&e&&(e={}),"object"!=typeof e&&(e={}),void 0===e.content&&(e.content=["prev","title"]),e.content instanceof Array||(e.content=[e.content]),void 0===e.use&&(e.use=!0),e}(e)).use)return;const n=g("div.mm-navbar");let{position:s}=e;"bottom"!==s&&(s="top"),t[s]||(t[s]=g("div.mm-navbars.mm-navbars--"+s)),t[s].append(n);for(let t=0,s=e.content.length;t{n.classList.remove("mm-hidden")},a=()=>{n.classList.add("mm-hidden")};"boolean"==typeof e.use?this.bind("initMenu:after",i):S(e.use,i,a)}),this.bind("initMenu:after",()=>{for(let e in t)this.node.pnls["bottom"==e?"after":"before"](t[e])})}}$.navbarContents={breadcrumbs:function(e){var t=g("div.mm-navbar__breadcrumbs");e.append(t),this.bind("initNavbar:after",e=>{if(!e.querySelector(".mm-navbar__breadcrumbs")){_(e,".mm-navbar")[0].classList.add("mm-hidden");for(var t=[],n=g("span.mm-navbar__breadcrumbs"),s=e,i=!0;s;){if(!(s=s.closest(".mm-panel")).parentElement.matches(".mm-listitem--vertical")){let e=L(s,".mm-navbar__title span")[0];if(e){let n=e.textContent;n.length&&t.unshift(i?`${n}`:`${n}`)}i=!1}s=L(this.node.pnls,"#"+s.dataset.mmParent)[0]}this.conf.navbars.breadcrumbs.removeFirst&&t.shift(),n.innerHTML=t.join(''+this.conf.navbars.breadcrumbs.separator+""),_(e,".mm-navbar")[0].append(n)}}),this.bind("openPanel:before",e=>{var n=e.querySelector(".mm-navbar__breadcrumbs");t.innerHTML=n?n.innerHTML:""})},close:function(e){const t=g("a.mm-btn.mm-btn--close.mm-navbar__btn");t.title=this.i18n(this.conf.offCanvas.screenReader.closeMenu),e.append(t),this.bind("setPage:after",e=>{t.href="#"+e.id})},prev:function(e){let t=g("a.mm-btn.mm-hidden");e.append(t),this.bind("initNavbar:after",e=>{_(e,".mm-navbar")[0].classList.add("mm-hidden")}),this.bind("openPanel:before",e=>{if(e.parentElement.matches(".mm-listitem--vertical"))return;t.classList.add("mm-hidden");const n=e.querySelector(".mm-navbar__btn.mm-btn--prev");if(n){const e=n.cloneNode(!0);t.after(e),t.remove(),t=e}})},searchfield:function(e){let t=g("div.mm-navbar__searchfield");t.id=r(),e.append(t),this.opts.searchfield=this.opts.searchfield||{},this.opts.searchfield.add=!0,this.opts.searchfield.addTo="#"+t.id},title:function(e){let t=g("a.mm-navbar__title");e.append(t),this.bind("openPanel:before",e=>{if(e.parentElement.matches(".mm-listitem--vertical"))return;const n=e.querySelector(".mm-navbar__title");if(n){const e=n.cloneNode(!0);t.after(e),t.remove(),t=e}})}},$.navbarTypes={tabs:function(e){function t(n){const s=_(e,`.mm-navbar__tab[href="#${n.id}"]`)[0];if(s)s.classList.add("mm-navbar__tab--selected"),s.ariaExpanded="true";else{const e=L(this.node.pnls,"#"+n.dataset.mmParent)[0];e&&t.call(this,e.closest(".mm-panel"))}}e.classList.add("mm-navbar--tabs"),e.closest(".mm-navbars").classList.add("mm-navbars--has-tabs"),_(e,"a").forEach(e=>{e.classList.add("mm-navbar__tab")}),this.bind("openPanel:before",n=>{_(e,"a").forEach(e=>{e.classList.remove("mm-navbar__tab--selected"),e.ariaExpanded="false"}),t.call(this,n)}),this.bind("initPanels:after",()=>{e.addEventListener("click",e=>{var t,n,s;const i=null===(n=null===(t=e.target)||void 0===t?void 0:t.closest(".mm-navbar__tab"))||void 0===n?void 0:n.getAttribute("href");try{null===(s=L(this.node.pnls,i+".mm-panel")[0])||void 0===s||s.classList.add("mm-panel--noanimation")}catch(e){}},{capture:!0})})}};var Z={scroll:!1,update:!1};var W={scrollOffset:0,updateOffset:50};var z={add:!1,addTo:"panels",noResults:"No results found.",placeholder:"Search",searchIn:"panels",splash:"",title:"Search"};var V={cancel:!0,clear:!0,form:{},input:{},panel:{},submit:!1},U={cancel:"انصراف","Cancel searching":"لغو جستجو","Clear searchfield":"پاک کردن فیلد جستجو","No results found.":"نتیجه‌ای یافت نشد.",Search:"جستجو"},Y={cancel:"annuleren","Cancel searching":"Zoeken annuleren","Clear searchfield":"Zoekveld leeg maken","No results found.":"Geen resultaten gevonden.",Search:"Zoeken"},K={cancel:"cancelar","Cancel searching":"Cancelar pesquisa","Clear searchfield":"Limpar campo de pesquisa","No results found.":"Nenhum resultado encontrado.",Search:"Buscar"},G={cancel:"отменить","Cancel searching":"Отменить поиск","Clear searchfield":"Очистить поле поиска","No results found.":"Ничего не найдено.",Search:"Найти"},X={cancel:"zrušiť","Cancel searching":"Zrušiť vyhľadávanie","Clear searchfield":"Vymazať pole vyhľadávania","No results found.":"Neboli nájdené žiadne výsledky.",Search:"Vyhľadávanie"};h({cancel:"abbrechen","Cancel searching":"Suche abbrechen","Clear searchfield":"Suchfeld löschen","No results found.":"Keine Ergebnisse gefunden.",Search:"Suche"},"de"),h(U,"fa"),h(Y,"nl"),h(K,"pt_br"),h(G,"ru"),h(X,"sk");const J=function(){const e=this.opts.searchfield,t=this.conf.searchfield;let n=_(this.node.pnls,".mm-panel--search")[0];return n||(n=g("div.mm-panel--search"),oe(n,t.panel),e.title.length&&(n.dataset.mmTitle=this.i18n(e.title)),n.append(g("ul")),this._initPanel(n),n)},Q=function(e){const t=this.opts.searchfield;if(e.matches(t.addTo)){const t=e.matches(".mm-panel--search");if(!L(e,".mm-searchfield").length){const n=ee.call(this,t);t&&n.classList.add("mm-searchfield--cancelable"),e.prepend(n),te.call(this,n)}}if(t.splash.length&&e.matches(".mm-panel--search")&&!L(e,".mm-panel__splash").length){const n=g("div.mm-panel__splash");n.innerHTML=t.splash,e.append(n)}if(t.noResults.length&&!L(e,".mm-panel__noresults").length){const n=g("div.mm-panel__noresults");n.innerHTML=this.i18n(t.noResults),e.append(n)}},ee=function(e=!1){const t=this.opts.searchfield,n=this.conf.searchfield,s=g("form.mm-searchfield");oe(s,n.form);const i=g("div.mm-searchfield__input");s.append(i);const a=g("input");if(i.append(a),a.type="text",a.autocomplete="off",a.placeholder=this.i18n(t.placeholder),a.setAttribute("aria-label",this.i18n(t.placeholder)),oe(a,n.input),n.submit){const e=g("button.mm-btnreset.mm-btn.mm-btn--next.mm-searchfield__btn");e.type="submit",i.append(e)}else if(n.clear){const e=g("button.mm-btnreset.mm-btn.mm-btn--close.mm-searchfield__btn");e.type="reset",e.title=this.i18n("Clear searchfield"),i.append(e),s.addEventListener("reset",()=>{window.requestAnimationFrame(()=>{a.dispatchEvent(new Event("input"))})})}if(n.cancel&&e){const e=g("a.mm-searchfield__cancel");e.href="#",e.title=this.i18n("Cancel searching"),e.textContent=this.i18n("cancel"),s.append(e),e.addEventListener("click",e=>{e.preventDefault(),this.closePanel(_(this.node.pnls,".mm-panel--search")[0],!1)})}return s},te=function(e){const t=this.opts.searchfield,n=e.closest(".mm-panel")||L(this.node.pnls,".mm-panel--search")[0],s=L(e,"input")[0];let i=n.matches(".mm-panel--search")?L(this.node.pnls,t.searchIn):[n];i=i.filter(e=>!e.matches(".mm-panel--search"));const a=()=>{const a=s.value.toLowerCase().trim(),o=[];if(i.forEach(e=>{e.scrollTop=0,o.push(...L(e,".mm-listitem"))}),a.length){this.trigger("search:before"),e.classList.add("mm-searchfield--searching"),n.classList.add("mm-panel--searching"),o.forEach(e=>{const t=_(e,".mm-listitem__text")[0];var n;(!t||(n=t,Array.prototype.slice.call(n.childNodes).filter(e=>3==e.nodeType).map(e=>e.textContent).join(" ")).toLowerCase().indexOf(a)>-1)&&(e.dataset.mmSearchresult=a)});let t=0;t=n.matches(".mm-panel--search")?ne(n,a,i):ie(a,i),n.classList[0==t?"add":"remove"]("mm-panel--noresults"),this.trigger("search:after")}else this.trigger("clear:before"),e.classList.remove("mm-searchfield--searching"),n.classList.remove("mm-panel--searching","mm-panel--noresults"),n.matches(".mm-panel--search")?(se(n),t.splash||this.closePanel(n,!1,!1)):ae(i),this.trigger("clear:after")};s.addEventListener("input",a),a()},ne=(e,t,n)=>{const s=L(e,".mm-listview")[0];s.innerHTML="";let i=0;return n.forEach(e=>{const n=L(e,`[data-mm-searchresult="${t}"]`);if(i+=n.length,n.length){const t=L(e,".mm-navbar__title")[0];if(t){const e=g("li.mm-divider");e.innerHTML=t.innerHTML,s.append(e)}n.forEach(e=>{s.append(e.cloneNode(!0))})}}),i},se=e=>{L(e,".mm-listview")[0].innerHTML=""},ie=(e,t)=>{let n=0;return t.forEach(t=>{const s=L(t,`[data-mm-searchresult="${e}"]`);n+=s.length,s.length&&s.forEach(t=>{const n=((e,t)=>{let n=[],s=e.previousElementSibling;for(;s;)t&&!s.matches(t)||n.push(s),s=s.previousElementSibling;return n})(t,".mm-divider")[0];n&&(n.dataset.mmSearchresult=e)}),L(t,".mm-listitem, .mm-divider").forEach(t=>{t.classList[t.dataset.mmSearchresult===e?"remove":"add"]("mm-hidden")})}),n},ae=e=>{e.forEach(e=>{L(e,".mm-listitem, .mm-divider").forEach(e=>{e.classList.remove("mm-hidden")})})},oe=(e,t)=>{t&&Object.keys(t).forEach(n=>{e[n]=t[n]})};var re={add:!1,addTo:"panels"};var le={current:!0,hover:!1,parent:!1};var me={collapsed:{use:!1,blockMenu:!0},expanded:{use:!1,initial:"open"}}; +!function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var s={hooks:{},navbar:{add:!0,title:"Menu",titleLink:"parent"},slidingSubmenus:!0};var i={classNames:{divider:"Divider",nolistview:"NoListview",nopanel:"NoPanel",panel:"Panel",selected:"Selected",vertical:"Vertical"},language:null,panelNodetype:["ul","ol","div"],screenReader:{closeSubmenu:"Close submenu",openSubmenu:"Open submenu",toggleSubmenu:"Toggle submenu"}};const a=(e,t)=>{"object"!=o(e)&&(e={}),"object"!=o(t)&&(t={});for(let n in t)t.hasOwnProperty(n)&&(void 0===e[n]?e[n]=t[n]:"object"==o(e[n])&&a(e[n],t[n]));return e},o=e=>({}.toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase()),r=()=>"mm-"+l++;let l=0;const m=e=>"mm-clone-"==e.slice(0,9)?e:"mm-clone-"+e,c=e=>"mm-clone-"==e.slice(0,9)?e.slice(9):e,d={},h=(e,t)=>{void 0===d[t]&&(d[t]={}),a(d[t],e)};var p={"Close submenu":"بستن زیرمنو",Menu:"منو","Open submenu":"بازکردن زیرمنو","Toggle submenu":"سوییچ زیرمنو"},u={"Close submenu":"Submenu sluiten",Menu:"Menu","Open submenu":"Submenu openen","Toggle submenu":"Submenu wisselen"},f={"Close submenu":"Fechar submenu",Menu:"Menu","Open submenu":"Abrir submenu","Toggle submenu":"Alternar submenu"},b={"Close submenu":"Закрыть подменю",Menu:"Меню","Open submenu":"Открыть подменю","Toggle submenu":"Переключить подменю"},v={"Close submenu":"Zatvoriť submenu",Menu:"Menu","Open submenu":"Otvoriť submenu","Toggle submenu":"Prepnúť submenu"};const g=e=>{const t=e.split("."),n=document.createElement(t.shift());return n.classList.add(...t),n},L=(e,t)=>t.length?[].slice.call(e.querySelectorAll(t)):[],_=(e,t)=>{const n=Array.prototype.slice.call(e.children);return t?n.filter(e=>e.matches(t)):n},E=e=>e.filter(e=>!e.matches(".mm-hidden")),w=e=>{let t=[];return E(e).forEach(e=>{t.push(..._(e,"a.mm-listitem__text"))}),t.filter(e=>!e.matches(".mm-btn--next"))},y=(e,t,n)=>{e.matches("."+t)&&e.classList.add(n)};let P={};const S=(e,t,n)=>{"number"==typeof e&&(e="(min-width: "+e+"px)"),P[e]=P[e]||[],P[e].push({yes:t,no:n})},k=(e,t)=>{var n=t.matches?"yes":"no";for(let t=0;t{for(let e in P){let t=window.matchMedia(e);k(e,t),t.onchange=n=>{k(e,t)}}})(),this.trigger("init:after"),this}openPanel(e,t=!0,n=!0){if(e){if(e.matches(".mm-panel")||(e=e.closest(".mm-panel")),this.trigger("openPanel:before",[e,{animation:t,setfocus:n}]),e.parentElement.matches(".mm-listitem--vertical"))e.parentElement.classList.add("mm-listitem--opened");else{const s=_(this.node.pnls,".mm-panel--opened")[0];e.matches(".mm-panel--parent")&&s&&s.classList.add("mm-panel--highest");const i=["mm-panel--opened","mm-panel--parent"],a=[];t?i.push("mm-panel--noanimation"):a.push("mm-panel--noanimation"),_(this.node.pnls,".mm-panel").forEach(e=>{e.classList.add(...a),e.classList.remove(...i),e!==s&&e.classList.remove("mm-panel--highest")}),e.classList.add("mm-panel--opened");let o=L(this.node.pnls,"#"+e.dataset.mmParent)[0];for(;o;)o=o.closest(".mm-panel"),o.classList.add("mm-panel--parent"),o=L(this.node.pnls,"#"+o.dataset.mmParent)[0];n&&this.node.pnls.focus()}this.trigger("openPanel:after",[e,{animation:t,setfocus:n}])}}closePanel(e,t=!0,n=!0){if(e&&(e.matches(".mm-panel--opened")||e.parentElement.matches(".mm-listitem--opened"))){if(this.trigger("closePanel:before",[e]),e.parentElement.matches(".mm-listitem--vertical"))e.parentElement.classList.remove("mm-listitem--opened");else if(e.dataset.mmParent){const s=L(this.node.pnls,"#"+e.dataset.mmParent)[0];this.openPanel(s,t,n)}else{const s=_(this.node.pnls,".mm-panel--parent").pop();if(s&&s!==e)this.openPanel(s,t,n);else{const s=_(this.node.pnls,".mm-panel")[0];s&&s!==e&&this.openPanel(s,t,n)}}this.trigger("closePanel:after",[e])}}togglePanel(e){let t="openPanel";(e.parentElement.matches(".mm-listitem--opened")||e.matches(".mm-panel--opened"))&&(t="closePanel"),this[t](e)}setSelected(e){this.trigger("setSelected:before",[e]),L(this.node.menu,".mm-listitem--selected").forEach(e=>{e.classList.remove("mm-listitem--selected")}),e.classList.add("mm-listitem--selected"),this.trigger("setSelected:after",[e])}bind(e,t){this.hook[e]=this.hook[e]||[],this.hook[e].push(t)}trigger(e,t){if(this.hook[e])for(var n=0,s=this.hook[e].length;n{e.forEach(e=>{e.addedNodes.forEach(e=>{e.matches(this.conf.panelNodetype.join(", "))&&this._initListview(e)})})})),C(this,x,new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{this._initListitem(e)})})})),C(this,T,new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{(null==e?void 0:e.matches(this.conf.panelNodetype.join(", ")))&&this._initSubPanel(e)})})}))}_initAPI(){const e=this;this.API={},this._api.forEach(t=>{this.API[t]=function(){return e[t].apply(e,arguments)}}),this.node.menu.mmApi=this.API}_initHooks(){for(let e in this.opts.hooks)this.bind(e,this.opts.hooks[e])}_initAddons(){this.trigger("initAddons:before");for(let e in O.addons)O.addons[e].call(this);this.trigger("initAddons:after")}_initMenu(){this.trigger("initMenu:before"),this.node.wrpr=this.node.wrpr||this.node.menu.parentElement,this.node.wrpr.classList.add("mm-wrapper"),this.node.menu.classList.add("mm-menu"),this.node.menu.id=this.node.menu.id||r(),this.node.menu.setAttribute("tabindex","-1");const e=_(this.node.menu).filter(e=>e.matches(this.conf.panelNodetype.join(", ")));this.node.pnls=g("div.mm-panels"),this.node.menu.append(this.node.pnls),this.node.pnls.setAttribute("tabindex","-1"),e.forEach(e=>{this._initPanel(e)}),this.trigger("initMenu:after")}_initPanels(){this.trigger("initPanels:before"),this.node.menu.addEventListener("click",e=>{var t,n;const s=(null===(n=null===(t=e.target)||void 0===t?void 0:t.closest("a[href]"))||void 0===n?void 0:n.getAttribute("href"))||"";if("#"===s.slice(0,1))try{const t=L(this.node.menu,s)[0];t&&(e.preventDefault(),this.togglePanel(t))}catch(e){}},{capture:!0}),this.trigger("initPanels:after")}_initPanel(e){var t;if(!e.matches(".mm-panel")&&(y(e,this.conf.classNames.panel,"mm-panel"),y(e,this.conf.classNames.nopanel,"mm-nopanel"),!e.matches(".mm-nopanel"))){if(this.trigger("initPanel:before",[e]),e.id=e.id||r(),e.matches("ul, ol")){const t=g("div");t.id=e.id,e.removeAttribute("id"),[].slice.call(e.classList).filter(e=>"mm-"===e.slice(0,3)).forEach(n=>{t.classList.add(n),e.classList.remove(n)}),Object.keys(e.dataset).filter(e=>"mm"===e.slice(0,2)).forEach(n=>{t.dataset[n]=e.dataset[n],delete e.dataset[n]}),e.before(t),t.append(e),e=t}return e.classList.add("mm-panel"),(null===(t=e.parentElement)||void 0===t?void 0:t.matches(".mm-listitem--vertical"))||this.node.pnls.append(e),this._initNavbar(e),_(e,"ul, ol").forEach(e=>{this._initListview(e)}),N(this,M).observe(e,{childList:!0}),this.trigger("initPanel:after",[e]),e}}_initNavbar(e){if(_(e,".mm-navbar").length)return;let t=null,n=null;if(e.dataset.mmParent)for(t=L(this.node.pnls,"#"+e.dataset.mmParent)[0],n=t.closest(".mm-panel");n.closest(".mm-listitem--vertical");)n=n.parentElement.closest(".mm-panel");if(null==t?void 0:t.matches(".mm-listitem--vertical"))return;this.trigger("initNavbar:before",[e]);const s=g("div.mm-navbar");if(this.opts.navbar.add||s.classList.add("mm-hidden"),n){const e=g("a.mm-btn.mm-btn--prev.mm-navbar__btn");e.href="#"+n.id,e.title=this.i18n(this.conf.screenReader.closeSubmenu),s.append(e)}let i=null;t?i=_(t,".mm-listitem__text")[0]:n&&(i=L(n,'a[href="#'+e.id+'"]')[0]);const a=g("a.mm-navbar__title");switch(a.tabIndex=-1,a.ariaHidden="true",this.opts.navbar.titleLink){case"anchor":i&&(a.href=i.getAttribute("href"));break;case"parent":n&&(a.href="#"+n.id)}const o=g("span");var r;o.innerHTML=e.dataset.mmTitle||((r=i)?[].slice.call(r.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.nodeValue.trim()).join(" "):"")||this.i18n(this.opts.navbar.title)||this.i18n("Menu"),e.prepend(s),s.append(a),a.append(o),this.trigger("initNavbar:after",[e])}_initListview(e){["htmlulistelement","htmlolistelement"].includes(o(e))&&(e.matches(".mm-listview")||(y(e,this.conf.classNames.nolistview,"mm-nolistview"),e.matches(".mm-nolistview")||(this.trigger("initListview:before",[e]),e.classList.add("mm-listview"),_(e).forEach(e=>{this._initListitem(e)}),N(this,x).observe(e,{childList:!0}),this.trigger("initListview:after",[e]))))}_initListitem(e){["htmllielement"].includes(o(e))&&(e.matches(".mm-listitem")||(y(e,this.conf.classNames.divider,"mm-divider"),e.matches(".mm-divider")||(this.trigger("initListitem:before",[e]),e.classList.add("mm-listitem"),y(e,this.conf.classNames.selected,"mm-listitem--selected"),_(e,"a, span").forEach(e=>{e.classList.add("mm-listitem__text")}),_(e,this.conf.panelNodetype.join(", ")).forEach(e=>{this._initSubPanel(e)}),N(this,T).observe(e,{childList:!0}),this.trigger("initListitem:after",[e]))))}_initSubPanel(e){if(e.matches(".mm-panel"))return;const t=e.parentElement;(e.matches("."+this.conf.classNames.vertical)||!this.opts.slidingSubmenus)&&t.classList.add("mm-listitem--vertical"),t.id=t.id||r(),e.id=e.id||r(),t.dataset.mmChild=e.id,e.dataset.mmParent=t.id;let n=_(t,".mm-btn")[0];n||(n=g("a.mm-btn.mm-btn--next.mm-listitem__btn"),_(t,"a, span").forEach(e=>{e.matches("span")?(n.classList.add("mm-listitem__text"),n.innerHTML=e.innerHTML,t.insertBefore(n,e.nextElementSibling),e.remove()):t.insertBefore(n,e.nextElementSibling)}),n.title=this.i18n(this.conf.screenReader[t.matches(".mm-listitem--vertical")?"toggleSubmenu":"openSubmenu"])),n.href="#"+e.id,this._initPanel(e)}_initOpened(){this.trigger("initOpened:before");const e=L(this.node.pnls,".mm-listitem--selected").pop();let t=_(this.node.pnls,".mm-panel")[0];e&&(this.setSelected(e),t=e.closest(".mm-panel")),this.openPanel(t,!1,!1),this.trigger("initOpened:after")}i18n(e){return((e,t)=>"string"==typeof t&&void 0!==d[t]&&d[t][e]||e)(e,this.conf.language)}static i18n(e={},t=""){if(!e||!t)return d;h(e,t)}}M=new WeakMap,x=new WeakMap,T=new WeakMap,O.addons={},O.node={},O.vars={};var A={use:!0,position:"left"};var j={clone:!1,menu:{insertMethod:"prepend",insertSelector:"body"},page:{nodetype:"div",selector:null,noSelector:[]},screenReader:{closeMenu:"Close menu",openMenu:"Open menu"}};O.prototype.open=function(){this.node.menu.matches(".mm-menu--opened")||(this.trigger("open:before"),this.node.menu.classList.add("mm-menu--opened"),this.node.wrpr.classList.add("mm-wrapper--opened"),O.node.blck.classList.add("mm-blocker--blocking"),this.node.open=document.activeElement,this.node.menu.focus(),this.trigger("open:after"))},O.prototype.close=function(){var e;if(!this.node.menu.matches(".mm-menu--opened"))return;this.trigger("close:before"),this.node.menu.classList.remove("mm-menu--opened"),this.node.wrpr.classList.remove("mm-wrapper--opened"),O.node.blck.classList.remove("mm-blocker--blocking");null===(e=this.node.open||document.querySelector(`[href="#${this.node.menu.id}"]`)||this.node.page||null)||void 0===e||e.focus(),this.trigger("close:after")},O.prototype.setPage=function(e){var t=this.conf.offCanvas;if(!e){let n="string"==typeof t.page.selector?L(document.body,t.page.selector):_(document.body,t.page.nodetype);if(n=n.filter(e=>!e.matches(".mm-menu, .mm-wrapper__blocker")),t.page.noSelector.length&&(n=n.filter(e=>!e.matches(t.page.noSelector.join(", ")))),n.length>1){let e=g("div");n[0].before(e),n.forEach(t=>{e.append(t)}),n=[e]}e=n[0]}this.trigger("setPage:before",[e]),e.setAttribute("tabindex","-1"),e.classList.add("mm-page","mm-slideout"),e.id=e.id||r(),O.node.blck.setAttribute("href","#"+e.id),O.node.page=e,this.trigger("setPage:after",[e])};var H={fix:!0};const I="ontouchstart"in window||!!navigator.msMaxTouchPoints||!1;var q={close:!1,open:!1};var R={add:!1};var B={use:!1,top:[],bottom:[],position:"left",type:"default"};var D={add:!1,blockPanel:!0,visible:3};var F={breadcrumbs:{separator:"/",removeFirst:!1}};function $(){this.opts.navbars=this.opts.navbars||[],this.conf.navbars=this.conf.navbars||{},a(this.conf.navbars,F);let e=this.opts.navbars;if(void 0!==e&&(e instanceof Array||(e=[e]),e.length)){var t={};e.forEach(e=>{if(!(e=function(e){return"boolean"==typeof e&&e&&(e={}),"object"!=typeof e&&(e={}),void 0===e.content&&(e.content=["prev","title"]),e.content instanceof Array||(e.content=[e.content]),void 0===e.use&&(e.use=!0),e}(e)).use)return;const n=g("div.mm-navbar");let{position:s}=e;"bottom"!==s&&(s="top"),t[s]||(t[s]=g("div.mm-navbars.mm-navbars--"+s)),t[s].append(n);for(let t=0,s=e.content.length;t{n.classList.remove("mm-hidden")},a=()=>{n.classList.add("mm-hidden")};"boolean"==typeof e.use?this.bind("initMenu:after",i):S(e.use,i,a)}),this.bind("initMenu:after",()=>{for(let e in t)this.node.pnls["bottom"==e?"after":"before"](t[e])})}}$.navbarContents={breadcrumbs:function(e){var t=g("div.mm-navbar__breadcrumbs");e.append(t),this.bind("initNavbar:after",e=>{if(!e.querySelector(".mm-navbar__breadcrumbs")){_(e,".mm-navbar")[0].classList.add("mm-hidden");for(var t=[],n=g("span.mm-navbar__breadcrumbs"),s=e,i=!0;s;){if(!(s=s.closest(".mm-panel")).parentElement.matches(".mm-listitem--vertical")){let e=L(s,".mm-navbar__title span")[0];if(e){let n=e.textContent;n.length&&t.unshift(i?`${n}`:`${n}`)}i=!1}s=L(this.node.pnls,"#"+s.dataset.mmParent)[0]}this.conf.navbars.breadcrumbs.removeFirst&&t.shift(),n.innerHTML=t.join(''+this.conf.navbars.breadcrumbs.separator+""),_(e,".mm-navbar")[0].append(n)}}),this.bind("openPanel:before",e=>{var n=e.querySelector(".mm-navbar__breadcrumbs");t.innerHTML=n?n.innerHTML:""})},close:function(e){const t=g("a.mm-btn.mm-btn--close.mm-navbar__btn");t.title=this.i18n(this.conf.offCanvas.screenReader.closeMenu),e.append(t),this.bind("setPage:after",e=>{t.href="#"+e.id})},prev:function(e){let t=g("a.mm-btn.mm-hidden");e.append(t),this.bind("initNavbar:after",e=>{_(e,".mm-navbar")[0].classList.add("mm-hidden")}),this.bind("openPanel:before",e=>{if(e.parentElement.matches(".mm-listitem--vertical"))return;t.classList.add("mm-hidden");const n=e.querySelector(".mm-navbar__btn.mm-btn--prev");if(n){const e=n.cloneNode(!0);t.after(e),t.remove(),t=e}})},searchfield:function(e){let t=g("div.mm-navbar__searchfield");t.id=r(),e.append(t),this.opts.searchfield=this.opts.searchfield||{},this.opts.searchfield.add=!0,this.opts.searchfield.addTo="#"+t.id},title:function(e){let t=g("a.mm-navbar__title");e.append(t),this.bind("openPanel:before",e=>{if(e.parentElement.matches(".mm-listitem--vertical"))return;const n=e.querySelector(".mm-navbar__title");if(n){const e=n.cloneNode(!0);t.after(e),t.remove(),t=e}})}},$.navbarTypes={tabs:function(e){function t(n){const s=_(e,`.mm-navbar__tab[href="#${n.id}"]`)[0];if(s)s.classList.add("mm-navbar__tab--selected"),s.ariaExpanded="true";else{const e=L(this.node.pnls,"#"+n.dataset.mmParent)[0];e&&t.call(this,e.closest(".mm-panel"))}}e.classList.add("mm-navbar--tabs"),e.closest(".mm-navbars").classList.add("mm-navbars--has-tabs"),_(e,"a").forEach(e=>{e.classList.add("mm-navbar__tab")}),this.bind("openPanel:before",n=>{_(e,"a").forEach(e=>{e.classList.remove("mm-navbar__tab--selected"),e.ariaExpanded="false"}),t.call(this,n)}),this.bind("initPanels:after",()=>{e.addEventListener("click",e=>{var t,n,s;const i=null===(n=null===(t=e.target)||void 0===t?void 0:t.closest(".mm-navbar__tab"))||void 0===n?void 0:n.getAttribute("href");try{null===(s=L(this.node.pnls,i+".mm-panel")[0])||void 0===s||s.classList.add("mm-panel--noanimation")}catch(e){}},{capture:!0})})}};var Z={scroll:!1,update:!1};var W={scrollOffset:0,updateOffset:50};var z={add:!1,addTo:"panels",noResults:"No results found.",placeholder:"Search",searchIn:"panels",splash:"",title:"Search"};var V={cancel:!0,clear:!0,form:{},input:{},panel:{},submit:!1},U={cancel:"انصراف","Cancel searching":"لغو جستجو","Clear searchfield":"پاک کردن فیلد جستجو","No results found.":"نتیجه‌ای یافت نشد.",Search:"جستجو"},Y={cancel:"annuleren","Cancel searching":"Zoeken annuleren","Clear searchfield":"Zoekveld leeg maken","No results found.":"Geen resultaten gevonden.",Search:"Zoeken"},K={cancel:"cancelar","Cancel searching":"Cancelar pesquisa","Clear searchfield":"Limpar campo de pesquisa","No results found.":"Nenhum resultado encontrado.",Search:"Buscar"},G={cancel:"отменить","Cancel searching":"Отменить поиск","Clear searchfield":"Очистить поле поиска","No results found.":"Ничего не найдено.",Search:"Найти"},X={cancel:"zrušiť","Cancel searching":"Zrušiť vyhľadávanie","Clear searchfield":"Vymazať pole vyhľadávania","No results found.":"Neboli nájdené žiadne výsledky.",Search:"Vyhľadávanie"};h({cancel:"abbrechen","Cancel searching":"Suche abbrechen","Clear searchfield":"Suchfeld löschen","No results found.":"Keine Ergebnisse gefunden.",Search:"Suche"},"de"),h(U,"fa"),h(Y,"nl"),h(K,"pt_br"),h(G,"ru"),h(X,"sk");const J=function(){const e=this.opts.searchfield,t=this.conf.searchfield;let n=_(this.node.pnls,".mm-panel--search")[0];return n||(n=g("div.mm-panel--search"),oe(n,t.panel),e.title.length&&(n.dataset.mmTitle=this.i18n(e.title)),n.append(g("ul")),this._initPanel(n),n)},Q=function(e){const t=this.opts.searchfield;if(e.matches(t.addTo)){const t=e.matches(".mm-panel--search");if(!L(e,".mm-searchfield").length){const n=ee.call(this,t);t&&n.classList.add("mm-searchfield--cancelable"),e.prepend(n),te.call(this,n)}}if(t.splash.length&&e.matches(".mm-panel--search")&&!L(e,".mm-panel__splash").length){const n=g("div.mm-panel__splash");n.innerHTML=t.splash,e.append(n)}if(t.noResults.length&&!L(e,".mm-panel__noresults").length){const n=g("div.mm-panel__noresults");n.innerHTML=this.i18n(t.noResults),e.append(n)}},ee=function(e=!1){const t=this.opts.searchfield,n=this.conf.searchfield,s=g("form.mm-searchfield");oe(s,n.form);const i=g("div.mm-searchfield__input");s.append(i);const a=g("input");if(i.append(a),a.type="text",a.autocomplete="off",a.placeholder=this.i18n(t.placeholder),a.setAttribute("aria-label",this.i18n(t.placeholder)),oe(a,n.input),n.submit){const e=g("button.mm-btnreset.mm-btn.mm-btn--next.mm-searchfield__btn");e.type="submit",i.append(e)}else if(n.clear){const e=g("button.mm-btnreset.mm-btn.mm-btn--close.mm-searchfield__btn");e.type="reset",e.title=this.i18n("Clear searchfield"),i.append(e),s.addEventListener("reset",()=>{window.requestAnimationFrame(()=>{a.dispatchEvent(new Event("input"))})})}if(n.cancel&&e){const e=g("a.mm-searchfield__cancel");e.href="#",e.title=this.i18n("Cancel searching"),e.textContent=this.i18n("cancel"),s.append(e),e.addEventListener("click",e=>{e.preventDefault(),this.closePanel(_(this.node.pnls,".mm-panel--search")[0],!1)})}return s},te=function(e){const t=this.opts.searchfield,n=e.closest(".mm-panel")||L(this.node.pnls,".mm-panel--search")[0],s=L(e,"input")[0];let i=n.matches(".mm-panel--search")?L(this.node.pnls,t.searchIn):[n];i=i.filter(e=>!e.matches(".mm-panel--search"));const a=()=>{const a=s.value.toLowerCase().trim(),o=[];if(i.forEach(e=>{e.scrollTop=0,o.push(...L(e,".mm-listitem"))}),a.length){this.trigger("search:before"),e.classList.add("mm-searchfield--searching"),n.classList.add("mm-panel--searching"),o.forEach(e=>{const t=_(e,".mm-listitem__text")[0];var n;(!t||(n=t,Array.prototype.slice.call(n.childNodes).filter(e=>3==e.nodeType).map(e=>e.textContent).join(" ")).toLowerCase().indexOf(a)>-1)&&(e.dataset.mmSearchresult=a)});let t=0;t=n.matches(".mm-panel--search")?ne(n,a,i):ie(a,i),n.classList[0==t?"add":"remove"]("mm-panel--noresults"),this.trigger("search:after")}else this.trigger("clear:before"),e.classList.remove("mm-searchfield--searching"),n.classList.remove("mm-panel--searching","mm-panel--noresults"),n.matches(".mm-panel--search")?(se(n),t.splash||this.closePanel(n,!1,!1)):ae(i),this.trigger("clear:after")};s.addEventListener("input",a),a()},ne=(e,t,n)=>{const s=L(e,".mm-listview")[0];s.innerHTML="";let i=0;return n.forEach(e=>{const n=L(e,`[data-mm-searchresult="${t}"]`);if(i+=n.length,n.length){const t=L(e,".mm-navbar__title")[0];if(t){const e=g("li.mm-divider");e.innerHTML=t.innerHTML,s.append(e)}n.forEach(e=>{s.append(e.cloneNode(!0))})}}),i},se=e=>{L(e,".mm-listview")[0].innerHTML=""},ie=(e,t)=>{let n=0;return t.forEach(t=>{const s=L(t,`[data-mm-searchresult="${e}"]`);n+=s.length,s.length&&s.forEach(t=>{const n=((e,t)=>{let n=[],s=e.previousElementSibling;for(;s;)t&&!s.matches(t)||n.push(s),s=s.previousElementSibling;return n})(t,".mm-divider")[0];n&&(n.dataset.mmSearchresult=e)}),L(t,".mm-listitem, .mm-divider").forEach(t=>{t.classList[t.dataset.mmSearchresult===e?"remove":"add"]("mm-hidden")})}),n},ae=e=>{e.forEach(e=>{L(e,".mm-listitem, .mm-divider").forEach(e=>{e.classList.remove("mm-hidden")})})},oe=(e,t)=>{t&&Object.keys(t).forEach(n=>{e[n]=t[n]})};var re={add:!1,addTo:"panels"};var le={current:!0,hover:!1,parent:!1};var me={collapsed:{use:!1,blockMenu:!0},expanded:{use:!1,initial:"open"}}; /*! * mmenu.js * mmenujs.com diff --git a/package-lock.json b/package-lock.json index 4d7086f9..bd1bff9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mmenu-js", - "version": "9.1.2", + "version": "9.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9243e82d..7c2eb6b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mmenu-js", - "version": "9.1.2", + "version": "9.1.3", "main": "dist/mmenu.js", "module": "src/mmenu.js", "author": "Fred Heusschen ", diff --git a/src/core/offcanvas/mmenu.offcanvas.scss b/src/core/offcanvas/mmenu.offcanvas.scss index cb0095d8..7e3eb5d6 100644 --- a/src/core/offcanvas/mmenu.offcanvas.scss +++ b/src/core/offcanvas/mmenu.offcanvas.scss @@ -10,11 +10,11 @@ .mm-menu--offcanvas { position: fixed; z-index: 0; - transition-property: visibility;// 0s linear variables.$mm_transitionDuration; xxx + transition-property: visibility 0s linear variables.$mm_transitionDuration; - // &.mm-menu--opened { - // transition-delay: 0s; xxx - // } + &.mm-menu--opened { + transition-delay: 0s; + } &:not(.mm-menu--opened) { visibility: hidden; diff --git a/src/core/offcanvas/mmenu.offcanvas.ts b/src/core/offcanvas/mmenu.offcanvas.ts index 11d7d572..5116470d 100644 --- a/src/core/offcanvas/mmenu.offcanvas.ts +++ b/src/core/offcanvas/mmenu.offcanvas.ts @@ -154,16 +154,13 @@ Mmenu.prototype.open = function (this: Mmenu) { // Invoke "before" hook. this.trigger('open:before'); - var clsn = ['mm-wrapper--opened']; - - this.node.wrpr.classList.add(...clsn); - // Open this.node.menu.classList.add('mm-menu--opened'); this.node.wrpr.classList.add('mm-wrapper--opened'); Mmenu.node.blck.classList.add('mm-blocker--blocking'); // Focus the menu. + this.node.open = document.activeElement as HTMLElement; this.node.menu.focus(); // Invoke "after" hook. @@ -183,7 +180,7 @@ Mmenu.prototype.close = function (this: Mmenu) { Mmenu.node.blck.classList.remove('mm-blocker--blocking'); // Focus opening link or page. - const focus = document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null; + const focus = this.node.open || document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null; (focus as HTMLElement)?.focus(); // Invoke "after" hook.