"use strict"; function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } (function ($) { 'use strict'; window.bhfb = { init: function init() { // this.previewIframe = this.builderGridContentFlag = false; this.updateGridDelay = 200; this.currentDevice = 'desktop'; this.currentArea = 'header'; this.currentRowInput = ''; this.currentRow = ''; this.currentColumn = ''; this.currentColumnPos = ''; this.currentComponent = ''; this.currentBuilder = ''; this.currentBuilderType = ''; this.componentsOrder = ''; this.preventEmptyRowValues(); this.customizeNavigation(); this.elementsPopup(); this.elementsButton(); this.storeGlobals(); this.devicesSwitcher(); this.elementsPopupContent(); this.builderGridContent(); this.elementsSortable(); this.builderCustomColumns(); this.builderColumnsLayout(); this.footerCustomizerOptions(); this.headerPresets(); // this.extraNavigation(); this.showHideBuilder(); this.showHideBuilderTop(); }, jsonDecode: function jsonDecode(value) { return JSON.parse(value.replace(/'/g, '"').replace(';', '')); }, // In some rare cases, the row values are empty, so we need to prevent that // case it is empty, we set the default values preventEmptyRowValues: function preventEmptyRowValues() { var areas = ['header', 'footer'], rows = ['above', 'main', 'below']; for (var _i = 0, _areas = areas; _i < _areas.length; _i++) { var area = _areas[_i]; var _iterator = _createForOfIteratorHelper(rows), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var row = _step.value; var rowInputValue = $('#_customize-input-botiga_' + area + '_row__' + row + '_' + area + '_row').val(); if (rowInputValue == '') { $('#_customize-input-botiga_' + area + '_row__' + row + '_' + area + '_row').val(botiga_hfb.rows.defaults[row + '_' + area + '_row']); } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } // Mobile offcanvas row var mobileOffcanvasRowInputValue = $('#_customize-input-botiga_header_row__mobile_offcanvas').val(); if (mobileOffcanvasRowInputValue == '') { $('#_customize-input-botiga_header_row__mobile_offcanvas').val(botiga_hfb.rows.defaults['mobile_offcanvas']); } }, customizeNavigation: function customizeNavigation() { var sections = ['sub-accordion-section-botiga_section_hb_presets', 'sub-accordion-section-botiga_section_hb_above_header_row', 'sub-accordion-section-botiga_section_hb_main_header_row', 'sub-accordion-section-botiga_section_hb_below_header_row', 'sub-accordion-section-botiga_section_hb_mobile_offcanvas', 'sub-accordion-section-botiga_section_hb_component__logo', 'sub-accordion-section-botiga_section_hb_component__search', 'sub-accordion-section-botiga_section_hb_component__social', 'sub-accordion-section-botiga_section_hb_component__menu', 'sub-accordion-section-botiga_section_hb_component__secondary_menu', 'sub-accordion-section-botiga_section_hb_component__contact_info', 'sub-accordion-section-botiga_section_hb_component__button', 'sub-accordion-section-botiga_section_hb_component__button2', 'sub-accordion-section-botiga_section_hb_component__html', 'sub-accordion-section-botiga_section_hb_component__html2', 'sub-accordion-section-botiga_section_hb_component__shortcode', 'sub-accordion-section-botiga_section_hb_component__login_register', 'sub-accordion-section-botiga_section_hb_component__woo_icons', 'sub-accordion-section-botiga_section_hb_component__pll_switcher', 'sub-accordion-section-botiga_section_hb_component__wpml_switcher', 'sub-accordion-section-botiga_section_hb_component__mobile_offcanvas_menu', 'sub-accordion-section-botiga_section_hb_component__mobile_hamburger', // Footer 'sub-accordion-section-botiga_section_fb_above_footer_row', 'sub-accordion-section-botiga_section_fb_main_footer_row', 'sub-accordion-section-botiga_section_fb_below_footer_row', 'sub-accordion-section-botiga_section_fb_component__footer_menu', 'sub-accordion-section-botiga_section_fb_component__copyright', 'sub-accordion-section-botiga_section_fb_component__social', 'sub-accordion-section-botiga_section_fb_component__button', 'sub-accordion-section-botiga_section_fb_component__button2', 'sub-accordion-section-botiga_section_fb_component__html', 'sub-accordion-section-botiga_section_fb_component__html2', 'sub-accordion-section-botiga_section_fb_component__shortcode', 'sub-accordion-section-botiga_section_fb_component__widget1', 'sub-accordion-section-botiga_section_fb_component__widget2', 'sub-accordion-section-botiga_section_fb_component__widget3', 'sub-accordion-section-botiga_section_fb_component__widget4']; // Append columns to the sections array. var rows = ['above', 'main', 'below']; for (var _i2 = 0, _rows = rows; _i2 < _rows.length; _i2++) { var row = _rows[_i2]; for (var i = 1; i <= 6; i++) { sections.push('sub-accordion-section-botiga_header_row__' + row + '_header_row_column' + i); sections.push('sub-accordion-section-botiga_footer_row__' + row + '_footer_row_column' + i); } } var current_section_id = ''; $(document).on('mouseover focus', '.customize-section-back', function (e) { current_section_id = $('.control-section.open').attr('id'); }); $(document).on('click keydown', '.customize-section-back', function (e) { if (sections.includes(current_section_id)) { // header columns. if (current_section_id.indexOf('above_header_row_column') !== -1) { wp.customize.section('botiga_section_hb_above_header_row').focus(); return false; } if (current_section_id.indexOf('main_header_row_column') !== -1) { wp.customize.section('botiga_section_hb_main_header_row').focus(); return false; } if (current_section_id.indexOf('below_header_row_column') !== -1) { wp.customize.section('botiga_section_hb_below_header_row').focus(); return false; } // footer columns. if (current_section_id.indexOf('above_footer_row_column') !== -1) { wp.customize.section('botiga_section_fb_above_footer_row').focus(); return false; } if (current_section_id.indexOf('main_footer_row_column') !== -1) { wp.customize.section('botiga_section_fb_main_footer_row').focus(); return false; } if (current_section_id.indexOf('below_footer_row_column') !== -1) { wp.customize.section('botiga_section_fb_below_footer_row').focus(); return false; } // header/footer row and components. if (current_section_id.indexOf('_hb_') !== -1 || current_section_id.indexOf('_header_') !== -1) { wp.customize.section('botiga_section_hb_wrapper').focus(); } else { wp.customize.section('botiga_section_fb_wrapper').focus(); } } }); }, storeGlobals: function storeGlobals() { var _this = this; // Current Device. $(' .wp-full-overlay-footer .devices button, .botiga-devices-preview button').on('click', function () { var device = $(this).attr('data-device'); if (device === 'tablet') { device = 'mobile'; } if (_this.currentBuilderType === 'footer') { device = 'desktop'; } _this.currentDevice = device; _this.builderGridContent(); }); // Column Area. $(document).on('click mouseover', '.botiga-bhfb-area:not(.bhfb-available-components)', function (e) { if ($('#botiga-bhfb-elements').hasClass('show')) { return false; } _this.currentRowInput = $('#_customize-input-botiga_' + _this.currentBuilderType + '_row__' + $(this).data('bhfb-row')); _this.currentRow = $(this).closest('.botiga-bhfb-row'); _this.currentColumnPos = $(this).index() - 1; _this.currentColumn = $(this); if (!_this.currentRow.length && $(this).hasClass('botiga-bhfb-area-offcanvas')) { _this.currentRowInput = $('#_customize-input-botiga_header_row__mobile_offcanvas'); _this.currentRow = $('.botiga-bhfb-area-offcanvas'); _this.currentColumnPos = $(this).index(); } }); $(document).on('click mouseover', '.bhfb-button', function (e) { _this.currentComponent = $(this).data('bhfb-id'); }); }, devicesSwitcher: function devicesSwitcher() { var _this = this; $(' .wp-full-overlay-footer .devices button, .botiga-devices-preview button').on('click', function () { var device = $(this).attr('data-device'); if (device === 'mobile') { device = 'tablet'; } $('.botiga-bhfb-devices .botiga-bhfb-device-link').removeClass('active'); $('.botiga-bhfb-devices .botiga-bhfb-device-link[data-device="' + device + '"]').addClass('active'); }); $('.botiga-bhfb-devices .botiga-bhfb-device-link').on('click', function (e) { e.preventDefault(); var device = $(this).attr('data-device'); $(' .wp-full-overlay-footer .devices button[data-device="' + device + '"]').trigger('click'); }); }, getElementsUnused: function getElementsUnused() { var _this = this; var elements = botiga_hfb.components.desktop, mb_elements = botiga_hfb.components.mobile; var fields = ['#_customize-input-botiga_header_row__above_header_row', '#_customize-input-botiga_header_row__main_header_row', '#_customize-input-botiga_header_row__below_header_row', '#_customize-input-botiga_header_row__mobile_offcanvas']; if (_this.currentBuilderType === 'footer') { elements = botiga_hfb.components.footer; fields = ['#_customize-input-botiga_footer_row__above_footer_row', '#_customize-input-botiga_footer_row__main_footer_row', '#_customize-input-botiga_footer_row__below_footer_row']; } for (var _i3 = 0, _fields = fields; _i3 < _fields.length; _i3++) { var field = _fields[_i3]; // desktop var _iterator2 = _createForOfIteratorHelper(elements), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var el = _step2.value; var input_value = this.jsonDecode($(field).val()); if (input_value.desktop.length) { var _iterator4 = _createForOfIteratorHelper(input_value.desktop), _step4; try { var _loop = function _loop() { var column = _step4.value; elements = elements.filter(function (item) { return !column.includes(item.id); }); }; for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { _loop(); } } catch (err) { _iterator4.e(err); } finally { _iterator4.f(); } } } // mobile } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } var _iterator3 = _createForOfIteratorHelper(mb_elements), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var el = _step3.value; var _input_value = this.jsonDecode($(field).val()); if (_input_value.mobile.length) { var _iterator5 = _createForOfIteratorHelper(_input_value.mobile), _step5; try { var _loop2 = function _loop2() { var column = _step5.value; mb_elements = mb_elements.filter(function (item) { return !column.includes(item.id); }); }; for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { _loop2(); } } catch (err) { _iterator5.e(err); } finally { _iterator5.f(); } } // off-canvas if (field.indexOf('row__mobile_offcanvas') !== -1 && _input_value.mobile_offcanvas.length) { var _iterator6 = _createForOfIteratorHelper(_input_value.mobile_offcanvas), _step6; try { var _loop3 = function _loop3() { var column = _step6.value; mb_elements = mb_elements.filter(function (item) { return !column.includes(item.id); }); }; for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { _loop3(); } } catch (err) { _iterator6.e(err); } finally { _iterator6.f(); } } } } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } } return { desktop: elements, mobile: mb_elements }; }, elementsPopup: function elementsPopup() { var _this = this; $(document).on('click', '.botiga-bhfb-area:not(.bhfb-available-components)', function (e) { var popup = _this.currentBuilder.find('#botiga-bhfb-elements'), rect = $(this)[0].getBoundingClientRect(), row = $(this).data('bhfb-row'); setTimeout(function () { popup.css('top', 0); popup.css('left', rect.left); popup.css('top', rect.top - (popup.height() + 50)); if (_this.isElementInViewport(popup)) { popup.css('left', rect.left); popup.css('right', 'auto'); } else { popup.css('left', 'auto'); popup.css('right', 25); } if (e.target.classList.contains('bhfb-remove-element') || e.target.classList.contains('bhfb-button')) { return false; } popup.addClass('show'); }, 200); _this.elementsPopupContent(row); _this.builderGridContent(); }); $('#customize-preview iframe').on('mouseup', function (e) { _this.closeElementsPopup(e); }); $(document).on('mouseup', function (e) { if (!_this.currentBuilder) { return false; } _this.closeElementsPopup(e); }); }, closeElementsPopup: function closeElementsPopup(e) { var _this = this, popup = _this.currentBuilder.find('#botiga-bhfb-elements'); if (e.target.closest('#botiga-bhfb-elements') === null) { popup.removeClass('show'); } }, isElementInViewport: function isElementInViewport(el) { if (typeof jQuery === "function" && el instanceof jQuery) { el = el[0]; } var rect = el.getBoundingClientRect(); return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || $(window).height()) && rect.right <= (window.innerWidth || $(window).width()); }, elementsPopupContent: function elementsPopupContent() { var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var _this = this, elements = this.getElementsUnused(), elementsWrapper = $('.botiga-bhfb-elements-desktop'), mobileElementsWrapper = $('.botiga-bhfb-elements-mobile'); elementsWrapper.html(''); mobileElementsWrapper.html(''); var cprefix = 'hb'; if (_this.currentBuilderType && _this.currentBuilderType === 'footer') { cprefix = 'fb'; } if (elements.desktop.length) { var _iterator7 = _createForOfIteratorHelper(elements.desktop), _step7; try { for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { var element = _step7.value; elementsWrapper.append('
").concat(botiga_hfb.upsell_components.total, "
\n ").concat(botiga_hfb.upsell_components.button, "\n