Start Theme Repo
This commit is contained in:
52
assets/treville/js/customizer-controls.js
Executable file
52
assets/treville/js/customizer-controls.js
Executable file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Customizer Controls JS
|
||||
*
|
||||
* Adds Javascript for Customizer Controls.
|
||||
*
|
||||
* @package Treville
|
||||
*/
|
||||
|
||||
( function( wp, $ ) {
|
||||
|
||||
// Based on https://make.xwp.co/2016/07/24/dependently-contextual-customizer-controls/
|
||||
wp.customize( 'custom_logo', function( setting ) {
|
||||
setting.bind( function( value ) {
|
||||
if ( '' !== value ) {
|
||||
// Set retina logo option to false when a new logo image is uploaded.
|
||||
wp.customize.instance( 'romhackplaza_theme_options[retina_logo]' ).set( false );
|
||||
}
|
||||
});
|
||||
|
||||
var setupControl = function( control ) {
|
||||
var setActiveState, isDisplayed;
|
||||
isDisplayed = function() {
|
||||
return '' !== setting.get();
|
||||
};
|
||||
setActiveState = function() {
|
||||
control.active.set( isDisplayed() );
|
||||
};
|
||||
setActiveState();
|
||||
setting.bind( setActiveState );
|
||||
control.active.validate = isDisplayed;
|
||||
};
|
||||
wp.customize.control( 'romhackplaza_theme_options[retina_logo_title]', setupControl );
|
||||
wp.customize.control( 'romhackplaza_theme_options[retina_logo]', setupControl );
|
||||
} );
|
||||
|
||||
wp.customize( 'romhackplaza_theme_options[blog_layout]', function( setting ) {
|
||||
var setupControl = function( control ) {
|
||||
var setActiveState, isDisplayed;
|
||||
isDisplayed = function() {
|
||||
return 'excerpt' === setting.get();
|
||||
};
|
||||
setActiveState = function() {
|
||||
control.active.set( isDisplayed() );
|
||||
};
|
||||
setActiveState();
|
||||
setting.bind( setActiveState );
|
||||
control.active.validate = isDisplayed;
|
||||
};
|
||||
wp.customize.control( 'romhackplaza_theme_options[excerpt_length]', setupControl );
|
||||
} );
|
||||
|
||||
})( this.wp, jQuery );
|
||||
Reference in New Issue
Block a user