/* global colorScheme, Color */ /** * Add a listener to the Color Scheme control to update other color controls to new values/defaults. * Also trigger an update of the Color Scheme CSS when a color is changed. */ ( function( api ) { var cssTemplate = wp.template( 'adoration-color-scheme' ), colorSchemeKeys = [ 'background_color', 'link_button_color' ], colorSettings = [ 'background_color', 'link_button_color' ]; // Generate the CSS for the current Color Scheme. function updateCSS() { var scheme = api( 'color_scheme' )(), css, colors = _.object( colorSchemeKeys, colorScheme[ scheme ].colors ); // Merge in color scheme overrides. _.each( colorSettings, function( setting ) { colors[ setting ] = api( setting )(); }); css = cssTemplate( colors ); api.previewer.send( 'update-color-scheme-css', css ); } // Update the CSS whenever a color setting is changed. _.each( colorSettings, function( setting ) { api( setting, function( setting ) { setting.bind( updateCSS ); } ); } ); } )( wp.customize );