/******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./assets/src/scss/customizer.scss": /*!*****************************************!*\ !*** ./assets/src/scss/customizer.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/customizer.js ***! \*************************************/ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _scss_customizer_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scss/customizer.scss */ "./assets/src/scss/customizer.scss"); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /* global ayyashCustomizerFontsL10n */ // noinspection JSUnusedGlobalSymbols,JSUnresolvedVariable (function ($, document, ayyashCustomizerFontsL10n) { var wpApi = wp.customize; var settingsLink = 'data-customize-setting-link'; var fontChosen = { cache: {}, init: function init() { fontChosen.buildFonts(); fontChosen.showFonts(); }, buildFonts: function buildFonts() { fontChosen.cache.fonts = ''; fontChosen.cache.chosen = {}; $.each(ayyashCustomizerFontsL10n, function (name, options) { var disabled = ''; if (options['disabled'] !== undefined) { disabled = ' disabled="disabled" '; } fontChosen.cache.fonts += ''; }); }, populateVariants: function populateVariants($el, font) { if ($el.length > 0 && ayyashCustomizerFontsL10n[font] !== undefined) { $el = $el.find('select'); $el.html(fontChosen.showVariants(ayyashCustomizerFontsL10n[font]['variants'])).children('option:first').attr('selected', 'selected'); $el.trigger('change'); } }, showFonts: function showFonts() { $(".chosen-select").each(function () { var $el = $(this); var key = $el.attr(settingsLink); fontChosen.cache.chosen[key] = $(this); wpApi(key, function (setting) { $el.on('chosen:ready', function () { var v = setting.get(); $(this).html(fontChosen.cache.fonts).val(v); setTimeout(function () { $el.trigger('chosen:updated'); }, 200); }); $el.on('change', function () { var $select = $(this); var font = $select.val(); var $varId = '#' + $select.closest('li').attr('id').replace('family', ''); fontChosen.populateVariants($($varId + 'variant'), font); }); $el.chosen({ search_contains: true, width: '100%' }); }); }); fontChosen.showDefaultVariants(); }, showDefaultVariants: function showDefaultVariants() { $('[id$=_variant] select').each(function () { var $el = $(this); var key = $el.attr(settingsLink); var parentKey = key.replace('_variant', '_family'); wpApi(key, function (setting) { if (fontChosen.cache.chosen[parentKey] !== undefined && fontChosen.cache.chosen[parentKey].length > 0) { var val = fontChosen.cache.chosen[parentKey].val(); if (val) { $el.html(fontChosen.showVariants(ayyashCustomizerFontsL10n[val]['variants'])).val(setting.get()); } } }); }); }, showVariants: function showVariants(variants) { var options = ''; options += ''; $.each(variants, function (ind, val) { var name = val.replace('italic', ' Italic').replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); options += ''; }); return options; } }; var multiCheckboxes = { init: function init() { /* === Checkbox Multiple Control === */ $('.customize-control-checkbox-multiple input[type="checkbox"]').on('change', function () { var checkbox_values = $(this).parents('.customize-control').find('input[type="checkbox"]:checked').map(function () { return this.value; }).get().join(','); $(this).parents('.customize-control').find('input[type="hidden"]').val(checkbox_values).trigger('change'); }); } }; $(document).ready(function () { multiCheckboxes.init(); fontChosen.init(); $('.customize-control input[type="range"]').on('change input', function () { var name = $(this).attr('name'); $('input[type="text"][data-name="' + name + '"]').val($(this).val()); }).trigger('change'); // Update the values for all our input fields and initialise the sortable repeater $('.social_profiles').each(function () { var profiles = $(this); var controlId = profiles.data('control-id'); var add = '.' + controlId + 'profile-add'; var remove = '.' + controlId + 'profile-remove'; var move = '.' + controlId + 'profile-move'; var profileClassName = '.social-profile'; var wrapper = profiles.find('.social_profiles_wrap'); var template = wp.template(controlId + '-social-profile'); var valueEl = profiles.find('#' + controlId); var triggerTimeout; var updateValues = function updateValues(now) { now = now || false; var data = []; if (triggerTimeout) { clearTimeout(triggerTimeout); triggerTimeout = null; } profiles.find(profileClassName).each(function () { var profile = $(this); data.push({ label: profile.find('input.label').val(), url: profile.find('input.url').val(), icon: profile.find('input.icon').val() }); }); valueEl.val(JSON.stringify(data)); if (now) { valueEl.trigger('change'); return; } triggerTimeout = setTimeout(function () { return valueEl.trigger('change'); }, 1500); }; var addProfile = function addProfile(idx, data) { return wrapper.append(template(_objectSpread({ index: idx, label: '', url: '', icon: '' }, data))); }; var renderProfiles = function renderProfiles() { try { wrapper.empty(); $.each(JSON.parse(valueEl.val()), addProfile); } catch (e) { console.log(e); } }; var sortableOptions = { handle: move, cancel: 'input', connectWith: '.' + controlId + '_social_profiles', items: '> ' + profileClassName, update: function update() { wrapper.find(profileClassName).each(function (idx) { var title = $(this).find('.field-title h3'); title.text(title.text().replace(/([\d]+)/g, idx + 1)); }); updateValues(true); } }; renderProfiles(); wrapper.sortable(sortableOptions); $(document).on('click', add, function (e) { e.preventDefault(); addProfile(wrapper.find(profileClassName).length, {}); wrapper.sortable('refresh'); }); $(document).on('click', remove, function (e) { e.preventDefault(); var el = $(this).closest(profileClassName); el.slideUp(100, 'linear', function () { el.remove(); wrapper.sortable('refresh'); updateValues(true); renderProfiles(); }); }); $(document).on('change', '.' + controlId + '-trigger', updateValues); }); }); })(jQuery, document, ayyashCustomizerFontsL10n); })(); /******/ })() ;