UNPKG

foundation-sites

Version:

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

3 lines (2 loc) 8.74 kB
((e,n)=>{"object"==typeof exports&&"object"==typeof module?module.exports=n(require("./foundation.core"),require("jquery"),require("./foundation.util.keyboard"),require("./foundation.util.nest")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery","./foundation.util.keyboard","./foundation.util.nest"],n):"object"==typeof exports?exports.__FOUNDATION_EXTERNAL__=n(require("./foundation.core"),require("jquery"),require("./foundation.util.keyboard"),require("./foundation.util.nest")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.accordionMenu"]=n(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.jQuery,e.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],e.__FOUNDATION_EXTERNAL__["foundation.util.nest"]))})(self,function(n,t,i,o){return u={"./js/foundation.accordionMenu.js":function(e,n,t){t.r(n),t.d(n,{AccordionMenu:function(){return i}});var n=t("jquery"),a=t.n(n),s=t("./foundation.util.keyboard"),o=t("./foundation.util.nest"),u=t("./foundation.core");function r(e){return(r="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 l(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,(e=>(e=((e,n)=>{if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return("string"===n?String:Number)(e);if("object"!=r(t=t.call(e,n||"default")))return t;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string"),"symbol"==r(e)?e:e+""))(i.key),i)}}function c(e,n,t){n=f(n);var i=e,n=d()?Reflect.construct(n,t||[],f(e).constructor):n.apply(e,t);if(!n||"object"!=r(n)&&"function"!=typeof n){if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");if(void 0===(n=i))throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return n}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,n){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e})(e,n)}var i=(e=>{function t(){var e=this,n=t;if(e instanceof n)return c(this,t,arguments);throw new TypeError("Cannot call a class as a function")}var n,i=t;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&p(i,e),i=t,(e=[{key:"_setup",value:function(e,n){this.$element=e,this.options=a().extend({},t.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(){o.Nest.Feather(this.$element,"accordion");var r=this,e=(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||(0,u.GetYoDigits)(6,"acc-menu-link"),n=a()(this),t=n.children("[data-submenu]"),i=t[0].id||(0,u.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})}),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()),o.Nest.Burn(this.$element,"accordion")}}])&&l(i.prototype,e),n&&l(i,n),Object.defineProperty(i,"prototype",{writable:!1}),i})(u.Plugin);i.defaults={parentLink:!1,slideSpeed:250,submenuToggle:!1,submenuToggleText:"Toggle menu",multiOpen:!0}},"./foundation.core":function(e){e.exports=n},"./foundation.util.keyboard":function(e){e.exports=i},"./foundation.util.nest":function(e){e.exports=o},jquery:function(e){e.exports=t}},a={},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,{a:n}),n},r.d=function(e,n){for(var t in n)r.o(n,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},l={},(r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(l),r.d(l,{AccordionMenu:function(){return s.AccordionMenu},Foundation:function(){return e.Foundation}}),e=r("./foundation.core"),s=r("./js/foundation.accordionMenu.js"),e.Foundation.plugin(s.AccordionMenu,"AccordionMenu"),l;function r(e){var n=a[e];return void 0!==n||(n=a[e]={exports:{}},u[e](n,n.exports,r)),n.exports}var u,a,e,s,l}); //# sourceMappingURL=foundation.accordionMenu.min.js.map