/*! * Beetan Theme * * Author: StorePress ( StorePressHQ@gmail.com ) * Date: 7/19/2022, 8:39:54 PM * Released under the GPLv3 license. */ /******/ (function() { // webpackBootstrap var __webpack_exports__ = {}; /*global wp, CustomizeTypographyObject*/ var Customize_Typography_Control = { isStandardFont: function isStandardFont(value) { return value.trim() == '' || Object.keys(CustomizeTypographyObject.standardFonts).includes(value.trim()); }, hideStyle: function hideStyle(value) { if (value.trim() == '') { this.container.hide(); } else { this.container.show(); } }, hideSubset: function hideSubset(value) { if (this.isStandardFont(value.trim())) { this.container.hide(); } else { this.container.show(); } }, changeStyle: function changeStyle(value) { var _this = this; wp.customize.control("".concat(this.params.extras.id, "[style]"), function (styleControl) { // control.container.hide(); var $selector = jQuery('.customize-control-typography-input', styleControl.container); var fontStyles = []; // console.log(styleControl.params.extras, styleControl.setting.get()); $selector.select2().select2("destroy"); $selector.find('option').each(function () { jQuery(this).remove(); }); if (_this.isStandardFont(value.trim())) { fontStyles = Object.keys(CustomizeTypographyObject.standardFontStyles).reduce(function (data, id) { data.push({ id: id, text: CustomizeTypographyObject.standardFontStyles[id] }); return data; }, []); } else { var varients = _.isUndefined(CustomizeTypographyObject.googleFonts[value.trim()]) ? {} : CustomizeTypographyObject.googleFonts[value.trim()].variants; fontStyles = Object.keys(varients).reduce(function (data, id) { data.push({ id: id, text: CustomizeTypographyObject.googleFonts[value.trim()].variants[id] }); return data; }, []); } $selector.select2({ data: fontStyles, allowClear: true, placeholder: styleControl.params.placeholder }).val(styleControl.setting.get()).trigger("change"); }); }, changeSubset: function changeSubset(value) { var _this2 = this; wp.customize.control("".concat(this.params.extras.id, "[subset]"), function (subsetControl) { // control.container.hide(); var $selector = jQuery('.customize-control-typography-input', subsetControl.container); var fontSubsets = []; // console.log(subsetControl.params.extras, subsetControl.setting.get()); $selector.select2().select2("destroy"); $selector.find('option').each(function () { jQuery(this).remove(); }); if (!_this2.isStandardFont(value.trim())) { var subsets = _.isUndefined(CustomizeTypographyObject.googleFonts[value.trim()]) ? {} : CustomizeTypographyObject.googleFonts[value.trim()].subsets; fontSubsets = Object.keys(subsets).reduce(function (data, id) { data.push({ id: id, text: CustomizeTypographyObject.googleFonts[value.trim()].subsets[id] }); return data; }, []); } $selector.select2({ data: fontSubsets, allowClear: true, placeholder: subsetControl.params.placeholder }).val(subsetControl.setting.get()).trigger("change"); }); }, ready: function ready() { var _this3 = this; // Select2 Init jQuery('.customize-control-typography-input', this.container).select2({ allowClear: true, placeholder: this.params.placeholder }).on('select2:unselecting', function () { _this3.setting.set(''); // this.container.find('[data-customize-setting-link]').trigger('change'); }); // Font Family Changed if (this.id == "".concat(this.params.extras.id, "[family]")) { wp.customize(this.id, function (value) { _this3.changeStyle(value.get()); _this3.changeSubset(value.get()); value.bind(function (changedValue) { _this3.changeStyle(changedValue); _this3.changeSubset(changedValue); }); }); } // Hide Style Based On Family if (this.id == "".concat(this.params.extras.id, "[style]")) { wp.customize("".concat(this.params.extras.id, "[family]"), function (value) { _this3.hideStyle(value.get()); value.bind(function (changedValue) { _this3.hideStyle(changedValue); }); }); } // Hide Style Based On Family if (this.id == "".concat(this.params.extras.id, "[subset]")) { wp.customize("".concat(this.params.extras.id, "[family]"), function (value) { _this3.hideSubset(value.get()); value.bind(function (changedValue) { _this3.hideSubset(changedValue); }); }); } // Hide Size Based On Family /*if (this.id == `${this.params.extras.id}[size]`) { wp.customize(`${this.params.extras.id}[family]`, (value) => { this.hideSize(value.get()); value.bind((changedValue) => { this.hideSize(changedValue); }); }); }*/ } }; wp.customize.controlConstructor['typography'] = wp.customize.Control.extend(Customize_Typography_Control); /******/ })() ;