!function(e){var t="offCanvas";e.mmenu.addons[t]={setup:function(){if(this.opts[t]){var n=this.opts[t],s=this.conf[t];i=e.mmenu.glbl,this._api=e.merge(this._api,["open","close","setPage"]),"top"!=n.position&&"bottom"!=n.position||(n.zposition="front"),"string"!=typeof s.pageSelector&&(s.pageSelector="> "+s.pageNodetype),i.$allMenus=(i.$allMenus||e()).add(this.$menu),this.vars.opened=!1;var a=[o.offcanvas];"left"!=n.position&&a.push(o.mm(n.position)),"back"!=n.zposition&&a.push(o.mm(n.zposition)),this.$menu.addClass(a.join(" ")).parent().removeClass(o.wrapper),this.setPage(i.$page),this._initBlocker(),this["_initWindow_"+t](),this.$menu[s.menuInjectMethod+"To"](s.menuWrapperSelector)}},add:function(){o=e.mmenu._c,n=e.mmenu._d,s=e.mmenu._e,o.add("offcanvas slideout blocking modal background opening blocker page"),n.add("style"),s.add("resize")},clickAnchor:function(e,n){if(!this.opts[t])return!1;var s=this.$menu.attr("id");if(s&&s.length&&(this.conf.clone&&(s=o.umm(s)),e.is('[href="#'+s+'"]')))return this.open(),!0;if(i.$page){var s=i.$page.first().attr("id");return!!(s&&s.length&&e.is('[href="#'+s+'"]'))&&(this.close(),!0)}}},e.mmenu.defaults[t]={position:"left",zposition:"back",blockUI:!0,moveBackground:!0},e.mmenu.configuration[t]={pageNodetype:"div",pageSelector:null,noPageSelector:[],wrapPageIfNeeded:!0,menuWrapperSelector:"body",menuInjectMethod:"prepend"},e.mmenu.prototype.open=function(){if(!this.vars.opened){var e=this;this._openSetup(),setTimeout(function(){e._openFinish()},this.conf.openingInterval),this.trigger("open")}},e.mmenu.prototype._openSetup=function(){var a=this,r=this.opts[t];this.closeAllOthers(),i.$page.each(function(){e(this).data(n.style,e(this).attr("style")||"")}),i.$wndw.trigger(s.resize+"-"+t,[!0]);var p=[o.opened];r.blockUI&&p.push(o.blocking),"modal"==r.blockUI&&p.push(o.modal),r.moveBackground&&p.push(o.background),"left"!=r.position&&p.push(o.mm(this.opts[t].position)),"back"!=r.zposition&&p.push(o.mm(this.opts[t].zposition)),this.opts.extensions&&p.push(this.opts.extensions),i.$html.addClass(p.join(" ")),setTimeout(function(){a.vars.opened=!0},this.conf.openingInterval),this.$menu.addClass(o.current+" "+o.opened)},e.mmenu.prototype._openFinish=function(){var e=this;this.__transitionend(i.$page.first(),function(){e.trigger("opened")},this.conf.transitionDuration),i.$html.addClass(o.opening),this.trigger("opening")},e.mmenu.prototype.close=function(){if(this.vars.opened){var s=this;this.__transitionend(i.$page.first(),function(){s.$menu.removeClass(o.current).removeClass(o.opened),i.$html.removeClass(o.opened).removeClass(o.blocking).removeClass(o.modal).removeClass(o.background).removeClass(o.mm(s.opts[t].position)).removeClass(o.mm(s.opts[t].zposition)),s.opts.extensions&&i.$html.removeClass(s.opts.extensions),i.$page.each(function(){e(this).attr("style",e(this).data(n.style))}),s.vars.opened=!1,s.trigger("closed")},this.conf.transitionDuration),i.$html.removeClass(o.opening),this.trigger("close"),this.trigger("closing")}},e.mmenu.prototype.closeAllOthers=function(){i.$allMenus.not(this.$menu).each(function(){var t=e(this).data("mmenu");t&&t.close&&t.close()})},e.mmenu.prototype.setPage=function(n){var s=this,a=this.conf[t];n&&n.length||(n=i.$body.find(a.pageSelector),a.noPageSelector.length&&(n=n.not(a.noPageSelector.join(", "))),n.length>1&&a.wrapPageIfNeeded&&(n=n.wrapAll("<"+this.conf[t].pageNodetype+" />").parent())),n.each(function(){e(this).attr("id",e(this).attr("id")||s.__getUniqueId())}),n.addClass(o.page+" "+o.slideout),i.$page=n,this.trigger("setPage",n)},e.mmenu.prototype["_initWindow_"+t]=function(){i.$wndw.off(s.keydown+"-"+t).on(s.keydown+"-"+t,function(e){if(i.$html.hasClass(o.opened)&&9==e.keyCode)return e.preventDefault(),!1});var e=0;i.$wndw.off(s.resize+"-"+t).on(s.resize+"-"+t,function(t,n){if(1==i.$page.length&&(n||i.$html.hasClass(o.opened))){var s=i.$wndw.height();(n||s!=e)&&(e=s,i.$page.css("minHeight",s))}})},e.mmenu.prototype._initBlocker=function(){var n=this;this.opts[t].blockUI&&(i.$blck||(i.$blck=e('
')),i.$blck.appendTo(i.$body).off(s.touchstart+"-"+t+" "+s.touchmove+"-"+t).on(s.touchstart+"-"+t+" "+s.touchmove+"-"+t,function(e){e.preventDefault(),e.stopPropagation(),i.$blck.trigger(s.mousedown+"-"+t)}).off(s.mousedown+"-"+t).on(s.mousedown+"-"+t,function(e){e.preventDefault(),i.$html.hasClass(o.modal)||(n.closeAllOthers(),n.close())}))};var o,n,s,i}(jQuery);