3 lines
10 KiB
JavaScript
3 lines
10 KiB
JavaScript
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("./foundation.util.box"),require("./foundation.util.keyboard"),require("./foundation.util.nest"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","./foundation.core.plugin","./foundation.core.utils","./foundation.util.box","./foundation.util.keyboard","./foundation.util.nest","jquery"],e):"object"==typeof exports?exports["foundation.dropdownMenu"]=e(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("./foundation.util.box"),require("./foundation.util.keyboard"),require("./foundation.util.nest"),require("jquery")):(n.__FOUNDATION_EXTERNAL__=n.__FOUNDATION_EXTERNAL__||{},n.__FOUNDATION_EXTERNAL__["foundation.dropdownMenu"]=e(n.__FOUNDATION_EXTERNAL__["foundation.core"],n.__FOUNDATION_EXTERNAL__["foundation.core"],n.__FOUNDATION_EXTERNAL__["foundation.core"],n.__FOUNDATION_EXTERNAL__["foundation.util.box"],n.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],n.__FOUNDATION_EXTERNAL__["foundation.util.nest"],n.jQuery))}(window,function(t,o,i,r,s,u,a){return function(t){var o={};function i(n){if(o[n])return o[n].exports;var e=o[n]={i:n,l:!1,exports:{}};return t[n].call(e.exports,e,e.exports,i),e.l=!0,e.exports}return i.m=t,i.c=o,i.d=function(n,e,t){i.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},i.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},i.t=function(e,n){if(1&n&&(e=i(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)i.d(t,o,function(n){return e[n]}.bind(null,o));return t},i.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return i.d(e,"a",e),e},i.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},i.p="",i(i.s=5)}({"./foundation.core":function(n,e){n.exports=t},"./foundation.core.plugin":function(n,e){n.exports=o},"./foundation.core.utils":function(n,e){n.exports=i},"./foundation.util.box":function(n,e){n.exports=r},"./foundation.util.keyboard":function(n,e){n.exports=s},"./foundation.util.nest":function(n,e){n.exports=u},"./js/entries/plugins/foundation.dropdownMenu.js":function(n,e,t){"use strict";t.r(e);var o=t("./foundation.core");t.d(e,"Foundation",function(){return o.Foundation});var i=t("./js/foundation.dropdownMenu.js");t.d(e,"DropdownMenu",function(){return i.DropdownMenu}),o.Foundation.plugin(i.DropdownMenu,"DropdownMenu")},"./js/foundation.dropdownMenu.js":function(n,e,t){"use strict";t.r(e),t.d(e,"DropdownMenu",function(){return m});var o=t("jquery"),f=t.n(o),r=t("./foundation.core.plugin"),u=t("./foundation.core.utils"),p=t("./foundation.util.keyboard"),s=t("./foundation.util.nest"),a=t("./foundation.util.box");function i(n){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function d(n,e){for(var t=0;t<e.length;t++){var o=e[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(n,o.key,o)}}function l(n,e){return!e||"object"!==i(e)&&"function"!=typeof e?function(n){if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(n):e}function c(n){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)})(n)}function h(n,e){return(h=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n})(n,e)}var m=function(n){function t(){return function(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),l(this,c(t).apply(this,arguments))}var e,o,i;return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&h(n,e)}(t,r["Plugin"]),e=t,(o=[{key:"_setup",value:function(n,e){this.$element=n,this.options=f.a.extend({},t.defaults,this.$element.data(),e),this.className="DropdownMenu",this._init(),p.Keyboard.register("DropdownMenu",{ENTER:"open",SPACE:"open",ARROW_RIGHT:"next",ARROW_UP:"up",ARROW_DOWN:"down",ARROW_LEFT:"previous",ESCAPE:"close"})}},{key:"_init",value:function(){s.Nest.Feather(this.$element,"dropdown");var n=this.$element.find("li.is-dropdown-submenu-parent");this.$element.children(".is-dropdown-submenu-parent").children(".is-dropdown-submenu").addClass("first-sub"),this.$menuItems=this.$element.find('[role="menuitem"]'),this.$tabs=this.$element.children('[role="menuitem"]'),this.$tabs.find("ul.is-dropdown-submenu").addClass(this.options.verticalClass),"auto"===this.options.alignment?this.$element.hasClass(this.options.rightClass)||Object(u.rtl)()||this.$element.parents(".top-bar-right").is("*")?(this.options.alignment="right",n.addClass("opens-left")):(this.options.alignment="left",n.addClass("opens-right")):"right"===this.options.alignment?n.addClass("opens-left"):n.addClass("opens-right"),this.changed=!1,this._events()}},{key:"_isVertical",value:function(){return"block"===this.$tabs.css("display")||"column"===this.$element.css("flex-direction")}},{key:"_isRtl",value:function(){return this.$element.hasClass("align-right")||Object(u.rtl)()&&!this.$element.hasClass("align-left")}},{key:"_events",value:function(){var c=this,r="ontouchstart"in window||void 0!==window.ontouchstart,s="is-dropdown-submenu-parent";(this.options.clickOpen||r)&&this.$menuItems.on("click.zf.dropdownmenu touchstart.zf.dropdownmenu",function(n){var e=f()(n.target).parentsUntil("ul",".".concat(s)),t=e.hasClass(s),o="true"===e.attr("data-is-click"),i=e.children(".is-dropdown-submenu");if(t)if(o){if(!c.options.closeOnClick||!c.options.clickOpen&&!r||c.options.forceFollow&&r)return;n.stopImmediatePropagation(),n.preventDefault(),c._hide(e)}else n.preventDefault(),n.stopImmediatePropagation(),c._show(i),e.add(e.parentsUntil(c.$element,".".concat(s))).attr("data-is-click",!0)}),c.options.closeOnClickInside&&this.$menuItems.on("click.zf.dropdownmenu",function(n){f()(this).hasClass(s)||c._hide()}),this.options.disableHover||this.$menuItems.on("mouseenter.zf.dropdownmenu",function(n){var e=f()(this);e.hasClass(s)&&(clearTimeout(e.data("_delay")),e.data("_delay",setTimeout(function(){c._show(e.children(".is-dropdown-submenu"))},c.options.hoverDelay)))}).on("mouseleave.zf.dropdownMenu",Object(u.ignoreMousedisappear)(function(n){var e=f()(this);if(e.hasClass(s)&&c.options.autoclose){if("true"===e.attr("data-is-click")&&c.options.clickOpen)return!1;clearTimeout(e.data("_delay")),e.data("_delay",setTimeout(function(){c._hide(e)},c.options.closingTime))}})),this.$menuItems.on("keydown.zf.dropdownmenu",function(e){var t,o,i=f()(e.target).parentsUntil("ul",'[role="menuitem"]'),n=-1<c.$tabs.index(i),r=n?c.$tabs:i.siblings("li").add(i);r.each(function(n){if(f()(this).is(i))return t=r.eq(n-1),void(o=r.eq(n+1))});var s=function(){o.children("a:first").focus(),e.preventDefault()},u=function(){t.children("a:first").focus(),e.preventDefault()},a=function(){var n=i.children("ul.is-dropdown-submenu");n.length&&(c._show(n),i.find("li > a:first").focus(),e.preventDefault())},d=function(){var n=i.parent("ul").parent("li");n.children("a:first").focus(),c._hide(n),e.preventDefault()},l={open:a,close:function(){c._hide(c.$element),c.$menuItems.eq(0).children("a").focus(),e.preventDefault()},handled:function(){e.stopImmediatePropagation()}};n?c._isVertical()?c._isRtl()?f.a.extend(l,{down:s,up:u,next:d,previous:a}):f.a.extend(l,{down:s,up:u,next:a,previous:d}):c._isRtl()?f.a.extend(l,{next:u,previous:s,down:a,up:d}):f.a.extend(l,{next:s,previous:u,down:a,up:d}):c._isRtl()?f.a.extend(l,{next:d,previous:a,down:s,up:u}):f.a.extend(l,{next:a,previous:d,down:s,up:u}),p.Keyboard.handleKey(e,"DropdownMenu",l)})}},{key:"_addBodyHandler",value:function(){var e=f()(document.body),t=this;e.off("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu").on("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu",function(n){t.$element.find(n.target).length||(t._hide(),e.off("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu"))})}},{key:"_show",value:function(t){var n=this.$tabs.index(this.$tabs.filter(function(n,e){return 0<f()(e).find(t).length})),e=t.parent("li.is-dropdown-submenu-parent").siblings("li.is-dropdown-submenu-parent");this._hide(e,n),t.css("visibility","hidden").addClass("js-dropdown-active").parent("li.is-dropdown-submenu-parent").addClass("is-active");var o=a.Box.ImNotTouchingYou(t,null,!0);if(!o){var i="left"===this.options.alignment?"-right":"-left",r=t.parent(".is-dropdown-submenu-parent");r.removeClass("opens".concat(i)).addClass("opens-".concat(this.options.alignment)),(o=a.Box.ImNotTouchingYou(t,null,!0))||r.removeClass("opens-".concat(this.options.alignment)).addClass("opens-inner"),this.changed=!0}t.css("visibility",""),this.options.closeOnClick&&this._addBodyHandler(),this.$element.trigger("show.zf.dropdownmenu",[t])}},{key:"_hide",value:function(n,t){var e;if((e=n&&n.length?n:void 0!==t?this.$tabs.not(function(n,e){return n===t}):this.$element).hasClass("is-active")||0<e.find(".is-active").length){if(e.find("li.is-active").add(e).attr({"data-is-click":!1}).removeClass("is-active"),e.find("ul.js-dropdown-active").removeClass("js-dropdown-active"),this.changed||e.find("opens-inner").length){var o="left"===this.options.alignment?"right":"left";e.find("li.is-dropdown-submenu-parent").add(e).removeClass("opens-inner opens-".concat(this.options.alignment)).addClass("opens-".concat(o)),this.changed=!1}this.$element.trigger("hide.zf.dropdownmenu",[e])}}},{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"),f()(document.body).off(".zf.dropdownmenu"),s.Nest.Burn(this.$element,"dropdown")}}])&&d(e.prototype,o),i&&d(e,i),t}();m.defaults={disableHover:!1,autoclose:!0,hoverDelay:50,clickOpen:!1,closingTime:500,alignment:"auto",closeOnClick:!0,closeOnClickInside:!0,verticalClass:"vertical",rightClass:"align-right",forceFollow:!0}},5:function(n,e,t){n.exports=t("./js/entries/plugins/foundation.dropdownMenu.js")},jquery:function(n,e){n.exports=a}})});
|
|
//# sourceMappingURL=foundation.dropdownMenu.min.js.map
|