/**
 * jquery.dlmenu.js v1.0.1
 * http://www.codrops.com
 *
 * Licensed under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2013, Codrops
 * http://www.codrops.com
 */

 /* EDITED BY THEMERELLA */

!function(n,i,t){"use strict";var e=i.Modernizr,s=n("body");n.DLMenu=function(i,t){this.$el=n(t),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},backLabel:"Back",useActiveItemAsBackLabel:!1,useActiveItemAsLink:!1,resetOnClose:!0},n.DLMenu.prototype={_init:function(i){this.options=n.extend(!0,{},n.DLMenu.defaults,i),this._config();var t={WebkitAnimation:"webkitAnimationEnd",OAnimation:"oAnimationEnd",msAnimation:"MSAnimationEnd",animation:"animationend"},s={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"};this.animEndEventName=t[e.prefixed("animation")]+".dlmenu",this.transEndEventName=s[e.prefixed("transition")]+".dlmenu",this.supportAnimations=e.cssanimations,this.supportTransitions=e.csstransitions,this._initEvents()},_config:function(){this.open=!1,this.$trigger=n(".main-bar").children(".module-nav-trigger:not(.hidden-lg)"),this.$menu=n(".main-bar").find("ul.main-nav"),this.$menuitems=this.$menu.find("li:not(.dl-back)"),this.$el.find("ul.nav-item-children").prepend('<li class="dl-back"><a href="#">'+this.options.backLabel+"</a></li>"),this.$back=this.$menu.find("li.dl-back"),this.options.useActiveItemAsBackLabel&&this.$back.each(function(){var i=n(this),t=i.parents("li:first").find("a:first").text();i.find("a").html(t)}),this.options.useActiveItemAsLink&&this.$el.find("ul.nav-item-children").prepend(function(){var i=n(this).parents("li:not(.dl-back):first").find("a:first");return'<li class="dl-parent"><a href="'+i.attr("href")+'">'+i.text()+"</a></li>"})},_initEvents:function(){var i=this;this.$trigger.on("click.dlmenu",function(){return i.open?i._closeMenu():(i._openMenu(),s.off("click").children().on("click.dlmenu",function(){})),!1}),this.$menuitems.on("click.dlmenu",function(t){t.stopPropagation();var e=n(this),s=e.children("ul.nav-item-children");if(s.length>0&&!n(t.currentTarget).hasClass("dl-subviewopen")){var a=s.clone().css("opacity",0).insertAfter(i.$menu),o=function(){i.$menu.off(i.animEndEventName).removeClass(i.options.animationClasses.classout).addClass("dl-subview"),e.addClass("dl-subviewopen").parents(".dl-subviewopen:first").removeClass("dl-subviewopen").addClass("dl-subview"),a.remove()};return setTimeout(function(){a.addClass(i.options.animationClasses.classin),i.$menu.addClass(i.options.animationClasses.classout),i.supportAnimations?i.$menu.on(i.animEndEventName,o):o.call(),i.options.onLevelClick(e,e.children("a:first").text())}),!1}i.options.onLinkClick(e,t)}),this.$back.on("click.dlmenu",function(t){var e=n(this),s=e.parents("ul.nav-item-children:first"),a=s.parent(),o=s.clone().insertAfter(i.$menu),l=function(){i.$menu.off(i.animEndEventName).removeClass(i.options.animationClasses.classin),o.remove()};return setTimeout(function(){o.addClass(i.options.animationClasses.classout),i.$menu.addClass(i.options.animationClasses.classin),i.supportAnimations?i.$menu.on(i.animEndEventName,l):l.call(),a.removeClass("dl-subviewopen");var n=e.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.options.resetOnClose&&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(){s.off("click").on("click.dlmenu",function(){}),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 a=function(n){i.console&&i.console.error(n)};n.fn.dlmenu=function(i){if("string"==typeof i){var t=Array.prototype.slice.call(arguments,1);this.each(function(){var e=n.data(this,"dlmenu");return e?n.isFunction(e[i])&&"_"!==i.charAt(0)?void e[i].apply(e,t):void a("no such method '"+i+"' for dlmenu instance"):void a("cannot call methods on dlmenu prior to initialization; attempted to call method '"+i+"'")})}else this.each(function(){var t=n.data(this,"dlmenu");t?t._init():t=n.data(this,"dlmenu",new n.DLMenu(i,this))});return this}}(jQuery,window);
