site_oueb_2/wp-content/themes/oceanwp/assets/js/drop-down-mobile-menu.min.js

1 line
14 KiB
JavaScript
Executable File

!function o(i,r,l){function a(t,e){if(!r[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(s)return s(t,!0);throw(n=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",n}n=r[t]={exports:{}},i[t][0].call(n.exports,function(e){return a(i[t][1][e]||e)},n,n.exports,o,i,r,l)}return r[t].exports}for(var s="function"==typeof require&&require,e=0;e<l.length;e++)a(l[e]);return a}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.options=void 0;var o=oceanwpLocalize;n.options=o},{}],2:[function(e,t,n){"use strict";var o=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(n,"__esModule",{value:!0}),n.fadeOutNav=n.fadeInNav=n.isSelectorValid=n.isElement=n.getSiblings=n.visible=n.offset=n.fadeToggle=n.fadeOut=n.fadeIn=n.slideToggle=n.slideUp=n.slideDown=n.wrap=void 0;var i=o(e("@babel/runtime/helpers/typeof"));n.wrap=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document.createElement("div");return e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t),t.appendChild(e)};function r(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:300,n=window.getComputedStyle(e).display;"none"===n&&(n="block"),e.style.transitionProperty="height",e.style.transitionDuration="".concat(t,"ms"),e.style.opacity=0,e.style.display=n;var o=e.offsetHeight;e.style.height=0,e.style.opacity=1,e.style.overflow="hidden",setTimeout(function(){e.style.height="".concat(o,"px")},5),window.setTimeout(function(){e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property"),e.style.removeProperty("opacity")},t+50)}n.slideDown=r;function l(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:300;e.style.boxSizing="border-box",e.style.transitionProperty="height, margin",e.style.transitionDuration="".concat(t,"ms"),e.style.height="".concat(e.offsetHeight,"px"),e.style.marginTop=0,e.style.marginBottom=0,e.style.overflow="hidden",setTimeout(function(){e.style.height=0},5),window.setTimeout(function(){e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t+50)}n.slideUp=l;n.slideToggle=function(e,t){("none"===window.getComputedStyle(e).display?r:l)(e,t)};function a(e){var t={duration:300,display:null,opacity:1,callback:null};Object.assign(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}),e.style.opacity=0,e.style.display=t.display||"block",setTimeout(function(){e.style.transition="".concat(t.duration,"ms opacity ease"),e.style.opacity=t.opacity},5),setTimeout(function(){e.style.removeProperty("transition"),t.callback&&t.callback()},t.duration+50)}n.fadeIn=a;function s(e){var t;"none"!==e.style.display&&(t={duration:300,display:null,opacity:0,callback:null},Object.assign(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}),e.style.opacity=1,e.style.display=t.display||"block",setTimeout(function(){e.style.transition="".concat(t.duration,"ms opacity ease"),e.style.opacity=t.opacity},5),setTimeout(function(){e.style.display="none",e.style.removeProperty("transition"),t.callback&&t.callback()},t.duration+50))}n.fadeOut=s;n.fadeToggle=function(e,t){("none"===window.getComputedStyle(e).display?a:s)(e,t)};n.offset=function(e){if(!e.getClientRects().length)return{top:0,left:0};var t=e.getBoundingClientRect(),e=e.ownerDocument.defaultView;return{top:t.top+e.pageYOffset,left:t.left+e.pageXOffset}};n.visible=function(e){return!!e&&!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)};n.getSiblings=function(e){var t=[];if(!e.parentNode)return t;for(var n=e.parentNode.firstChild;n;)1===n.nodeType&&n!==e&&t.push(n),n=n.nextSibling;return t};n.isElement=function(e){return"object"===("undefined"==typeof HTMLElement?"undefined":(0,i.default)(HTMLElement))?e instanceof HTMLElement:e&&"object"===(0,i.default)(e)&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName};var u,e=(u=document.createDocumentFragment(),function(e){try{u.querySelector(e)}catch(e){return!1}return!0});n.isSelectorValid=e;n.fadeInNav=function(e){var t={duration:300,visibility:"visible",opacity:1,callback:null};Object.assign(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}),e.style.opacity=0,e.style.visibility=t.visibility||"visible",setTimeout(function(){e.style.transition="".concat(t.duration,"ms opacity ease"),e.style.opacity=t.opacity},5)};n.fadeOutNav=function(e){var t;"hidden"!==e.style.visibility&&(t={duration:300,visibility:"hidden",opacity:0,callback:null},Object.assign(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}),e.style.opacity=1,e.style.visibility=t.visibility||"visible",setTimeout(function(){e.style.transition="".concat(t.duration,"ms opacity ease"),e.style.opacity=t.opacity},5),setTimeout(function(){e.style.visibility="hidden",e.style.removeProperty("transition"),t.callback&&t.callback()},t.duration+50))}},{"@babel/runtime/helpers/interopRequireDefault":11,"@babel/runtime/helpers/typeof":12}],3:[function(e,t,n){"use strict";var o=e("@babel/runtime/helpers/interopRequireDefault"),i=o(e("@babel/runtime/helpers/defineProperty")),r=o(e("@babel/runtime/helpers/classCallCheck")),l=o(e("@babel/runtime/helpers/classPrivateFieldSet")),u=o(e("@babel/runtime/helpers/classPrivateFieldGet")),a=o(e("delegate")),c=e("../../constants"),d=e("../../lib/utils");function s(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function p(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach(function(e){(0,i.default)(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}var f=new WeakMap,y=new WeakMap,v=new WeakMap,m=new WeakMap,b=new WeakMap,g=new WeakMap,h=new WeakMap,w=new WeakMap,x=new WeakMap,M=new WeakMap,k=new WeakMap,E=new WeakMap,e=function e(){var s=this;(0,r.default)(this,e),f.set(this,{writable:!0,value:{body:document.body}}),y.set(this,{writable:!0,value:void 0}),v.set(this,{writable:!0,value:void 0}),m.set(this,{writable:!0,value:function(){(0,l.default)(s,f,p(p({},(0,u.default)(s,f)),{},{parentMenuItems:document.querySelectorAll("#mobile-dropdown .menu-item-has-children"),navWrapper:document.querySelector("#mobile-dropdown"),hamburgerBtn:document.querySelector(".mobile-menu > .hamburger"),toggleMenuBtn:document.querySelector(".mobile-menu"),nav:document.querySelector("#mobile-dropdown > nav")}))}}),b.set(this,{writable:!0,value:function(){var e,t;(0,l.default)(s,y,!1),null!==(e=(0,u.default)(s,f).parentMenuItems)&&void 0!==e&&e.forEach(function(e){var t=document.createElement("span");t.className="dropdown-toggle",t.setAttribute("tabindex",0),e.getElementsByTagName("a")[0].appendChild(t)}),(0,l.default)(s,v,"link"==c.options.sidrDropdownTarget?null===(t=(0,u.default)(s,f).navWrapper)||void 0===t?void 0:t.querySelectorAll("li.menu-item-has-children > a"):null===(t=(0,u.default)(s,f).navWrapper)||void 0===t?void 0:t.querySelectorAll(".dropdown-toggle"))}}),g.set(this,{writable:!0,value:function(){var e;(0,a.default)(document.body,".mobile-menu","click",(0,u.default)(s,h)),null!==(e=(0,u.default)(s,f).navWrapper)&&void 0!==e&&e.querySelectorAll('li a[href*="#"]:not([href="#"])').forEach(function(e){e.addEventListener("click",(0,u.default)(s,w))}),document.addEventListener("click",(0,u.default)(s,w)),null!==(e=(0,u.default)(s,f).navWrapper)&&void 0!==e&&e.addEventListener("click",function(e){e.stopPropagation()}),window.addEventListener("resize",(0,u.default)(s,x)),null!==(e=(0,u.default)(s,f).hamburgerBtn)&&void 0!==e&&e.addEventListener("click",(0,u.default)(s,M)),null!==(e=(0,u.default)(s,v))&&void 0!==e&&e.forEach(function(e){e.addEventListener("click",(0,u.default)(s,k))}),document.addEventListener("keydown",(0,u.default)(s,E))}}),h.set(this,{writable:!0,value:function(e){e.preventDefault(),e.stopPropagation(),(0,u.default)(s,f).navWrapper&&(0,d.slideToggle)((0,u.default)(s,f).navWrapper,400),null!==(e=(0,u.default)(s,f).toggleMenuBtn)&&void 0!==e&&e.classList.toggle("opened"),null!==(e=(0,u.default)(s,f).hamburgerBtn)&&void 0!==e&&e.classList.toggle("is-active"),null!==(e=(0,u.default)(s,f).toggleMenuBtn)&&void 0!==e&&e.focus()}}),w.set(this,{writable:!0,value:function(e){var t;(0,u.default)(s,f).navWrapper&&(0,d.slideUp)((0,u.default)(s,f).navWrapper,250),null!==(t=(0,u.default)(s,f).toggleMenuBtn)&&void 0!==t&&t.classList.remove("opened"),null!==(t=(0,u.default)(s,f).hamburgerBtn)&&void 0!==t&&t.classList.remove("is-active")}}),x.set(this,{writable:!0,value:function(e){960<=window.innerWidth&&(0,u.default)(s,w).call(s)}}),M.set(this,{writable:!0,value:function(e){(0,l.default)(s,y,!(0,u.default)(s,y)),e.currentTarget.setAttribute("aria-expanded",(0,u.default)(s,y))}}),k.set(this,{writable:!0,value:function(e){e.preventDefault(),e.stopPropagation();var t=e.currentTarget,n=("link"==c.options.sidrDropdownTarget?t:t.parentNode).parentNode,e=n.lastElementChild;null!=n&&n.classList.contains("active")?(n.classList.remove("active"),(0,d.slideUp)(e,250),null!==(t=n.querySelectorAll(".menu-item-has-children.active"))&&void 0!==t&&t.forEach(function(e){e.classList.remove("active"),(0,d.slideUp)(e.querySelector("ul"))})):(n.classList.add("active"),(0,d.slideDown)(e,250))}}),E.set(this,{writable:!0,value:function(e){var t,n,o,i,r,l,a;null!==(a=(0,u.default)(s,f).toggleMenuBtn)&&void 0!==a&&a.classList.contains("opened")&&(t=9===e.keyCode,n=e.shiftKey,o=27===e.keyCode,i=13===e.keyCode,r=(0,u.default)(s,f).toggleMenuBtn,l=(a=null===(l=(0,u.default)(s,f).nav)||void 0===l?void 0:l.querySelectorAll("a, span.dropdown-toggle, input, button"))[0],a=a[a.length-1],r&&(r.style.outline=""),o&&(e.preventDefault(),(0,u.default)(s,w).call(s)),i&&document.activeElement.classList.contains("dropdown-toggle")&&(e.preventDefault(),document.activeElement.click()),!n&&t&&a===document.activeElement&&(e.preventDefault(),r.style.outline="1px dashed rgba(255, 255, 255, 0.6)",r.focus()),n&&t&&l===document.activeElement&&(e.preventDefault(),r.style.outline="1px dashed rgba(255, 255, 255, 0.6)",r.focus()),t&&l===a&&e.preventDefault())}}),(0,u.default)(this,f).body.classList.contains("dropdown-mobile")&&((0,u.default)(this,m).call(this),(0,u.default)(this,b).call(this),(0,u.default)(this,g).call(this))};window.oceanwp=window.oceanwp||{},oceanwp.dropDownMobileMenu=new e},{"../../constants":1,"../../lib/utils":2,"@babel/runtime/helpers/classCallCheck":6,"@babel/runtime/helpers/classPrivateFieldGet":8,"@babel/runtime/helpers/classPrivateFieldSet":9,"@babel/runtime/helpers/defineProperty":10,"@babel/runtime/helpers/interopRequireDefault":11,delegate:14}],4:[function(e,t,n){t.exports=function(e,t){return t.get?t.get.call(e):t.value},t.exports.default=t.exports,t.exports.__esModule=!0},{}],5:[function(e,t,n){t.exports=function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}},t.exports.default=t.exports,t.exports.__esModule=!0},{}],6:[function(e,t,n){t.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},{}],7:[function(e,t,n){t.exports=function(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)},t.exports.default=t.exports,t.exports.__esModule=!0},{}],8:[function(e,t,n){var o=e("./classApplyDescriptorGet.js"),i=e("./classExtractFieldDescriptor.js");t.exports=function(e,t){return t=i(e,t,"get"),o(e,t)},t.exports.default=t.exports,t.exports.__esModule=!0},{"./classApplyDescriptorGet.js":4,"./classExtractFieldDescriptor.js":7}],9:[function(e,t,n){var o=e("./classApplyDescriptorSet.js"),i=e("./classExtractFieldDescriptor.js");t.exports=function(e,t,n){return t=i(e,t,"set"),o(e,t,n),n},t.exports.default=t.exports,t.exports.__esModule=!0},{"./classApplyDescriptorSet.js":5,"./classExtractFieldDescriptor.js":7}],10:[function(e,t,n){t.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},t.exports.default=t.exports,t.exports.__esModule=!0},{}],11:[function(e,t,n){t.exports=function(e){return e&&e.__esModule?e:{default:e}},t.exports.default=t.exports,t.exports.__esModule=!0},{}],12:[function(e,t,n){function o(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=o=function(e){return typeof e}:t.exports=o=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.default=t.exports,t.exports.__esModule=!0,o(e)}t.exports=o,t.exports.default=t.exports,t.exports.__esModule=!0},{}],13:[function(e,t,n){var o;"undefined"==typeof Element||Element.prototype.matches||((o=Element.prototype).matches=o.matchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector||o.webkitMatchesSelector),t.exports=function(e,t){for(;e&&9!==e.nodeType;){if("function"==typeof e.matches&&e.matches(t))return e;e=e.parentNode}}},{}],14:[function(e,t,n){var l=e("./closest");function r(e,t,n,o,i){var r=function(t,n,e,o){return function(e){e.delegateTarget=l(e.target,n),e.delegateTarget&&o.call(t,e)}}.apply(this,arguments);return e.addEventListener(n,r,i),{destroy:function(){e.removeEventListener(n,r,i)}}}t.exports=function(e,t,n,o,i){return"function"==typeof e.addEventListener?r.apply(null,arguments):"function"==typeof n?r.bind(null,document).apply(null,arguments):("string"==typeof e&&(e=document.querySelectorAll(e)),Array.prototype.map.call(e,function(e){return r(e,t,n,o,i)}))}},{"./closest":13}]},{},[3]);