updated theme GeneratePress version 3.1.0

This commit is contained in:
2021-12-20 13:42:43 +00:00
committed by Gitium
parent d5dbb2bde7
commit bdeb131b25
94 changed files with 24875 additions and 20553 deletions

View File

@ -0,0 +1,44 @@
<?php
/**
* Customize API: ColorAlpha class
*
* @package GeneratePress
*/
/**
* Customize Color Control class.
*
* @since 1.0.0
*
* @see WP_Customize_Control
*/
class GeneratePress_Customize_Color_Control extends WP_Customize_Color_Control {
/**
* Type.
*
* @access public
* @since 1.0.0
* @var string
*/
public $type = 'generate-color-control';
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @since 3.4.0
* @uses WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['choices'] = $this->choices;
}
/**
* Empty JS template.
*
* @access public
* @since 1.0.0
* @return void
*/
public function content_template() {}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Customize API: ColorAlpha class
*
* @package GeneratePress
*/
/**
* Customize Color Control class.
*
* @since 1.0.0
*
* @see WP_Customize_Control
*/
class GeneratePress_Customize_React_Control extends WP_Customize_Control {
/**
* Type.
*
* @access public
* @since 1.0.0
* @var string
*/
public $type = 'generate-react-control';
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @since 3.4.0
* @uses WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['choices'] = $this->choices;
}
/**
* Empty JS template.
*
* @access public
* @since 1.0.0
* @return void
*/
public function content_template() {}
/**
* Empty PHP template.
*
* @access public
* @since 1.0.0
* @return void
*/
public function render_content() {}
}

View File

@ -1,501 +1,297 @@
( function( api ) {
'use strict';
// Add callback for when the header_textcolor setting exists.
api( 'generate_settings[nav_position_setting]', function( setting ) {
var isNavFloated, isNavAlignable, setNavDropPointActiveState, setNavAlignmentsActiveState;
/**
* Determine whether the navigation is floating.
*
* @returns {boolean} Is floating?
*/
isNavFloated = function() {
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
return true;
}
return false;
};
/**
* Determine whether the navigation is align-able.
*
* @returns {boolean} Is floating?
*/
isNavAlignable = function() {
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
var navAsHeader = api.instance( 'generate_menu_plus_settings[navigation_as_header]' );
if ( navAsHeader && navAsHeader.get() ) {
return true;
}
return false;
}
return true;
};
/**
* Update a control's active state according to the navigation location setting's value.
*
* @param {wp.customize.Control} control
*/
setNavDropPointActiveState = function( control ) {
var setActiveState = function() {
control.active.set( isNavFloated() );
};
// FYI: With the following we can eliminate all of our PHP active_callback code.
control.active.validate = isNavFloated;
// Set initial active state.
setActiveState();
/*
* Update activate state whenever the setting is changed.
* Even when the setting does have a refresh transport where the
* server-side active callback will manage the active state upon
* refresh, having this JS management of the active state will
* ensure that controls will have their visibility toggled
* immediately instead of waiting for the preview to load.
* This is especially important if the setting has a postMessage
* transport where changing the setting wouldn't normally cause
* the preview to refresh and thus the server-side active_callbacks
* would not get invoked.
*/
setting.bind( setActiveState );
};
/**
* Update a control's active state according to the navigation location setting's value.
*
* @param {wp.customize.Control} control
*/
setNavAlignmentsActiveState = function( control ) {
var setActiveState = function() {
control.active.set( isNavAlignable() );
};
// FYI: With the following we can eliminate all of our PHP active_callback code.
control.active.validate = isNavAlignable;
// Set initial active state.
setActiveState();
/*
* Update activate state whenever the setting is changed.
* Even when the setting does have a refresh transport where the
* server-side active callback will manage the active state upon
* refresh, having this JS management of the active state will
* ensure that controls will have their visibility toggled
* immediately instead of waiting for the preview to load.
* This is especially important if the setting has a postMessage
* transport where changing the setting wouldn't normally cause
* the preview to refresh and thus the server-side active_callbacks
* would not get invoked.
*/
setting.bind( setActiveState );
};
api.control( 'generate_settings[nav_drop_point]', setNavDropPointActiveState );
api.control( 'generate_settings[nav_layout_setting]', setNavAlignmentsActiveState );
api.control( 'generate_settings[nav_inner_width]', setNavAlignmentsActiveState );
api.control( 'generate_settings[nav_alignment_setting]', setNavAlignmentsActiveState );
} );
var setOption = function( options ) {
if ( options.headerAlignment ) {
api.instance( 'generate_settings[header_alignment_setting]' ).set( options.headerAlignment );
}
if ( options.navLocation ) {
api.instance( 'generate_settings[nav_position_setting]' ).set( options.navLocation );
}
if ( options.navAlignment ) {
api.instance( 'generate_settings[nav_alignment_setting]' ).set( options.navAlignment );
}
if ( options.boxAlignment ) {
api.instance( 'generate_settings[container_alignment]' ).set( options.boxAlignment );
}
if ( options.siteTitleFontSize ) {
api.instance( 'generate_settings[site_title_font_size]' ).set( options.siteTitleFontSize );
}
if ( 'undefined' !== typeof options.hideSiteTagline ) {
api.instance( 'generate_settings[hide_tagline]' ).set( options.hideSiteTagline );
}
if ( options.headerPaddingTop ) {
api.instance( 'generate_spacing_settings[header_top]' ).set( options.headerPaddingTop );
}
if ( options.headerPaddingBottom ) {
api.instance( 'generate_spacing_settings[header_bottom]' ).set( options.headerPaddingBottom );
}
};
api( 'generate_header_helper', function( value ) {
var headerAlignment = false,
navLocation = false,
navAlignment = false,
boxAlignment = false,
siteTitleFontSize = false,
hideSiteTagline = false,
headerPaddingTop = false,
headerPaddingBottom = false;
value.bind( function( newval ) {
var headerAlignmentSetting = api.instance( 'generate_settings[header_alignment_setting]' );
var navLocationSetting = api.instance( 'generate_settings[nav_position_setting]' );
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' );
var boxAlignmentSetting = api.instance( 'generate_settings[container_alignment]' );
var siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' );
var hideSiteTaglineSetting = api.instance( 'generate_settings[hide_tagline]' );
var headerPaddingTopSetting = api.instance( 'generate_spacing_settings[header_top]' );
var headerPaddingBottomSetting = api.instance( 'generate_spacing_settings[header_bottom]' );
if ( ! headerAlignmentSetting._dirty ) {
headerAlignment = headerAlignmentSetting.get();
}
if ( ! navLocationSetting._dirty ) {
navLocation = navLocationSetting.get();
}
if ( ! navAlignmentSetting._dirty ) {
navAlignment = navAlignmentSetting.get();
}
if ( ! boxAlignmentSetting._dirty ) {
boxAlignment = boxAlignmentSetting.get();
}
if ( ! siteTitleFontSizeSetting._dirty ) {
siteTitleFontSize = siteTitleFontSizeSetting.get();
}
if ( ! hideSiteTaglineSetting._dirty ) {
hideSiteTagline = hideSiteTaglineSetting.get();
}
if ( ! headerPaddingTopSetting._dirty ) {
headerPaddingTop = headerPaddingTopSetting.get();
}
if ( ! headerPaddingBottomSetting._dirty ) {
headerPaddingBottom = headerPaddingBottomSetting.get();
}
var options = {
headerAlignment: generatepress_defaults.header_alignment_setting,
navLocation: generatepress_defaults.nav_position_setting,
navAlignment: generatepress_defaults.nav_alignment_setting,
boxAlignment: generatepress_defaults.container_alignment,
siteTitleFontSize: generatepress_typography_defaults.site_title_font_size,
hideSiteTagline: generatepress_defaults.hide_tagline,
headerPaddingTop: generatepress_spacing_defaults.header_top,
headerPaddingBottom: generatepress_spacing_defaults.header_bottom,
};
if ( 'current' === newval ) {
options = {
headerAlignment: headerAlignment,
navLocation: navLocation,
navAlignment: navAlignment,
boxAlignment: boxAlignment,
siteTitleFontSize: siteTitleFontSize,
hideSiteTagline: hideSiteTagline,
headerPaddingTop: headerPaddingTop,
headerPaddingBottom: headerPaddingBottom,
};
setOption( options );
}
if ( 'default' === newval ) {
setOption( options );
}
if ( 'classic' === newval ) {
var options = {
headerAlignment: 'left',
navLocation: 'nav-below-header',
navAlignment: 'left',
boxAlignment: 'boxes',
siteTitleFontSize: '45',
hideSiteTagline: '',
headerPaddingTop: '40',
headerPaddingBottom: '40',
};
setOption( options );
}
if ( 'nav-before' === newval ) {
options['headerAlignment'] = 'left';
options['navLocation'] = 'nav-above-header';
options['navAlignment'] = 'left';
setOption( options );
}
if ( 'nav-after' === newval ) {
options['headerAlignment'] = 'left';
options['navLocation'] = 'nav-below-header';
options['navAlignment'] = 'left';
setOption( options );
}
if ( 'nav-before-centered' === newval ) {
options['headerAlignment'] = 'center';
options['navLocation'] = 'nav-above-header';
options['navAlignment'] = 'center';
setOption( options );
}
if ( 'nav-after-centered' === newval ) {
options['headerAlignment'] = 'center';
options['navLocation'] = 'nav-below-header';
options['navAlignment'] = 'center';
setOption( options );
}
if ( 'nav-left' === newval ) {
options['headerAlignment'] = 'left';
options['navLocation'] = 'nav-float-left';
options['navAlignment'] = 'right';
setOption( options );
}
} );
} );
api( 'nav_color_presets', function( value ) {
var backgroundColor = false,
textColor = false,
backgroundColorHover = false,
textColorHover = false,
currentBackgroundColor = false,
currentTextColor = false,
subMenuBackgroundColor = false,
subMenuTextColor = false,
subMenuBackgroundColorHover = false,
subMenuTextColorHover = false,
subMenuCurrentBackgroundColor = false,
subMenuCurrentTextColor = false;
value.bind( function( newval ) {
var backgroundColorSetting = api.instance( 'generate_settings[navigation_background_color]' ),
textColorSetting = api.instance( 'generate_settings[navigation_text_color]' ),
backgroundColorHoverSetting = api.instance( 'generate_settings[navigation_background_hover_color]' ),
textColorHoverSetting = api.instance( 'generate_settings[navigation_text_hover_color]' ),
currentBackgroundColorSetting = api.instance( 'generate_settings[navigation_background_current_color]' ),
currentTextColorSetting = api.instance( 'generate_settings[navigation_text_current_color]' ),
subMenuBackgroundColorSetting = api.instance( 'generate_settings[subnavigation_background_color]' ),
subMenuTextColorSetting = api.instance( 'generate_settings[subnavigation_text_color]' ),
subMenuBackgroundColorHoverSetting = api.instance( 'generate_settings[subnavigation_background_hover_color]' ),
subMenuTextColorHoverSetting = api.instance( 'generate_settings[subnavigation_text_hover_color]' ),
subMenuCurrentBackgroundColorSetting = api.instance( 'generate_settings[subnavigation_background_current_color]' ),
subMenuCurrentTextColorSetting = api.instance( 'generate_settings[subnavigation_text_current_color]' );
if ( ! backgroundColorSetting._dirty ) {
backgroundColor = backgroundColorSetting.get();
}
if ( ! textColorSetting._dirty ) {
textColor = textColorSetting.get();
}
if ( ! backgroundColorHoverSetting._dirty ) {
backgroundColorHover = backgroundColorHoverSetting.get();
}
if ( ! textColorHoverSetting._dirty ) {
textColorHover = textColorHoverSetting.get();
}
if ( ! currentBackgroundColorSetting._dirty ) {
currentBackgroundColor = currentBackgroundColorSetting.get();
}
if ( ! currentTextColorSetting._dirty ) {
currentTextColor = currentTextColorSetting.get();
}
if ( ! subMenuBackgroundColorSetting._dirty ) {
subMenuBackgroundColor = subMenuBackgroundColorSetting.get();
}
if ( ! subMenuTextColorSetting._dirty ) {
subMenuTextColor = subMenuTextColorSetting.get();
}
if ( ! subMenuBackgroundColorHoverSetting._dirty ) {
subMenuBackgroundColorHover = subMenuBackgroundColorHoverSetting.get();
}
if ( ! subMenuTextColorHoverSetting._dirty ) {
subMenuTextColorHover = subMenuTextColorHoverSetting.get();
}
if ( ! subMenuCurrentBackgroundColorSetting._dirty ) {
subMenuCurrentBackgroundColor = subMenuCurrentBackgroundColorSetting.get();
}
if ( ! subMenuCurrentTextColorSetting._dirty ) {
subMenuCurrentTextColor = subMenuCurrentTextColorSetting.get();
}
if ( 'current' === newval ) {
backgroundColorSetting.set( backgroundColor );
textColorSetting.set( textColor );
backgroundColorHoverSetting.set( backgroundColorHover );
textColorHoverSetting.set( textColorHover );
currentBackgroundColorSetting.set( currentBackgroundColor );
currentTextColorSetting.set( currentTextColorSetting );
subMenuBackgroundColorSetting.set( subMenuBackgroundColor );
subMenuTextColorSetting.set( subMenuTextColor );
subMenuBackgroundColorHoverSetting.set( subMenuBackgroundColorHover );
subMenuTextColorHoverSetting.set( subMenuTextColorHover );
subMenuCurrentBackgroundColorSetting.set( subMenuCurrentBackgroundColor );
subMenuCurrentTextColorSetting.set( subMenuCurrentTextColorSetting );
}
if ( 'default' === newval ) {
backgroundColorSetting.set( generatepress_color_defaults.navigation_background_color );
textColorSetting.set( generatepress_color_defaults.navigation_text_color );
backgroundColorHoverSetting.set( generatepress_color_defaults.navigation_background_hover_color );
textColorHoverSetting.set( generatepress_color_defaults.navigation_text_hover_color );
currentBackgroundColorSetting.set( generatepress_color_defaults.navigation_background_current_color );
currentTextColorSetting.set( generatepress_color_defaults.navigation_text_current_color );
subMenuBackgroundColorSetting.set( generatepress_color_defaults.subnavigation_background_color );
subMenuTextColorSetting.set( generatepress_color_defaults.subnavigation_text_color );
subMenuBackgroundColorHoverSetting.set( generatepress_color_defaults.subnavigation_background_hover_color );
subMenuTextColorHoverSetting.set( generatepress_color_defaults.subnavigation_text_hover_color );
subMenuCurrentBackgroundColorSetting.set( generatepress_color_defaults.subnavigation_background_current_color );
subMenuCurrentTextColorSetting.set( generatepress_color_defaults.subnavigation_text_current_color );
}
if ( 'classic' === newval ) {
backgroundColorSetting.set( '#222222' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#3f3f3f' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#3f3f3f' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#3f3f3f' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#4f4f4f' );
subMenuTextColorHoverSetting.set( '#ffffff' );
subMenuCurrentBackgroundColorSetting.set( '#4f4f4f' );
subMenuCurrentTextColorSetting.set( '#ffffff' );
}
if ( 'grey' === newval ) {
backgroundColorSetting.set( '#595959' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#424242' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#424242' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#424242' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#424242' );
subMenuTextColorHoverSetting.set( '#dbdbdb' );
subMenuCurrentBackgroundColorSetting.set( '#424242' );
subMenuCurrentTextColorSetting.set( '#dbdbdb' );
}
if ( 'blue' === newval ) {
backgroundColorSetting.set( '#1e73be' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#035a9e' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#035a9e' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#035a9e' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#035a9e' );
subMenuTextColorHoverSetting.set( '#bbd2e8' );
subMenuCurrentBackgroundColorSetting.set( '#035a9e' );
subMenuCurrentTextColorSetting.set( '#bbd2e8' );
}
if ( 'red' === newval ) {
backgroundColorSetting.set( '#ed4250' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#c42f2f' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#c42f2f' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#c42f2f' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#c42f2f' );
subMenuTextColorHoverSetting.set( '#fcd9d6' );
subMenuCurrentBackgroundColorSetting.set( '#c42f2f' );
subMenuCurrentTextColorSetting.set( '#fcd9d6' );
}
if ( 'green' === newval ) {
backgroundColorSetting.set( '#16aa74' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#119b6d' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#119b6d' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#119b6d' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#119b6d' );
subMenuTextColorHoverSetting.set( '#c2e8de' );
subMenuCurrentBackgroundColorSetting.set( '#119b6d' );
subMenuCurrentTextColorSetting.set( '#c2e8de' );
}
jQuery('.wp-color-picker').wpColorPicker().change();
} );
} );
}( wp.customize ) );
( function( api ) {
'use strict';
// Add callback for when the header_textcolor setting exists.
api( 'generate_settings[nav_position_setting]', function( setting ) {
var isNavFloated, isNavAlignable, setNavDropPointActiveState, setNavAlignmentsActiveState;
/**
* Determine whether the navigation is floating.
*
* @returns {boolean} Is floating?
*/
isNavFloated = function() {
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
return true;
}
return false;
};
/**
* Determine whether the navigation is align-able.
*
* @returns {boolean} Is floating?
*/
isNavAlignable = function() {
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
var navAsHeader = api.instance( 'generate_menu_plus_settings[navigation_as_header]' );
if ( navAsHeader && navAsHeader.get() ) {
return true;
}
return false;
}
return true;
};
/**
* Update a control's active state according to the navigation location setting's value.
*
* @param {wp.customize.Control} control
*/
setNavDropPointActiveState = function( control ) {
var setActiveState = function() {
control.active.set( isNavFloated() );
};
// FYI: With the following we can eliminate all of our PHP active_callback code.
control.active.validate = isNavFloated;
// Set initial active state.
setActiveState();
/*
* Update activate state whenever the setting is changed.
* Even when the setting does have a refresh transport where the
* server-side active callback will manage the active state upon
* refresh, having this JS management of the active state will
* ensure that controls will have their visibility toggled
* immediately instead of waiting for the preview to load.
* This is especially important if the setting has a postMessage
* transport where changing the setting wouldn't normally cause
* the preview to refresh and thus the server-side active_callbacks
* would not get invoked.
*/
setting.bind( setActiveState );
};
/**
* Update a control's active state according to the navigation location setting's value.
*
* @param {wp.customize.Control} control
*/
setNavAlignmentsActiveState = function( control ) {
var setActiveState = function() {
control.active.set( isNavAlignable() );
};
// FYI: With the following we can eliminate all of our PHP active_callback code.
control.active.validate = isNavAlignable;
// Set initial active state.
setActiveState();
/*
* Update activate state whenever the setting is changed.
* Even when the setting does have a refresh transport where the
* server-side active callback will manage the active state upon
* refresh, having this JS management of the active state will
* ensure that controls will have their visibility toggled
* immediately instead of waiting for the preview to load.
* This is especially important if the setting has a postMessage
* transport where changing the setting wouldn't normally cause
* the preview to refresh and thus the server-side active_callbacks
* would not get invoked.
*/
setting.bind( setActiveState );
};
api.control( 'generate_settings[nav_drop_point]', setNavDropPointActiveState );
api.control( 'generate_settings[nav_layout_setting]', setNavAlignmentsActiveState );
api.control( 'generate_settings[nav_inner_width]', setNavAlignmentsActiveState );
api.control( 'generate_settings[nav_alignment_setting]', setNavAlignmentsActiveState );
} );
var setOption = function( options ) {
if ( options.headerAlignment ) {
api.instance( 'generate_settings[header_alignment_setting]' ).set( options.headerAlignment );
}
if ( options.navLocation ) {
api.instance( 'generate_settings[nav_position_setting]' ).set( options.navLocation );
}
if ( options.navAlignment ) {
api.instance( 'generate_settings[nav_alignment_setting]' ).set( options.navAlignment );
}
if ( options.boxAlignment ) {
api.instance( 'generate_settings[container_alignment]' ).set( options.boxAlignment );
}
if ( options.siteTitleFontSize ) {
api.instance( 'generate_settings[site_title_font_size]' ).set( options.siteTitleFontSize );
}
if ( 'undefined' !== typeof options.hideSiteTagline ) {
api.instance( 'generate_settings[hide_tagline]' ).set( options.hideSiteTagline );
}
if ( options.headerPaddingTop ) {
api.instance( 'generate_spacing_settings[header_top]' ).set( options.headerPaddingTop );
}
if ( options.headerPaddingBottom ) {
api.instance( 'generate_spacing_settings[header_bottom]' ).set( options.headerPaddingBottom );
}
};
api( 'generate_header_helper', function( value ) {
var headerAlignment = false,
navLocation = false,
navAlignment = false,
boxAlignment = false,
siteTitleFontSize = false,
hideSiteTagline = false,
headerPaddingTop = false,
headerPaddingBottom = false;
value.bind( function( newval ) {
var headerAlignmentSetting = api.instance( 'generate_settings[header_alignment_setting]' );
var navLocationSetting = api.instance( 'generate_settings[nav_position_setting]' );
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' );
var boxAlignmentSetting = api.instance( 'generate_settings[container_alignment]' );
var siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' );
var hideSiteTaglineSetting = api.instance( 'generate_settings[hide_tagline]' );
var headerPaddingTopSetting = api.instance( 'generate_spacing_settings[header_top]' );
var headerPaddingBottomSetting = api.instance( 'generate_spacing_settings[header_bottom]' );
if ( ! headerAlignmentSetting._dirty ) {
headerAlignment = headerAlignmentSetting.get();
}
if ( ! navLocationSetting._dirty ) {
navLocation = navLocationSetting.get();
}
if ( ! navAlignmentSetting._dirty ) {
navAlignment = navAlignmentSetting.get();
}
if ( ! boxAlignmentSetting._dirty ) {
boxAlignment = boxAlignmentSetting.get();
}
if ( ! siteTitleFontSizeSetting._dirty ) {
siteTitleFontSize = siteTitleFontSizeSetting.get();
}
if ( ! hideSiteTaglineSetting._dirty ) {
hideSiteTagline = hideSiteTaglineSetting.get();
}
if ( ! headerPaddingTopSetting._dirty ) {
headerPaddingTop = headerPaddingTopSetting.get();
}
if ( ! headerPaddingBottomSetting._dirty ) {
headerPaddingBottom = headerPaddingBottomSetting.get();
}
var options = {
headerAlignment: generatepress_defaults.header_alignment_setting,
navLocation: generatepress_defaults.nav_position_setting,
navAlignment: generatepress_defaults.nav_alignment_setting,
boxAlignment: generatepress_defaults.container_alignment,
siteTitleFontSize: generatepress_typography_defaults.site_title_font_size,
hideSiteTagline: generatepress_defaults.hide_tagline,
headerPaddingTop: generatepress_spacing_defaults.header_top,
headerPaddingBottom: generatepress_spacing_defaults.header_bottom,
};
if ( 'current' === newval ) {
options = {
headerAlignment: headerAlignment,
navLocation: navLocation,
navAlignment: navAlignment,
boxAlignment: boxAlignment,
siteTitleFontSize: siteTitleFontSize,
hideSiteTagline: hideSiteTagline,
headerPaddingTop: headerPaddingTop,
headerPaddingBottom: headerPaddingBottom,
};
setOption( options );
}
if ( 'default' === newval ) {
setOption( options );
}
if ( 'classic' === newval ) {
var options = {
headerAlignment: 'left',
navLocation: 'nav-below-header',
navAlignment: 'left',
boxAlignment: 'boxes',
siteTitleFontSize: '45',
hideSiteTagline: '',
headerPaddingTop: '40',
headerPaddingBottom: '40',
};
setOption( options );
}
if ( 'nav-before' === newval ) {
options['headerAlignment'] = 'left';
options['navLocation'] = 'nav-above-header';
options['navAlignment'] = 'left';
setOption( options );
}
if ( 'nav-after' === newval ) {
options['headerAlignment'] = 'left';
options['navLocation'] = 'nav-below-header';
options['navAlignment'] = 'left';
setOption( options );
}
if ( 'nav-before-centered' === newval ) {
options['headerAlignment'] = 'center';
options['navLocation'] = 'nav-above-header';
options['navAlignment'] = 'center';
setOption( options );
}
if ( 'nav-after-centered' === newval ) {
options['headerAlignment'] = 'center';
options['navLocation'] = 'nav-below-header';
options['navAlignment'] = 'center';
setOption( options );
}
if ( 'nav-left' === newval ) {
options['headerAlignment'] = 'left';
options['navLocation'] = 'nav-float-left';
options['navAlignment'] = 'right';
setOption( options );
}
} );
} );
api( 'generate_settings[use_dynamic_typography]', function( value ) {
var fontManager = api.control( 'generate_settings[font_manager]' );
var typographyManager = api.control( 'generate_settings[typography]' );
value.bind( function( newval ) {
if ( newval ) {
if ( fontManager.setting.get().length === 0 ) {
fontManager.setting.set( generatepressCustomizeControls.mappedTypographyData.fonts );
}
if ( typographyManager.setting.get().length === 0 ) {
typographyManager.setting.set( generatepressCustomizeControls.mappedTypographyData.typography );
}
}
} );
} );
}( wp.customize ) );

View File

@ -0,0 +1,341 @@
/* global gpPostMessageFields */
/* eslint max-depth: off */
var gpPostMessage = {
/**
* The fields.
*
* @since 1.0.0
*/
fields: {},
/**
* A collection of methods for the <style> tags.
*
* @since 1.0.0
*/
styleTag: {
/**
* Add a <style> tag in <head> if it doesn't already exist.
*
* @since 1.0.0
*
* @param {string} id - The field-ID.
*
* @return {void}
*/
add( id ) {
id = id.replace( /[^\w\s]/gi, '-' );
if ( null === document.getElementById( 'gp-postmessage-' + id ) || 'undefined' === typeof document.getElementById( 'gp-postmessage-' + id ) ) {
jQuery( 'head' ).append( '<style id="gp-postmessage-' + id + '"></style>' );
}
},
/**
* Add a <style> tag in <head> if it doesn't already exist,
* by calling the this.add method, and then add styles inside it.
*
* @since 1.0.0
*
* @param {string} id - The field-ID.
* @param {string} styles - The styles to add.
*
* @return {void}
*/
addData( id, styles ) {
id = id.replace( '[', '-' ).replace( ']', '' );
gpPostMessage.styleTag.add( id );
jQuery( '#gp-postmessage-' + id ).text( styles );
},
},
/**
* Common utilities.
*
* @since 1.0.0
*/
util: {
/**
* Processes the value and applies any replacements and/or additions.
*
* @since 1.0.0
*
* @param {Object} output - The output (js_vars) argument.
* @param {mixed} value - The value.
* @param {string} controlType - The control-type.
*
* @return {string|false} - Returns false if value is excluded, otherwise a string.
*/
processValue( output, value ) {
var self = this,
settings = window.parent.wp.customize.get(),
excluded = false;
if ( 'object' === typeof value ) {
_.each( value, function( subValue, key ) {
value[ key ] = self.processValue( output, subValue );
} );
return value;
}
output = _.defaults( output, {
prefix: '',
units: '',
suffix: '',
value_pattern: '$',
pattern_replace: {},
exclude: [],
} );
if ( 1 <= output.exclude.length ) {
_.each( output.exclude, function( exclusion ) {
if ( value == exclusion ) {
excluded = true;
}
} );
}
if ( excluded ) {
return false;
}
value = output.value_pattern.replace( new RegExp( '\\$', 'g' ), value );
_.each( output.pattern_replace, function( id, placeholder ) {
if ( ! _.isUndefined( settings[ id ] ) ) {
value = value.replace( placeholder, settings[ id ] );
}
} );
return output.prefix + value + output.units + output.suffix;
},
/**
* Make sure urls are properly formatted for background-image properties.
*
* @since 1.0.0
*
* @param {string} url - The URL.
*
* @return {string} - Returns the URL.
*/
backgroundImageValue( url ) {
return ( -1 === url.indexOf( 'url(' ) ) ? 'url(' + url + ')' : url;
},
},
/**
* A collection of utilities for CSS generation.
*
* @since 1.0.0
*/
css: {
/**
* Generates the CSS from the output (js_vars) parameter.
*
* @since 1.0.0
*
* @param {Object} output - The output (js_vars) argument.
* @param {mixed} value - The value.
* @param {string} controlType - The control-type.
*
* @return {string} - Returns CSS as a string.
*/
fromOutput( output, value, controlType ) {
var styles = '',
mediaQuery = false,
processedValue;
try {
value = JSON.parse( value );
} catch ( e ) {} // eslint-disable-line no-empty
if ( output.js_callback && 'function' === typeof window[ output.js_callback ] ) {
value = window[ output.js_callback[ 0 ] ]( value, output.js_callback[ 1 ] );
}
// Apply the gpPostMessageStylesOutput filter.
styles = wp.hooks.applyFilters( 'gpPostMessageStylesOutput', styles, value, output, controlType );
if ( '' === styles ) {
switch ( controlType ) {
case 'kirki-multicolor':
case 'kirki-sortable':
styles += output.element + '{';
_.each( value, function( val, key ) {
if ( output.choice && key !== output.choice ) {
return;
}
processedValue = gpPostMessage.util.processValue( output, val );
if ( '' === processedValue ) {
if ( 'background-color' === output.property ) {
processedValue = 'unset';
} else if ( 'background-image' === output.property ) {
processedValue = 'none';
}
}
if ( false !== processedValue ) {
styles += output.property ? output.property + '-' + key + ':' + processedValue + ';' : key + ':' + processedValue + ';';
}
} );
styles += '}';
break;
default:
if ( 'kirki-image' === controlType ) {
value = ( ! _.isUndefined( value.url ) ) ? gpPostMessage.util.backgroundImageValue( value.url ) : gpPostMessage.util.backgroundImageValue( value );
}
if ( _.isObject( value ) ) {
styles += output.element + '{';
_.each( value, function( val, key ) {
var property;
if ( output.choice && key !== output.choice ) {
return;
}
processedValue = gpPostMessage.util.processValue( output, val );
property = output.property ? output.property : key;
if ( '' === processedValue ) {
if ( 'background-color' === property ) {
processedValue = 'unset';
} else if ( 'background-image' === property ) {
processedValue = 'none';
}
}
if ( false !== processedValue ) {
styles += property + ':' + processedValue + ';';
}
} );
styles += '}';
} else {
processedValue = gpPostMessage.util.processValue( output, value );
if ( '' === processedValue ) {
if ( 'background-color' === output.property ) {
processedValue = 'unset';
} else if ( 'background-image' === output.property ) {
processedValue = 'none';
}
}
if ( false !== processedValue ) {
styles += output.element + '{' + output.property + ':' + processedValue + ';}';
}
}
break;
}
}
// Get the media-query.
if ( output.media_query && 'string' === typeof output.media_query && ! _.isEmpty( output.media_query ) ) {
mediaQuery = output.media_query;
if ( -1 === mediaQuery.indexOf( '@media' ) ) {
mediaQuery = '@media ' + mediaQuery;
}
}
// If we have a media-query, add it and return.
if ( mediaQuery ) {
return mediaQuery + '{' + styles + '}';
}
// Return the styles.
return styles;
},
},
/**
* A collection of utilities to change the HTML in the document.
*
* @since 1.0.0
*/
html: {
/**
* Modifies the HTML from the output (js_vars) parameter.
*
* @since 1.0.0
*
* @param {Object} output - The output (js_vars) argument.
* @param {mixed} value - The value.
*
* @return {void}
*/
fromOutput( output, value ) {
if ( output.js_callback && 'function' === typeof window[ output.js_callback ] ) {
value = window[ output.js_callback[ 0 ] ]( value, output.js_callback[ 1 ] );
}
if ( _.isObject( value ) || _.isArray( value ) ) {
if ( ! output.choice ) {
return;
}
_.each( value, function( val, key ) {
if ( output.choice && key !== output.choice ) {
return;
}
value = val;
} );
}
value = gpPostMessage.util.processValue( output, value );
if ( output.attr ) {
jQuery( output.element ).attr( output.attr, value );
} else {
jQuery( output.element ).html( value );
}
},
},
/**
* A collection of utilities to allow toggling a CSS class.
*
* @since 1.0.0
*/
toggleClass: {
/**
* Toggles a CSS class from the output (js_vars) parameter.
*
* @since 1.0.0
*
* @param {Object} output - The output (js_vars) argument.
* @param {mixed} value - The value.
*
* @return {void}
*/
fromOutput( output, value ) {
if ( 'undefined' === typeof output.class || 'undefined' === typeof output.value ) {
return;
}
if ( value === output.value && ! jQuery( output.element ).hasClass( output.class ) ) {
jQuery( output.element ).addClass( output.class );
} else {
jQuery( output.element ).removeClass( output.class );
}
},
},
};
jQuery( document ).ready( function() {
var styles;
_.each( gpPostMessageFields, function( field ) {
wp.customize( field.settings, function( value ) {
value.bind( function( newVal ) {
styles = '';
_.each( field.js_vars, function( output ) {
output.function = ( ! output.function || 'undefined' === typeof gpPostMessage[ output.function ] ) ? 'css' : output.function;
field.type = ( field.choices && field.choices.parent_type ) ? field.choices.parent_type : field.type;
if ( 'css' === output.function ) {
styles += gpPostMessage.css.fromOutput( output, newVal, field.type );
} else {
gpPostMessage[ output.function ].fromOutput( output, newVal, field.type );
}
} );
gpPostMessage.styleTag.addData( field.settings, styles );
} );
} );
} );
} );