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,cAAe,OACnC,OAAAJ,GAAAG,EAAA9B,EAAA2B,EAAA,SAAAG,EAAAF,GAAA,CACF,KAAO,CACN,IAC0BI,EAD1BC,EAAAb,EACmBH,GAAO,IAA1B,IAAAgB,EAAAZ,MAAAW,EAAAC,EAAAX,KAAAC,MAA4B,KAAnBC,EAAMQ,EAAAP,MACVjC,EAAO0C,SAASV,KACnBb,EAAAA,EAAAA,IAAQvB,EAAOE,WAGhBkC,EAAOO,aAAa,cAAe,QACpC,CAAC,OAAAJ,GAAAM,EAAAjC,EAAA2B,EAAA,SAAAM,EAAAL,GAAA,CACF,CACD,CACD,EASAM,SAAQ,SAACV,GAGR,MAFuD,UAAvCA,EAAOpB,aAAa,cAGrC,GAGK+B,EAAS,CACd1C,KAAMD,EAAOC,K","sources":["webpack://BellGully/../http/content/scripts/src/app/ui/filter/filter.js"],"sourcesContent":["import { listen } from 'Util/core';\r\nimport { publish } from 'Util/pubsub';\r\n\r\n/** CSS selectors */\r\nconst selectors = Object.freeze({\r\n\tmodal: '.js-filter__modal',\r\n\ttrigger: '.js-filter__modal-trigger',\r\n});\r\n\r\n/** CSS classes */\r\nconst classes = Object.freeze({\r\n\tallowAnimations: 'allow-animations',\r\n});\r\n\r\n/** Publish/subscribe events */\r\nconst events = Object.freeze({\r\n\tshowModal: '/modal/show',\r\n\thideModal: '/modal/hide',\r\n});\r\n\r\n/** @type {string} Mediaquery for which the filter uses a modal layout */\r\nconst modalBp = '(max-width: 767px)';\r\n\r\n/**\r\n * Whether or not the filter was using a modal layout last time the breakpoint was checked\r\n *\r\n * @type {null | boolean}\r\n */\r\nlet isModal = null;\r\n\r\nconst module = {\r\n\t/**\r\n\t * Initialise the filter module.\r\n\t */\r\n\tinit() {\r\n\t\tmodule._setState();\r\n\t\tmodule._initEvents();\r\n\t},\r\n\r\n\t/**\r\n\t * Add all event listeners for this module.\r\n\t */\r\n\t_initEvents() {\r\n\t\tlisten(selectors.trigger, 'click', module._triggerClickEvent);\r\n\t\twindow.addEventListener('resize', module._setState);\r\n\t},\r\n\r\n\t/**\r\n\t * Emulate a modal trigger click, and also apply 'allow-animations' class to\r\n\t * the filter modal\r\n\t *\r\n\t * @param {Event} e\r\n\t */\r\n\t_triggerClickEvent(e) {\r\n\t\tconst $trigger = e.target;\r\n\r\n\t\tif ($trigger) {\r\n\t\t\tconst targetId = $trigger.getAttribute('aria-controls');\r\n\t\t\tconst $target = document.getElementById(targetId);\r\n\r\n\t\t\tif ($target) {\r\n\t\t\t\tif (!$target.classList.contains(classes.allowAnimations)) {\r\n\t\t\t\t\t$target.classList.add(classes.allowAnimations);\r\n\t\t\t\t}\r\n\t\t\t\tpublish(events.showModal, targetId);\r\n\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t/**\r\n\t * Set the state of the filter elements based on the current breakpoint\r\n\t */\r\n\t_setState() {\r\n\t\tconst inModalBp = window.matchMedia(modalBp).matches;\r\n\r\n\t\tif (inModalBp !== isModal) {\r\n\t\t\tisModal = inModalBp;\r\n\r\n\t\t\t// We've crossed the threshold between modal and non-modal\r\n\t\t\tconst $modals = document.querySelectorAll(selectors.modal);\r\n\r\n\t\t\t// Ensure animations are disabled by default\r\n\t\t\tfor (let $modal of $modals) {\r\n\t\t\t\tif ($modal.classList.contains(classes.allowAnimations)) {\r\n\t\t\t\t\t$modal.classList.remove(classes.allowAnimations);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (inModalBp) {\r\n\t\t\t\t// Modal filters should be aria-hidden by default\r\n\t\t\t\tfor (let $modal of $modals) {\r\n\t\t\t\t\t$modal.setAttribute('aria-hidden', 'true');\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t// Non-modal filters should not be aria-hidden by default\r\n\t\t\t\tfor (let $modal of $modals) {\r\n\t\t\t\t\tif (module._isShown($modal)) {\r\n\t\t\t\t\t\tpublish(events.hideModal);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t$modal.setAttribute('aria-hidden', 'false');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t/**\r\n\t * If the given modal window is currently shown.\r\n\t *\r\n\t * @param {HTMLElement} $modal - The modal window to check.\r\n\t *\r\n\t * @return {boolean} Whether or not the modal window is currently shown.\r\n\t */\r\n\t_isShown($modal) {\r\n\t\tconst isShown = $modal.getAttribute('aria-hidden') === 'false';\r\n\r\n\t\treturn isShown;\r\n\t},\r\n};\r\n\r\nconst filter = {\r\n\tinit: module.init,\r\n};\r\n\r\nexport { filter };\r\n"],"names":["selectors","Object","freeze","modal","trigger","classes","allowAnimations","events","showModal","hideModal","isModal","module","init","_setState","_initEvents","listen","_triggerClickEvent","window","addEventListener","e","$trigger","target","targetId","getAttribute","$target","document","getElementById","classList","contains","add","publish","stopPropagation","inModalBp","matchMedia","matches","_step","$modals","querySelectorAll","_iterator","_createForOfIteratorHelper","s","n","done","$modal","value","remove","err","f","_step2","_iterator2","setAttribute","_step3","_iterator3","_isShown","filter"],"sourceRoot":""}