"use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,n){for(var t=0;t-1,r=a?n.$tabs:s.siblings("li").add(s);r.each(function(n){if(e(this).is(s))return i=r.eq(n-1),void(o=r.eq(n+1))});var d=function(){s.is(":last-child")||(o.children("a:first").focus(),t.preventDefault())},l=function(){i.children("a:first").focus(),t.preventDefault()},u=function(){var e=s.children("ul.is-dropdown-submenu");e.length&&(n._show(e),s.find("li > a:first").focus(),t.preventDefault())},p=function(){var e=s.parent("ul").parent("li");e.children("a:first").focus(),n._hide(e),t.preventDefault()},c={open:u,close:function(){n._hide(n.$element),n.$menuItems.find("a:first").focus(),t.preventDefault()},handled:function(){t.stopImmediatePropagation()}};a?n._isVertical()?Foundation.rtl()?e.extend(c,{down:d,up:l,next:p,previous:u}):e.extend(c,{down:d,up:l,next:u,previous:p}):Foundation.rtl()?e.extend(c,{next:l,previous:d,down:u,up:p}):e.extend(c,{next:d,previous:l,down:u,up:p}):Foundation.rtl()?e.extend(c,{next:p,previous:u,down:d,up:l}):e.extend(c,{next:u,previous:p,down:d,up:l}),Foundation.Keyboard.handleKey(t,"DropdownMenu",c)})}},{key:"_addBodyHandler",value:function(){var n=e(document.body),t=this;n.off("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu").on("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu",function(e){var i=t.$element.find(e.target);i.length||(t._hide(),n.off("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu"))})}},{key:"_show",value:function(n){var t=this.$tabs.index(this.$tabs.filter(function(t,i){return e(i).find(n).length>0})),i=n.parent("li.is-dropdown-submenu-parent").siblings("li.is-dropdown-submenu-parent");this._hide(i,t),n.css("visibility","hidden").addClass("js-dropdown-active").parent("li.is-dropdown-submenu-parent").addClass("is-active");var o=Foundation.Box.ImNotTouchingYou(n,null,!0);if(!o){var s="left"===this.options.alignment?"-right":"-left",a=n.parent(".is-dropdown-submenu-parent");a.removeClass("opens"+s).addClass("opens-"+this.options.alignment),o=Foundation.Box.ImNotTouchingYou(n,null,!0),o||a.removeClass("opens-"+this.options.alignment).addClass("opens-inner"),this.changed=!0}n.css("visibility",""),this.options.closeOnClick&&this._addBodyHandler(),this.$element.trigger("show.zf.dropdownmenu",[n])}},{key:"_hide",value:function(e,n){var t;t=e&&e.length?e:void 0!==n?this.$tabs.not(function(e,t){return e===n}):this.$element;var i=t.hasClass("is-active")||t.find(".is-active").length>0;if(i){if(t.find("li.is-active").add(t).attr({"data-is-click":!1}).removeClass("is-active"),t.find("ul.js-dropdown-active").removeClass("js-dropdown-active"),this.changed||t.find("opens-inner").length){var o="left"===this.options.alignment?"right":"left";t.find("li.is-dropdown-submenu-parent").add(t).removeClass("opens-inner opens-"+this.options.alignment).addClass("opens-"+o),this.changed=!1}this.$element.trigger("hide.zf.dropdownmenu",[t])}}},{key:"destroy",value:function(){this.$menuItems.off(".zf.dropdownmenu").removeAttr("data-is-click").removeClass("is-right-arrow is-left-arrow is-down-arrow opens-right opens-left opens-inner"),e(document.body).off(".zf.dropdownmenu"),Foundation.Nest.Burn(this.$element,"dropdown"),Foundation.unregisterPlugin(this)}}]),n}();n.defaults={disableHover:!1,autoclose:!0,hoverDelay:50,clickOpen:!1,closingTime:500,alignment:"left",closeOnClick:!0,closeOnClickInside:!0,verticalClass:"vertical",rightClass:"align-right",forceFollow:!0},Foundation.plugin(n,"DropdownMenu")}(jQuery);