(window["webpackJsonp_name_"] = window["webpackJsonp_name_"] || []).push([[27],{ /***/ 191: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var WpwMenu = function () { function WpwMenu(args) { _classCallCheck(this, WpwMenu); this._args = Object.assign({}, args); this._init(); } _createClass(WpwMenu, [{ key: '_init', value: function _init() { var _this = this; this._menuArray = []; this.settings.forEach(function (setting, index) { _this._menuArray.push(new Menu({ settings: _this.settings, id: _this.id, index: index })); }); // Array.from(document.querySelectorAll(`.${this.id} .nav-list__submenu-indicator`)).forEach(item => { // item.addEventListener('click', event => { // event.stopPropagation(); // event.preventDefault(); // }); // }); if (this.id === "menu-default") { var menus = document.querySelectorAll('.' + this.id + ' .menu-transition-dropdown'); if (menus.length) { var menusArray = Array.from(menus); menusArray.shift(); menusArray.forEach(function (item) { return item.className = item.className.replace('menu-transition-dropdown', 'menu-transition-slide_left'); }); } } this._slideMenu(); this._accordionMenu(); } /** * No menu */ }, { key: '_noMenu', value: function _noMenu() {} /** * Accordion menu */ }, { key: '_accordionMenu', value: function _accordionMenu() { var _this2 = this; // menu-transition-accordion Array.from(document.querySelectorAll('.' + this.id + ' .menu-transition-accordion')).forEach(function (item) { var button = item.previousElementSibling; if (button) { button.classList.add('before-over-target'); button.addEventListener('click', function (event) { event.preventDefault(); _this2._toggleAccordeonMenu(event.currentTarget); }); } }); } }, { key: '_toggleAccordeonMenu', value: function _toggleAccordeonMenu(target) { var li = target.parentNode; if (li.classList.contains('menu-item_opened')) { li.classList.remove('menu-item_opened'); } else { li.classList.add('menu-item_opened'); } } /** * Slide menu */ }, { key: '_slideMenu', value: function _slideMenu() { var _this3 = this; var ul = document.querySelectorAll('.' + this.id + ' [class*="menu-transition-slide_"]'); Array.from(ul).forEach(function (item) { var a = item.previousElementSibling; if (a) { a.classList.add('before-over-target'); a.addEventListener('click', function (event) { event.preventDefault(); _this3._toggleSlideMenu(event.currentTarget); }); } }); var close = document.querySelectorAll('.' + this.id + ' [data-action="menu-back"]'); Array.from(close).forEach(function (item) { item.addEventListener('click', function (event) { event.preventDefault(); _this3._closeSubmenu(event.currentTarget); }); }); } }, { key: '_toggleSlideMenu', value: function _toggleSlideMenu(target) { if (!target) { return false; } var li = target.parentNode; var parentNode = li.parentNode; if (li.classList.contains('active-slide')) { li.classList.remove('active-slide'); parentNode.classList.remove('show-slide'); } else { li.classList.add('active-slide'); parentNode.classList.add('show-slide'); } } }, { key: '_closeSubmenu', value: function _closeSubmenu(target) { var li = target.parentNode.parentNode.parentNode; var parentNode = li.parentNode; parentNode.classList.remove('show-slide'); li.classList.remove('active-slide'); } }, { key: 'id', get: function get() { return this._args.id; } }, { key: 'settings', get: function get() { return this._args.settings; } }]); return WpwMenu; }(); exports.default = WpwMenu; var Menu = function () { function Menu(args) { _classCallCheck(this, Menu); this.docFrag = document.createDocumentFragment(); this._args = Object.assign({}, args); this._init(); } _createClass(Menu, [{ key: '_init', value: function _init() { var _this4 = this; if (this.settings[this.index].overflow_behaviour === "more") { if (this.index === 0) { this._checkNavWidth(); var time = void 0; window.addEventListener('resize', function (event) { clearTimeout(time); time = setTimeout(function () { _this4._checkNavWidth(); }, 200); }); } } } }, { key: '_open', value: function _open() { if (this.settings[this.index].overflow_behaviour === "more") { if (this.index === 0) { this._checkNavWidth(); } } } /** * Work only for first level menu */ }, { key: '_checkNavWidth', value: function _checkNavWidth() { var wrapper = document.querySelector('.' + this.id); var ul = wrapper.querySelectorAll('.menu-overflow-more')[this.index]; var fullWidth = ul.clientWidth; if (!ul) { return false; } ul.parentNode.style.position = ''; ul.parentNode.style.width = ''; ul.parentNode.style.left = ''; if (!fullWidth) { return false; } if (this.docFrag) { ul.appendChild(this.docFrag); } var nextSetting = this.settings[this.index + 1] || null; var setting = this.settings[this.index] || null; // const submenuIndicator = if (!this.templateMore) { var li = document.createElement('LI'); li.className = 'menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-has-children'; li.innerHTML = '\n \n More\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n '; var ulMore = document.createElement('UL'); ulMore.className = 'sub-menu menu-item-layout-' + (nextSetting ? nextSetting.item_layout : '') + ' menu-transition-' + (nextSetting ? nextSetting.lvl_transition : '') + '\n menu-item-h-align-' + (setting ? setting.h_align : '') + ' menu-item-v-align-' + (setting ? setting.v_align : '') + '\n '; li.appendChild(ulMore); this.templateMore = ulMore; } else { if (this.templateMore.parentNode.parentNode) { this.templateMore.parentNode.parentNode.removeChild(this.templateMore.parentNode); this.templateMore.innerHTML = ''; } } this.docFrag = document.createDocumentFragment(); var docFrag = document.createDocumentFragment(); var width = 0; var links = Array.from(ul.children); if (this.index === 0 && links.length > 1) { links = links.slice(1); } var setWidth = false; var preWidth = 0; if (!links.length) { return false; } var menuPos = ul.getBoundingClientRect(); var lastIndex = links.length - 1; function checkWidth(index) { if (index === undefined) { return false; } var liPos = links[index].getBoundingClientRect(); //debugger; if (liPos.right > menuPos.right && liPos.left < menuPos.right) { if (menuPos.right - liPos.left < 100 && index > 0) { index = index - 1; } return index; } else if (liPos.right <= menuPos.right) { if (index === links.length - 1) { return undefined; } lastIndex = lastIndex > 1 ? Math.floor(lastIndex / 2) : 1; index = index + lastIndex; return checkWidth(index); } else if (liPos.right >= menuPos.right && liPos.left >= menuPos.right) { lastIndex = lastIndex > 1 ? Math.floor(lastIndex / 2) : 1; index = index - lastIndex; return checkWidth(index); } } var moreIndex = checkWidth(links.length - 1); if (moreIndex !== undefined) { for (var i = moreIndex; i < links.length; i++) { this.docFrag.appendChild(links[i]); docFrag.appendChild(links[i].cloneNode(true)); } this.templateMore.innerHTML = '\n