/*! * 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 allPresetValues, colorPresetKeys, colorPresetVariables, Color */ (function ($) { // Variables Based on Preset var getColorKeysFromPreset = function getColorKeysFromPreset(preset) { return colorPresetVariables.map(function (variable) { return preset + '_' + variable; }); }; // StyleSheet Template // let styleSheetTemplate = wp.template('beetan-color-preset-css'); // Generate the CSS for the current Color Scheme. var updateStyleSheet = function updateStyleSheet() { var currentPreset = wp.customize('color_preset')(); // Merge in color scheme overrides. /*_.each(colorSettings, function (setting) { colors[setting] = api(setting)(); });*/ //css = cssTemplate(colors); var colorVariables = colorPresetVariables.reduce(function (variables, variable) { var key = currentPreset + '_' + variable; variables[variable] = wp.customize(key)(); return variables; }, {}); // console.log(colorVariables); // let styleSheet = styleSheetTemplate(colorVariables); wp.customize.previewer.send('update-color-preset-css', colorVariables); }; // Toggle Control Based on Preset var toggleControl = function toggleControl(presetValues, currentVariables) { _.difference(presetValues, currentVariables).map(function (key) { wp.customize.control(key, function (control) { control.container.hide(); }); }); _.intersection(presetValues, currentVariables).map(function (key) { wp.customize.control(key, function (control) { control.container.show(); }); }); updateStyleSheet(); }; wp.customize.bind('ready', function () { // Preset wp.customize('color_preset', function (value) { var currentPreset = value.get(); var currentVariables = getColorKeysFromPreset(currentPreset); toggleControl(allPresetValues, currentVariables); // On Change value.bind(function (changedPreset) { currentVariables = getColorKeysFromPreset(changedPreset); toggleControl(allPresetValues, currentVariables); }); }); // Preset Colors allPresetValues.map(function (setting) { wp.customize(setting, function (value) { value.bind(updateStyleSheet); }); }); }); })(jQuery); /******/ })() ;