2014-10-14 21:48:19 +02:00
|
|
|
/* global colorScheme */
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
/**
|
2014-11-07 18:20:22 +01:00
|
|
|
* Add a listener to the Color Scheme control to update other color controls to new values/defaults.
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
*/
|
|
|
|
|
2014-10-31 21:45:22 +01:00
|
|
|
( function( api ) {
|
2014-11-07 21:55:23 +01:00
|
|
|
var cssTemplate = wp.template( 'twentyfifteen-color-scheme' ),
|
|
|
|
colorSchemeKeys = [
|
|
|
|
'background_color',
|
|
|
|
'header_background_color',
|
|
|
|
'box_background_color',
|
|
|
|
'textcolor',
|
|
|
|
'sidebar_textcolor',
|
|
|
|
'meta_box_background_color'
|
|
|
|
],
|
|
|
|
colorSettings = [
|
|
|
|
'background_color',
|
|
|
|
'header_background_color',
|
|
|
|
'sidebar_textcolor'
|
|
|
|
];
|
|
|
|
|
2014-10-31 21:45:22 +01:00
|
|
|
api.controlConstructor.select = api.Control.extend( {
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
ready: function() {
|
2014-10-17 22:52:19 +02:00
|
|
|
if ( 'color_scheme' === this.id ) {
|
|
|
|
this.setting.bind( 'change', function( value ) {
|
2014-10-31 21:45:22 +01:00
|
|
|
// Update Background Color.
|
|
|
|
api( 'background_color' ).set( colorScheme[value].colors[0] );
|
|
|
|
api.control( 'background_color' ).container.find( '.color-picker-hex' )
|
2014-10-17 22:52:19 +02:00
|
|
|
.data( 'data-default-color', colorScheme[value].colors[0] )
|
|
|
|
.wpColorPicker( 'defaultColor', colorScheme[value].colors[0] );
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
|
2014-10-31 21:45:22 +01:00
|
|
|
// Update Header/Sidebar Background Color.
|
|
|
|
api( 'header_background_color' ).set( colorScheme[value].colors[1] );
|
|
|
|
api.control( 'header_background_color' ).container.find( '.color-picker-hex' )
|
2014-10-17 22:52:19 +02:00
|
|
|
.data( 'data-default-color', colorScheme[value].colors[1] )
|
|
|
|
.wpColorPicker( 'defaultColor', colorScheme[value].colors[1] );
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
|
2014-11-04 19:42:22 +01:00
|
|
|
// Update Header/Sidebar Text Color.
|
2014-10-31 21:45:22 +01:00
|
|
|
api( 'sidebar_textcolor' ).set( colorScheme[value].colors[4] );
|
|
|
|
api.control( 'sidebar_textcolor' ).container.find( '.color-picker-hex' )
|
2014-10-17 22:52:19 +02:00
|
|
|
.data( 'data-default-color', colorScheme[value].colors[4] )
|
|
|
|
.wpColorPicker( 'defaultColor', colorScheme[value].colors[4] );
|
|
|
|
} );
|
|
|
|
}
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
}
|
|
|
|
} );
|
2014-11-07 21:55:23 +01:00
|
|
|
|
|
|
|
function getCSS() {
|
|
|
|
var scheme = api( 'color_scheme' )(),
|
|
|
|
colors = _.object( colorSchemeKeys, colorScheme[ scheme ].colors );
|
|
|
|
|
|
|
|
// Merge in color scheme overrides.
|
|
|
|
_.each( colorSettings, function( setting ) {
|
|
|
|
colors[ setting ] = api( setting )();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Add additional colors.
|
|
|
|
colors['secondary_textcolor'] = Color( colors.textcolor ).toCSS( 'rgba', 0.7 );
|
|
|
|
colors['border_color'] = Color( colors.textcolor ).toCSS( 'rgba', 0.1 );
|
|
|
|
colors['border_focus_color'] = Color( colors.textcolor ).toCSS( 'rgba', 0.3 );
|
|
|
|
colors['sidebar_textcolor2'] = Color( colors.sidebar_textcolor ).toCSS( 'rgba', 0.7 );
|
|
|
|
colors['sidebar_border_color'] = Color( colors.sidebar_textcolor ).toCSS( 'rgba', 0.1 );
|
|
|
|
colors['sidebar_border_focus_color'] = Color( colors.sidebar_textcolor ).toCSS( 'rgba', 0.3 );
|
|
|
|
|
|
|
|
return cssTemplate( colors );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the CSS whenever a color setting is changed.
|
|
|
|
_.each( colorSettings, function( setting ) {
|
|
|
|
api( setting, function( setting ) {
|
|
|
|
setting.bind( _.throttle( function( value ) {
|
|
|
|
api( 'color_scheme_css' ).set( getCSS() );
|
|
|
|
}, 250 ) );
|
|
|
|
} );
|
|
|
|
} );
|
2014-10-31 21:45:22 +01:00
|
|
|
} )( wp.customize );
|