!function(n,i,e){"use strict";var t=i.modernizr,s=n("body");n.dlmenu=function(i,e){this.$el=n(e),this._init(i)},n.dlmenu.defaults={animationclasses:{classin:"dl-animate-in-1",classout:"dl-animate-out-1"},onlevelclick:function(n,i){return!1},onlinkclick:function(n,i){return!1}},n.dlmenu.prototype={_init:function(i){this.options=n.extend(!0,{},n.dlmenu.defaults,i),this._config();var e={webkitanimation:"webkitanimationend",oanimation:"oanimationend",msanimation:"msanimationend",animation:"animationend"},s={webkittransition:"webkittransitionend",moztransition:"transitionend",otransition:"otransitionend",mstransition:"mstransitionend",transition:"transitionend"};this.animendeventname=e[t.prefixed("animation")]+".dlmenu",this.transendeventname=s[t.prefixed("transition")]+".dlmenu",this.supportanimations=t.cssanimations,this.supporttransitions=t.csstransitions,this._initevents()},_config:function(){this.open=!1,this.$trigger=this.$el.children(".dl-trigger"),this.$menu=this.$el.children("ul.dl-menu"),this.$menuitems=this.$menu.find("li:not(.dl-back)"),this.$el.find("ul.dl-submenu").prepend('
返回'),this.$back=this.$menu.find("li.dl-back")},_initevents:function(){var i=this;this.$trigger.on("click.dlmenu",function(){return i.open?i._closemenu():i._openmenu(),!1}),this.$menuitems.on("click.dlmenu",function(e){e.stoppropagation();var t=n(this),s=t.children("ul.dl-submenu");if(s.length>0){var o=s.clone().css("opacity",0).insertafter(i.$menu),a=function(){i.$menu.off(i.animendeventname).removeclass(i.options.animationclasses.classout).addclass("dl-subview"),t.addclass("dl-subviewopen").parents(".dl-subviewopen:first").removeclass("dl-subviewopen").addclass("dl-subview"),o.remove()};return settimeout(function(){o.addclass(i.options.animationclasses.classin),i.$menu.addclass(i.options.animationclasses.classout),i.supportanimations?i.$menu.on(i.animendeventname,a):a.call(),i.options.onlevelclick(t,t.children("a:first").text())}),!1}i.options.onlinkclick(t,e)}),this.$back.on("click.dlmenu",function(e){var t=n(this),s=t.parents("ul.dl-submenu:first"),o=s.parent(),a=s.clone().insertafter(i.$menu),l=function(){i.$menu.off(i.animendeventname).removeclass(i.options.animationclasses.classin),a.remove()};return settimeout(function(){a.addclass(i.options.animationclasses.classout),i.$menu.addclass(i.options.animationclasses.classin),i.supportanimations?i.$menu.on(i.animendeventname,l):l.call(),o.removeclass("dl-subviewopen");var n=t.parents(".dl-subview:first");n.is("li")&&n.addclass("dl-subviewopen"),n.removeclass("dl-subview")}),!1})},closemenu:function(){this.open&&this._closemenu()},_closemenu:function(){var n=this,i=function(){n.$menu.off(n.transendeventname),n._resetmenu()};this.$menu.removeclass("dl-menuopen"),this.$menu.addclass("dl-menu-toggle"),this.$trigger.removeclass("dl-active"),this.supporttransitions?this.$menu.on(this.transendeventname,i):i.call(),this.open=!1},openmenu:function(){this.open||this._openmenu()},_openmenu:function(){var i=this;s.off("click").on("click.dlmenu",function(){i._closemenu()}),this.$menu.addclass("dl-menuopen dl-menu-toggle").on(this.transendeventname,function(){n(this).removeclass("dl-menu-toggle")}),this.$trigger.addclass("dl-active"),this.open=!0},_resetmenu:function(){this.$menu.removeclass("dl-subview"),this.$menuitems.removeclass("dl-subview dl-subviewopen")}};var o=function(n){i.console&&i.console.error(n)};n.fn.dlmenu=function(i){if("string"==typeof i){var e=array.prototype.slice.call(arguments,1);this.each(function(){var t=n.data(this,"dlmenu");return t?n.isfunction(t[i])&&"_"!==i.charat(0)?void t[i].apply(t,e):void o("no such method '"+i+"' for dlmenu instance"):void o("cannot call methods on dlmenu prior to initialization; attempted to call method '"+i+"'")})}else this.each(function(){var e=n.data(this,"dlmenu");e?e._init():e=n.data(this,"dlmenu",new n.dlmenu(i,this))});return this}}(jquery,window);