UNPKG

foundation-sites

Version:

The most advanced responsive front-end framework in the world.

3 lines (2 loc) 9.13 kB
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("./foundation.core"),require("./foundation.util.keyboard"),require("./foundation.util.nest"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","./foundation.util.keyboard","./foundation.util.nest","jquery"],n):"object"==typeof exports?exports["foundation.accordionMenu"]=n(require("./foundation.core"),require("./foundation.util.keyboard"),require("./foundation.util.nest"),require("jquery")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.accordionMenu"]=n(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],e.__FOUNDATION_EXTERNAL__["foundation.util.nest"],e.jQuery))}(window,function(t,i,o,r){return a={"./foundation.core":function(e,n){e.exports=t},"./foundation.util.keyboard":function(e,n){e.exports=i},"./foundation.util.nest":function(e,n){e.exports=o},"./js/entries/plugins/foundation.accordionMenu.js":function(e,n,t){"use strict";t.r(n);var i=t("./foundation.core");t.d(n,"Foundation",function(){return i.Foundation});var o=t("./js/foundation.accordionMenu.js");t.d(n,"AccordionMenu",function(){return o.AccordionMenu}),i.Foundation.plugin(o.AccordionMenu,"AccordionMenu")},"./js/foundation.accordionMenu.js":function(e,n,t){"use strict";t.r(n),t.d(n,"AccordionMenu",function(){return i});var n=t("jquery"),a=t.n(n),s=t("./foundation.util.keyboard"),u=t("./foundation.util.nest"),c=t("./foundation.core");function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n){for(var t=0;t<n.length;t++){var i=n[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,n){return(l=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function d(t){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,n=f(t);return function(e,n){{if(n&&("object"===o(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined")}return function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,i?(e=f(this).constructor,Reflect.construct(n,arguments,e)):n.apply(this,arguments))}}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var i=function(){!function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&l(e,n)}(o,c["Plugin"]);var e,n,t,i=d(o);function o(){return function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,o),i.apply(this,arguments)}return e=o,(n=[{key:"_setup",value:function(e,n){this.$element=e,this.options=a.a.extend({},o.defaults,this.$element.data(),n),this.className="AccordionMenu",this._init(),s.Keyboard.register("AccordionMenu",{ENTER:"toggle",SPACE:"toggle",ARROW_RIGHT:"open",ARROW_UP:"up",ARROW_DOWN:"down",ARROW_LEFT:"close",ESCAPE:"closeAll"})}},{key:"_init",value:function(){u.Nest.Feather(this.$element,"accordion");var r=this;this.$element.find("[data-submenu]").not(".is-active").slideUp(0),this.$element.attr({"aria-multiselectable":this.options.multiOpen}),this.$menuLinks=this.$element.find(".is-accordion-submenu-parent"),this.$menuLinks.each(function(){var e=this.id||Object(c.GetYoDigits)(6,"acc-menu-link"),n=a()(this),t=n.children("[data-submenu]"),i=t[0].id||Object(c.GetYoDigits)(6,"acc-menu"),o=t.hasClass("is-active");r.options.parentLink&&n.children("a").clone().prependTo(t).wrap('<li data-is-parent-link class="is-submenu-parent-item is-submenu-item is-accordion-submenu-item"></li>'),r.options.submenuToggle?(n.addClass("has-submenu-toggle"),n.children("a").after('<button id="'+e+'" class="submenu-toggle" aria-controls="'+i+'" aria-expanded="'+o+'" title="'+r.options.submenuToggleText+'"><span class="submenu-toggle-text">'+r.options.submenuToggleText+"</span></button>")):n.attr({"aria-controls":i,"aria-expanded":o,id:e}),t.attr({"aria-labelledby":e,"aria-hidden":!o,role:"group",id:i})});var e=this.$element.find(".is-active");e.length&&e.each(function(){r.down(a()(this))}),this._events()}},{key:"_events",value:function(){var u=this;this.$element.find("li").each(function(){var n=a()(this).children("[data-submenu]");n.length&&(u.options.submenuToggle?a()(this).children(".submenu-toggle").off("click.zf.accordionMenu").on("click.zf.accordionMenu",function(){u.toggle(n)}):a()(this).children("a").off("click.zf.accordionMenu").on("click.zf.accordionMenu",function(e){e.preventDefault(),u.toggle(n)}))}).on("keydown.zf.accordionMenu",function(n){var t,i,o=a()(this),r=o.parent("ul").children("li"),e=o.children("[data-submenu]");r.each(function(e){a()(this).is(o)&&(t=r.eq(Math.max(0,e-1)).find("a").first(),i=r.eq(Math.min(e+1,r.length-1)).find("a").first(),a()(this).children("[data-submenu]:visible").length&&(i=o.find("li:first-child").find("a").first()),a()(this).is(":first-child")?t=o.parents("li").first().find("a").first():t.parents("li").first().children("[data-submenu]:visible").length&&(t=t.parents("li").find("li:last-child").find("a").first()),a()(this).is(":last-child")&&(i=o.parents("li").first().next("li").find("a").first()))}),s.Keyboard.handleKey(n,"AccordionMenu",{open:function(){e.is(":hidden")&&(u.down(e),e.find("li").first().find("a").first().focus())},close:function(){e.length&&!e.is(":hidden")?u.up(e):o.parent("[data-submenu]").length&&(u.up(o.parent("[data-submenu]")),o.parents("li").first().find("a").first().focus())},up:function(){return t.focus(),!0},down:function(){return i.focus(),!0},toggle:function(){return!u.options.submenuToggle&&(o.children("[data-submenu]").length?(u.toggle(o.children("[data-submenu]")),!0):void 0)},closeAll:function(){u.hideAll()},handled:function(e){e&&n.preventDefault()}})})}},{key:"hideAll",value:function(){this.up(this.$element.find("[data-submenu]"))}},{key:"showAll",value:function(){this.down(this.$element.find("[data-submenu]"))}},{key:"toggle",value:function(e){e.is(":animated")||(e.is(":hidden")?this.down(e):this.up(e))}},{key:"down",value:function(e){var n,t=this;this.options.multiOpen||(n=e.parentsUntil(this.$element).add(e).add(e.find(".is-active")),n=this.$element.find(".is-active").not(n),this.up(n)),e.addClass("is-active").attr({"aria-hidden":!1}),(this.options.submenuToggle?e.prev(".submenu-toggle"):e.parent(".is-accordion-submenu-parent")).attr({"aria-expanded":!0}),e.slideDown(this.options.slideSpeed,function(){t.$element.trigger("down.zf.accordionMenu",[e])})}},{key:"up",value:function(e){var n=this,t=e.find("[data-submenu]"),i=e.add(t);t.slideUp(0),i.removeClass("is-active").attr("aria-hidden",!0),(this.options.submenuToggle?i.prev(".submenu-toggle"):i.parent(".is-accordion-submenu-parent")).attr("aria-expanded",!1),e.slideUp(this.options.slideSpeed,function(){n.$element.trigger("up.zf.accordionMenu",[e])})}},{key:"_destroy",value:function(){this.$element.find("[data-submenu]").slideDown(0).css("display",""),this.$element.find("a").off("click.zf.accordionMenu"),this.$element.find("[data-is-parent-link]").detach(),this.options.submenuToggle&&(this.$element.find(".has-submenu-toggle").removeClass("has-submenu-toggle"),this.$element.find(".submenu-toggle").remove()),u.Nest.Burn(this.$element,"accordion")}}])&&r(e.prototype,n),t&&r(e,t),o}();i.defaults={parentLink:!1,slideSpeed:250,submenuToggle:!1,submenuToggleText:"Toggle menu",multiOpen:!0}},2:function(e,n,t){e.exports=t("./js/entries/plugins/foundation.accordionMenu.js")},jquery:function(e,n){e.exports=r}},s={},u.m=a,u.c=s,u.d=function(e,n,t){u.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(n,e){if(1&e&&(n=u(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var i in n)u.d(t,i,function(e){return n[e]}.bind(null,i));return t},u.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(n,"a",n),n},u.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},u.p="",u(u.s=2);function u(e){if(s[e])return s[e].exports;var n=s[e]={i:e,l:!1,exports:{}};return a[e].call(n.exports,n,n.exports,u),n.l=!0,n.exports}var a,s}); //# sourceMappingURL=foundation.accordionMenu.min.js.map