2020-04-07 13:03:04 +00:00
|
|
|
( function( $, api ) {
|
|
|
|
/**
|
|
|
|
* Set some controls when we're using the navigation as a header.
|
|
|
|
*
|
|
|
|
* @since 1.8
|
2021-07-25 23:25:02 +00:00
|
|
|
*/
|
2020-04-07 13:03:04 +00:00
|
|
|
api( 'generate_menu_plus_settings[navigation_as_header]', function( value ) {
|
|
|
|
value.bind( function( newval ) {
|
|
|
|
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' ),
|
|
|
|
navAlignment = gpControls.navigationAlignment,
|
|
|
|
siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' ),
|
|
|
|
mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
|
|
|
|
siteTitleFontSize = gpControls.siteTitleFontSize,
|
|
|
|
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize,
|
|
|
|
mobileHeader = api.instance( 'generate_menu_plus_settings[mobile_header]' ).get(),
|
|
|
|
navTextColorSetting = api.instance( 'generate_settings[navigation_text_color]' ),
|
|
|
|
navTextColor = gpControls.navigationTextColor,
|
2020-10-20 15:16:06 +00:00
|
|
|
siteTitleTextColorSetting = api.instance( 'generate_settings[site_title_color]' ),
|
|
|
|
siteTitleTextColor = gpControls.siteTitleTextColor;
|
2020-04-07 13:03:04 +00:00
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( siteTitleFontSizeSetting && ! siteTitleFontSizeSetting._dirty && 25 !== siteTitleFontSizeSetting.get() ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
siteTitleFontSize = siteTitleFontSizeSetting.get();
|
|
|
|
}
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( mobileSiteTitleFontSizeSetting && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
|
|
|
|
}
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( navTextColorSetting && ! navTextColorSetting._dirty ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
navTextColor = navTextColorSetting.get();
|
|
|
|
}
|
|
|
|
|
2020-10-20 15:16:06 +00:00
|
|
|
if ( siteTitleTextColorSetting && ! siteTitleTextColorSetting._dirty ) {
|
|
|
|
siteTitleTextColor = siteTitleTextColorSetting.get();
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( newval ) {
|
|
|
|
navAlignmentSetting.set( 'right' );
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( siteTitleFontSizeSetting ) {
|
|
|
|
siteTitleFontSizeSetting.set( 25 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
|
|
|
|
api.instance( 'generate_settings[site_title_color]' ).set( navTextColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
mobileSiteTitleFontSizeSetting.set( 20 );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
navAlignmentSetting.set( navAlignment );
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( siteTitleFontSizeSetting ) {
|
|
|
|
siteTitleFontSizeSetting.set( siteTitleFontSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
|
2020-10-20 15:16:06 +00:00
|
|
|
api.instance( 'generate_settings[site_title_color]' ).set( siteTitleTextColor );
|
2020-08-13 14:53:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
mobileSiteTitleFontSizeSetting.set( mobileSiteTitleFontSize );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
var showRegularHeader,
|
2021-07-25 23:25:02 +00:00
|
|
|
showRegularHeaderCallback;
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether we should display our header controls.
|
|
|
|
*
|
2021-07-25 23:25:02 +00:00
|
|
|
* @return {boolean} Whether we should show the regular header.
|
2020-04-07 13:03:04 +00:00
|
|
|
*/
|
|
|
|
showRegularHeader = function() {
|
|
|
|
if ( value.get() ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update a control's active state according to the navigation as header option.
|
|
|
|
*
|
2021-07-25 23:25:02 +00:00
|
|
|
* @param {wp.customize.Control} control The current control.
|
2020-04-07 13:03:04 +00:00
|
|
|
*/
|
|
|
|
showRegularHeaderCallback = function( control ) {
|
|
|
|
var setActiveState = function() {
|
|
|
|
control.active.set( showRegularHeader() );
|
|
|
|
};
|
|
|
|
|
|
|
|
control.active.validate = showRegularHeader;
|
|
|
|
setActiveState();
|
|
|
|
value.bind( setActiveState );
|
|
|
|
};
|
|
|
|
|
|
|
|
api.control( 'generate_header_helper', showRegularHeaderCallback );
|
|
|
|
api.control( 'generate_settings[header_layout_setting]', showRegularHeaderCallback );
|
|
|
|
api.control( 'generate_settings[header_inner_width]', showRegularHeaderCallback );
|
|
|
|
api.control( 'generate_settings[header_alignment_setting]', showRegularHeaderCallback );
|
|
|
|
api.control( 'header_spacing', showRegularHeaderCallback );
|
|
|
|
api.control( 'generate_settings[header_background_color]', showRegularHeaderCallback );
|
|
|
|
api.control( 'header_text_color', showRegularHeaderCallback );
|
|
|
|
api.control( 'header_link_color', showRegularHeaderCallback );
|
|
|
|
api.control( 'header_link_hover_color', showRegularHeaderCallback );
|
|
|
|
api.control( 'site_tagline_color', showRegularHeaderCallback );
|
|
|
|
api.control( 'font_site_tagline_control', showRegularHeaderCallback );
|
|
|
|
api.control( 'generate_settings[site_tagline_font_size]', showRegularHeaderCallback );
|
|
|
|
api.control( 'generate_settings[nav_position_setting]', showRegularHeaderCallback );
|
|
|
|
api.control( 'generate_settings[logo_width]', showRegularHeaderCallback );
|
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the navigation branding font size label on mobile header branding change.
|
|
|
|
*
|
|
|
|
* @since 1.8
|
2021-07-25 23:25:02 +00:00
|
|
|
*/
|
2020-04-07 13:03:04 +00:00
|
|
|
api( 'generate_menu_plus_settings[mobile_header_branding]', function( value ) {
|
|
|
|
value.bind( function( newval ) {
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) && 'title' === newval ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the navigation branding font size label on mobile header change.
|
|
|
|
*
|
|
|
|
* @since 1.8
|
2021-07-25 23:25:02 +00:00
|
|
|
*/
|
2020-04-07 13:03:04 +00:00
|
|
|
api( 'generate_menu_plus_settings[mobile_header]', function( value ) {
|
|
|
|
value.bind( function( newval ) {
|
|
|
|
var mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
|
|
|
|
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize;
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( mobileSiteTitleFontSizeSetting && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
|
|
|
|
}
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
if ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) ) {
|
|
|
|
if ( 'enable' === newval ) {
|
|
|
|
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
|
|
|
|
} else {
|
|
|
|
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( mobileSiteTitleFontSize );
|
|
|
|
}
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
2021-07-25 23:25:02 +00:00
|
|
|
}( jQuery, wp.customize ) );
|