/******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./assets/src/scss/admin/mega-menu.scss": /*!**********************************************!*\ !*** ./assets/src/scss/admin/mega-menu.scss ***! \**********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); // extracted by mini-css-extract-plugin /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { /*!*****************************************!*\ !*** ./assets/src/js/edit-mega-menu.js ***! \*****************************************/ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _scss_admin_mega_menu_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scss/admin/mega-menu.scss */ "./assets/src/scss/admin/mega-menu.scss"); // noinspection ES6ConvertVarToLetConst /* global ajaxurl */ (function ($, window, document) { 'use strict'; var preventDefault = function preventDefault(e) { return e.preventDefault(); }; /** * Ayyash Mega Menu * @param el * @constructor */ var AyyashMegamenu = function AyyashMegamenu(el) { var base = this; // Access to jQuery and DOM versions of element var $elem = $(el); // base.$el = $( el ); // base.el = el; // Add a reverse reference to the DOM object //$elem.data( 'AyyashMegamenu', base ); var _timeout = 0; base.init = function () { $elem.on('click', '.is-mega', function () { base.flush($(this)); base.depends(); }); $elem.on('mouseup', '.menu-item-bar', function () { clearTimeout(_timeout); _timeout = setTimeout(function () { base.depends(); }, 50); }); $elem.on('change', '.is-width', function () { var _this = $(this); var type = _this.val(); var _container = _this.closest('.ayyash-mega-menu'); // toggle class remove class if state is false. _container.find('.mega-depend-width').toggleClass('hidden', type !== 'custom'); // show position dropdown only if item is not full width. _container.find('.mega-depend-position').toggleClass('hidden', 'full' === type); }); $('.is-width').trigger('change'); base.depends(); }; base.depends = function () { $elem.find('.is-mega').each(function () { base.flush($(this)); }); // clear all mega columns $('li', $elem).removeClass('active-mega-column').removeClass('active-sub-mega-column'); // Add columns for mega menu. var nextDepth = $('.active-mega-menu', $elem).nextUntil('.menu-item-depth-0', 'li'); nextDepth.closest('li.menu-item-depth-1').addClass('active-mega-column'); nextDepth.closest('li:not(.menu-item-depth-1)').addClass('active-sub-mega-column'); }; base.flush = function (_el) { var isActive = _el.is(':checked'); var item = _el.closest('li'); item.toggleClass('active-mega-menu', isActive); item.find('.field-mega-width').toggleClass('hidden', !isActive); }; // Run initializer base.init(); }; $.fn.ayyashMegamenu = function () { return this.each(function () { new AyyashMegamenu(this); }); }; // ====================================================== /** * Ayyash Megamenu Icon Picker */ var ayyashMegamenuIcons = function ayyashMegamenuIcons() { var _iconDialog = $('#icon-dialog'); var _iconOverlay = $('#icon-overlay'); var _iconInsert = _iconDialog.find('#icon-insert'); var _iconLoad = _iconDialog.find('#icon-load'); var _iconSearch = _iconDialog.find('#icon-search'); var _iconDialogHeight = $(window).height() < 500 ? parseInt($(window).height()) : 500; var _iconSelected = false; var _iconsLoaded = false; var _iconRemove; var _iconParent; var _iconValue; var _iconPreview; _iconDialog.dialog({ dialogClass: 'wp-dialog ayyash-icon-dialog', width: 1000, height: _iconDialogHeight, closeOnEscape: true, autoOpen: false, create: function create() { $('.ui-dialog-titlebar-close').addClass('ui-button'); }, open: function open() { _iconLoad.height(_iconDialogHeight - 210); _iconOverlay.show(); }, close: function close() { // clear on close. _iconSelected = false; _iconOverlay.hide(); }, resize: function resize(event, ui) { _iconLoad.height(parseInt(ui.size.height) - 210); } }); $(document).on('click', '.pick-icon[data-name]', function (e) { preventDefault(e); var self = $(this); if (self.is('.active-icon')) { self.removeClass('active-icon'); _iconSelected = false; } else { self.addClass('active-icon').siblings().removeClass('active-icon'); _iconSelected = self.data('name'); } }); var iconList; _iconSearch.keyup(function () { if (!_iconsLoaded) { return; } if (!iconList) { iconList = _iconLoad.find('a'); } var search = $(this).val(); if (!search) { iconList.show(); return; } var pattern = new RegExp(search, 'i'); iconList.each(function () { var _this = $(this); if (_this.data('name').search(pattern) < 0) { _this.hide(); } else { _this.show(); } }); }); _iconInsert.click(function (e) { preventDefault(e); if (!_iconsLoaded || !_iconSelected) { return; } var label = _iconPreview.data('label').replace('%s', _iconSelected.replace('ti-', '').replace('-', ' ')); // preview _iconPreview.removeClass('hidden'); _iconPreview.html("")); _iconPreview.next('.icon-add').data('icon', _iconSelected); // value _iconValue.val(_iconSelected).trigger('keyup'); // remove icon class _iconRemove.removeClass('hidden'); // close dialog _iconDialog.dialog('close'); }); $(document.body).on('click', '.icon-add', function (e) { preventDefault(e); // set vars _iconParent = $(this).parent(); _iconPreview = _iconParent.find('.icon-preview'); _iconRemove = _iconParent.find('.icon-remove'); _iconValue = _iconParent.find('.icon-value'); _iconDialog.dialog('open'); if (_iconsLoaded === false) { $.ajax({ type: 'POST', url: ajaxurl, data: { action: 'ayyash-icons' }, success: function success(data) { _iconLoad.html(data); //_iconLoad.find( '[data-name]' ).removeClass( 'active-icon' ); _iconLoad.find('[data-name="' + $(this).data('icon') + '"]').addClass('active-icon'); _iconsLoaded = true; } }); } else { _iconLoad.find('a').removeClass('active-icon'); _iconLoad.find('[data-name="' + $(this).data('icon') + '"]').addClass('active-icon'); } }); // clear $(document.body).on('click', '.icon-remove', function (e) { preventDefault(e); var self = $(this); var item = self.parent(); item.find('.icon-preview').empty().addClass('hidden'); item.find('.icon-add').data('icon', ''); item.find('.icon-value').val(''); self.addClass('hidden'); }); _iconOverlay.click(function (e) { preventDefault(e); _iconOverlay.hide(); _iconDialog.dialog('close'); }); }; $(document).ready(function () { $('#menu-to-edit').ayyashMegamenu(); //$( '.ayyash-icon-select' ). ayyashMegamenuIcons(); }); })(jQuery, window, document); })(); /******/ })() ;