Initial commit
This commit is contained in:
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/**
|
||||
* Where old Customizer controls retire.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Customize_Width_Slider_Control' ) ) {
|
||||
/**
|
||||
* Create our container width slider control
|
||||
* @deprecated 1.3.47
|
||||
*/
|
||||
class Generate_Customize_Width_Slider_Control extends WP_Customize_Control {
|
||||
public function render_content() {}
|
||||
}
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GenerateLabelControl' ) ) {
|
||||
/**
|
||||
* Heading area
|
||||
* @since 0.1
|
||||
* @depreceted 1.3.41
|
||||
**/
|
||||
class GenerateLabelControl extends WP_Customize_Control {
|
||||
public function render_content() {}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Generate_Google_Font_Dropdown_Custom_Control' ) ) {
|
||||
/**
|
||||
* A class to create a dropdown for all google fonts
|
||||
*/
|
||||
class Generate_Google_Font_Dropdown_Custom_Control extends WP_Customize_Control {
|
||||
public $type = 'gp-customizer-fonts';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'generatepress-customizer-fonts', trailingslashit( get_template_directory_uri() ) . 'inc/js/typography-controls.js', array( 'customize-controls' ), GENERATE_VERSION, true );
|
||||
wp_localize_script( 'generatepress-customizer-fonts', 'gp_customize', array( 'nonce' => wp_create_nonce( 'gp_customize_nonce' ) ) );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 );
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['value'] = $this->value();
|
||||
$this->json['default_fonts_title'] = __( 'Default fonts', 'generatepress' );
|
||||
$this->json['google_fonts_title'] = __( 'Google fonts', 'generatepress' );
|
||||
$this->json['description'] = __( 'Font family','generatepress' );
|
||||
$this->json['google_fonts'] = apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) );
|
||||
$this->json['default_fonts'] = generate_typography_default_fonts();
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<select {{{ data.link }}}>
|
||||
<optgroup label="{{ data.default_fonts_title }}">
|
||||
<# for ( var key in data.default_fonts ) { #>
|
||||
<# var name = data.default_fonts[ key ].split(',')[0]; #>
|
||||
<option value="{{ data.default_fonts[ key ] }}" <# if ( data.default_fonts[ key ] === data.value ) { #>selected="selected"<# } #>>{{ name }}</option>
|
||||
<# } #>
|
||||
</optgroup>
|
||||
<optgroup label="{{ data.google_fonts_title }}">
|
||||
<# for ( var key in data.google_fonts ) { #>
|
||||
<option value="{{ data.google_fonts[ key ].name }}" <# if ( data.google_fonts[ key ].name === data.value ) { #>selected="selected"<# } #>>{{ data.google_fonts[ key ].name }}</option>
|
||||
<# } #>
|
||||
</optgroup>
|
||||
</select>
|
||||
<p class="description">{{ data.description }}</p>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Generate_Select_Control' ) ) {
|
||||
/**
|
||||
* A class to create a dropdown for font weight
|
||||
*/
|
||||
class Generate_Select_Control extends WP_Customize_Control {
|
||||
public $type = 'gp-typography-select';
|
||||
public $choices = array();
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
foreach ( $this->choices as $name => $choice ) {
|
||||
$this->choices[ $name ] = $choice;
|
||||
}
|
||||
|
||||
$this->json['choices'] = $this->choices;
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['value'] = $this->value();
|
||||
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( ! data.choices )
|
||||
return;
|
||||
#>
|
||||
<label>
|
||||
<select {{{ data.link }}}>
|
||||
<# jQuery.each( data.choices, function( label, choice ) { #>
|
||||
<option value="{{ choice }}" <# if ( choice === data.value ) { #> selected="selected"<# } #>>{{ choice }}</option>
|
||||
<# } ) #>
|
||||
</select>
|
||||
<# if ( data.label ) { #>
|
||||
<p class="description">{{ data.label }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Generate_Hidden_Input_Control' ) ) {
|
||||
/**
|
||||
* Create our hidden input control
|
||||
*/
|
||||
class Generate_Hidden_Input_Control extends WP_Customize_Control {
|
||||
// Setup control type
|
||||
public $type = 'gp-hidden-input';
|
||||
public $id = '';
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['value'] = $this->value();
|
||||
$this->json['id'] = $this->id;
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<input name="{{ data.id }}" type="text" {{{ data.link }}} value="{{{ data.value }}}" class="gp-hidden-input" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Generate_Font_Weight_Custom_Control' ) ) {
|
||||
/**
|
||||
* A class to create a dropdown for font weight
|
||||
* @deprecated since 1.3.40
|
||||
*/
|
||||
class Generate_Font_Weight_Custom_Control extends WP_Customize_Control {
|
||||
|
||||
public function __construct( $manager, $id, $args = array(), $options = array() ) {
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the content of the category dropdown
|
||||
*
|
||||
* @return HTML
|
||||
*/
|
||||
public function render_content() {
|
||||
?>
|
||||
<label>
|
||||
<select <?php $this->link(); ?>>
|
||||
<?php
|
||||
printf('<option value="%s" %s>%s</option>', 'normal', selected($this->value(), 'normal', false), 'normal');
|
||||
printf('<option value="%s" %s>%s</option>', 'bold', selected($this->value(), 'bold', false), 'bold');
|
||||
printf('<option value="%s" %s>%s</option>', '100', selected($this->value(), '100', false), '100');
|
||||
printf('<option value="%s" %s>%s</option>', '200', selected($this->value(), '200', false), '200');
|
||||
printf('<option value="%s" %s>%s</option>', '300', selected($this->value(), '300', false), '300');
|
||||
printf('<option value="%s" %s>%s</option>', '400', selected($this->value(), '400', false), '400');
|
||||
printf('<option value="%s" %s>%s</option>', '500', selected($this->value(), '500', false), '500');
|
||||
printf('<option value="%s" %s>%s</option>', '600', selected($this->value(), '600', false), '600');
|
||||
printf('<option value="%s" %s>%s</option>', '700', selected($this->value(), '700', false), '700');
|
||||
printf('<option value="%s" %s>%s</option>', '800', selected($this->value(), '800', false), '800');
|
||||
printf('<option value="%s" %s>%s</option>', '900', selected($this->value(), '900', false), '900');
|
||||
?>
|
||||
</select>
|
||||
<p class="description"><?php echo esc_html( $this->label ); ?></p>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Generate_Text_Transform_Custom_Control' ) ) {
|
||||
/**
|
||||
* A class to create a dropdown for text-transform
|
||||
* @deprecated since 1.3.40
|
||||
*/
|
||||
class Generate_Text_Transform_Custom_Control extends WP_Customize_Control {
|
||||
|
||||
public function __construct( $manager, $id, $args = array(), $options = array() ) {
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the content of the category dropdown
|
||||
*
|
||||
* @return HTML
|
||||
*/
|
||||
public function render_content() {
|
||||
?>
|
||||
<label>
|
||||
<select <?php $this->link(); ?>>
|
||||
<?php
|
||||
printf('<option value="%s" %s>%s</option>', 'none', selected($this->value(), 'none', false), 'none');
|
||||
printf('<option value="%s" %s>%s</option>', 'capitalize', selected($this->value(), 'capitalize', false), 'capitalize');
|
||||
printf('<option value="%s" %s>%s</option>', 'uppercase', selected($this->value(), 'uppercase', false), 'uppercase');
|
||||
printf('<option value="%s" %s>%s</option>', 'lowercase', selected($this->value(), 'lowercase', false), 'lowercase');
|
||||
?>
|
||||
</select>
|
||||
<p class="description"><?php echo esc_html( $this->label ); ?></p>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Generate_Customize_Slider_Control' ) ) {
|
||||
/**
|
||||
* Create our container width slider control
|
||||
* @deprecated 1.3.47
|
||||
*/
|
||||
class Generate_Customize_Slider_Control extends WP_Customize_Control {
|
||||
public function render_content() {}
|
||||
}
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* The range slider Customizer control.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Range_Slider_Control' ) ) {
|
||||
/**
|
||||
* Create a range slider control.
|
||||
* This control allows you to add responsive settings.
|
||||
*
|
||||
* @since 1.3.47
|
||||
*/
|
||||
class Generate_Range_Slider_Control extends WP_Customize_Control {
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'generatepress-range-slider';
|
||||
|
||||
public $description = '';
|
||||
|
||||
public $sub_description = '';
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$devices = array( 'desktop','tablet','mobile' );
|
||||
foreach ( $devices as $device ) {
|
||||
$this->json['choices'][ $device ]['min'] = ( isset( $this->choices[ $device ]['min'] ) ) ? $this->choices[ $device ]['min'] : '0';
|
||||
$this->json['choices'][ $device ]['max'] = ( isset( $this->choices[ $device ]['max'] ) ) ? $this->choices[ $device ]['max'] : '100';
|
||||
$this->json['choices'][ $device ]['step'] = ( isset( $this->choices[ $device ]['step'] ) ) ? $this->choices[ $device ]['step'] : '1';
|
||||
$this->json['choices'][ $device ]['edit'] = ( isset( $this->choices[ $device ]['edit'] ) ) ? $this->choices[ $device ]['edit'] : false;
|
||||
$this->json['choices'][ $device ]['unit'] = ( isset( $this->choices[ $device ]['unit'] ) ) ? $this->choices[ $device ]['unit'] : false;
|
||||
}
|
||||
|
||||
foreach ( $this->settings as $setting_key => $setting_id ) {
|
||||
$this->json[ $setting_key ] = array(
|
||||
'link' => $this->get_link( $setting_key ),
|
||||
'value' => $this->value( $setting_key ),
|
||||
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
|
||||
);
|
||||
}
|
||||
|
||||
$this->json['desktop_label'] = __( 'Desktop','generatepress' );
|
||||
$this->json['tablet_label'] = __( 'Tablet','generatepress' );
|
||||
$this->json['mobile_label'] = __( 'Mobile','generatepress' );
|
||||
$this->json['reset_label'] = __( 'Reset','generatepress' );
|
||||
|
||||
$this->json['description'] = $this->description;
|
||||
$this->json['sub_description'] = $this->sub_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'generatepress-range-slider', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/slider-control.js', array( 'jquery', 'customize-base', 'jquery-ui-slider' ), false, true );
|
||||
wp_enqueue_style( 'generatepress-range-slider-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/slider-customizer.css', null );
|
||||
}
|
||||
|
||||
/**
|
||||
* An Underscore (JS) template for this control's content (but not its container).
|
||||
*
|
||||
* Class variables for this control class are available in the `data` JS object;
|
||||
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<div class="generatepress-range-slider-control">
|
||||
<div class="gp-range-title-area">
|
||||
<# if ( data.label || data.description ) { #>
|
||||
<div class="gp-range-title-info">
|
||||
<# if ( data.label ) { #>
|
||||
<span class="customize-control-title">{{{ data.label }}}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<p class="description">{{{ data.description }}}</p>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<div class="gp-range-slider-controls">
|
||||
<span class="gp-device-controls">
|
||||
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
|
||||
<span class="generatepress-device-desktop dashicons dashicons-desktop" data-option="desktop" title="{{ data.desktop_label }}"></span>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof (data.tablet) ) { #>
|
||||
<span class="generatepress-device-tablet dashicons dashicons-tablet" data-option="tablet" title="{{ data.tablet_label }}"></span>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof (data.mobile) ) { #>
|
||||
<span class="generatepress-device-mobile dashicons dashicons-smartphone" data-option="mobile" title="{{ data.mobile_label }}"></span>
|
||||
<# } #>
|
||||
</span>
|
||||
|
||||
<span title="{{ data.reset_label }}" class="generatepress-reset dashicons dashicons-image-rotate"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gp-range-slider-areas">
|
||||
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
|
||||
<label class="range-option-area" data-option="desktop" style="display: none;">
|
||||
<div class="wrapper <# if ( '' !== data.choices['desktop']['unit'] ) { #>has-unit<# } #>">
|
||||
<div class="generatepress-slider" data-step="{{ data.choices['desktop']['step'] }}" data-min="{{ data.choices['desktop']['min'] }}" data-max="{{ data.choices['desktop']['max'] }}"></div>
|
||||
|
||||
<div class="gp_range_value <# if ( '' == data.choices['desktop']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
|
||||
<input <# if ( data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['desktop']['step'] }}" class="desktop-range value" value="{{ data.desktop.value }}" min="{{ data.choices['desktop']['min'] }}" max="{{ data.choices['desktop']['max'] }}" {{{ data.desktop.link }}} data-reset_value="{{ data.desktop.default }}" />
|
||||
<span <# if ( ! data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.desktop.value }}</span>
|
||||
|
||||
<# if ( data.choices['desktop']['unit'] ) { #>
|
||||
<span class="unit">{{ data.choices['desktop']['unit'] }}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.tablet ) ) { #>
|
||||
<label class="range-option-area" data-option="tablet" style="display:none">
|
||||
<div class="wrapper <# if ( '' !== data.choices['tablet']['unit'] ) { #>has-unit<# } #>">
|
||||
<div class="generatepress-slider" data-step="{{ data.choices['tablet']['step'] }}" data-min="{{ data.choices['tablet']['min'] }}" data-max="{{ data.choices['tablet']['max'] }}"></div>
|
||||
|
||||
<div class="gp_range_value <# if ( '' == data.choices['tablet']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
|
||||
<input <# if ( data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['tablet']['step'] }}" class="tablet-range value" value="{{ data.tablet.value }}" min="{{ data.choices['tablet']['min'] }}" max="{{ data.choices['tablet']['max'] }}" {{{ data.tablet.link }}} data-reset_value="{{ data.tablet.default }}" />
|
||||
<span <# if ( ! data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.tablet.value }}</span>
|
||||
|
||||
<# if ( data.choices['tablet']['unit'] ) { #>
|
||||
<span class="unit">{{ data.choices['tablet']['unit'] }}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.mobile ) ) { #>
|
||||
<label class="range-option-area" data-option="mobile" style="display:none;">
|
||||
<div class="wrapper <# if ( '' !== data.choices['mobile']['unit'] ) { #>has-unit<# } #>">
|
||||
<div class="generatepress-slider" data-step="{{ data.choices['mobile']['step'] }}" data-min="{{ data.choices['mobile']['min'] }}" data-max="{{ data.choices['mobile']['max'] }}"></div>
|
||||
|
||||
<div class="gp_range_value <# if ( '' == data.choices['mobile']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
|
||||
<input <# if ( data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['mobile']['step'] }}" class="mobile-range value" value="{{ data.mobile.value }}" min="{{ data.choices['mobile']['min'] }}" max="{{ data.choices['mobile']['max'] }}" {{{ data.mobile.link }}} data-reset_value="{{ data.mobile.default }}" />
|
||||
<span <# if ( ! data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.mobile.value }}</span>
|
||||
|
||||
<# if ( data.choices['mobile']['unit'] ) { #>
|
||||
<span class="unit">{{ data.choices['mobile']['unit'] }}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<# if ( data.sub_description ) { #>
|
||||
<p class="description sub-description">{{{ data.sub_description }}}</p>
|
||||
<# } #>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* The typography Customizer control.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Typography_Customize_Control' ) ) {
|
||||
/**
|
||||
* Create the typography elements control.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class Generate_Typography_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'gp-customizer-typography';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'generatepress-typography-selectWoo', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/selectWoo.min.js', array( 'customize-controls', 'jquery' ), GENERATE_VERSION, true );
|
||||
wp_enqueue_style( 'generatepress-typography-selectWoo', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/selectWoo.min.css', array(), GENERATE_VERSION );
|
||||
|
||||
wp_enqueue_script( 'generatepress-typography-customizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/typography-customizer.js', array( 'customize-controls', 'generatepress-typography-selectWoo' ), GENERATE_VERSION, true );
|
||||
wp_enqueue_style( 'generatepress-typography-customizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/typography-customizer.css', array(), GENERATE_VERSION );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['default_fonts_title'] = __( 'System fonts', 'generatepress' );
|
||||
$this->json['google_fonts_title'] = __( 'Google fonts', 'generatepress' );
|
||||
$this->json['default_fonts'] = generate_typography_default_fonts();
|
||||
$this->json['family_title'] = esc_html__( 'Font family', 'generatepress' );
|
||||
$this->json['weight_title'] = esc_html__( 'Font weight', 'generatepress' );
|
||||
$this->json['transform_title'] = esc_html__( 'Text transform', 'generatepress' );
|
||||
$this->json['category_title'] = '';
|
||||
$this->json['variant_title'] = esc_html__( 'Variants', 'generatepress' );
|
||||
|
||||
foreach ( $this->settings as $setting_key => $setting_id ) {
|
||||
$this->json[ $setting_key ] = array(
|
||||
'link' => $this->get_link( $setting_key ),
|
||||
'value' => $this->value( $setting_key ),
|
||||
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
|
||||
'id' => isset( $setting_id->id ) ? $setting_id->id : ''
|
||||
);
|
||||
|
||||
if ( 'weight' === $setting_key ) {
|
||||
$this->json[ $setting_key ]['choices'] = $this->get_font_weight_choices();
|
||||
}
|
||||
|
||||
if ( 'transform' === $setting_key ) {
|
||||
$this->json[ $setting_key ]['choices'] = $this->get_font_transform_choices();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( '' !== data.label ) { #>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<# } #>
|
||||
<# if ( 'undefined' !== typeof ( data.family ) ) { #>
|
||||
<div class="generatepress-font-family">
|
||||
<label>
|
||||
<select {{{ data.family.link }}} data-category="{{{ data.category.id }}}" data-variants="{{{ data.variant.id }}}" style="width:100%;">
|
||||
<optgroup label="{{ data.default_fonts_title }}">
|
||||
<# for ( var key in data.default_fonts ) { #>
|
||||
<# var name = data.default_fonts[ key ].split(',')[0]; #>
|
||||
<option value="{{ data.default_fonts[ key ] }}" <# if ( data.default_fonts[ key ] === data.family.value ) { #>selected="selected"<# } #>>{{ name }}</option>
|
||||
<# } #>
|
||||
</optgroup>
|
||||
<optgroup label="{{ data.google_fonts_title }}">
|
||||
<# for ( var key in generatePressTypography.googleFonts ) { #>
|
||||
<option value="{{ generatePressTypography.googleFonts[ key ].name }}" <# if ( generatePressTypography.googleFonts[ key ].name === data.family.value ) { #>selected="selected"<# } #>>{{ generatePressTypography.googleFonts[ key ].name }}</option>
|
||||
<# } #>
|
||||
</optgroup>
|
||||
</select>
|
||||
<# if ( '' !== data.family_title ) { #>
|
||||
<p class="description">{{ data.family_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.variant ) ) { #>
|
||||
<#
|
||||
var id = data.family.value.split(' ').join('_').toLowerCase();
|
||||
var font_data = generatePressTypography.googleFonts[id];
|
||||
var variants = '';
|
||||
if ( typeof font_data !== 'undefined' ) {
|
||||
variants = font_data.variants;
|
||||
}
|
||||
|
||||
if ( null === data.variant.value ) {
|
||||
data.variant.value = data.variant.default;
|
||||
}
|
||||
#>
|
||||
<div id={{{ data.variant.id }}}" class="generatepress-font-variant" data-saved-value="{{ data.variant.value }}">
|
||||
<label>
|
||||
<select name="{{{ data.variant.id }}}" multiple class="typography-multi-select" style="width:100%;" {{{ data.variant.link }}}>
|
||||
<# _.each( variants, function( label, choice ) { #>
|
||||
<option value="{{ label }}">{{ label }}</option>
|
||||
<# } ) #>
|
||||
</select>
|
||||
|
||||
<# if ( '' !== data.variant_title ) { #>
|
||||
<p class="description">{{ data.variant_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.category ) ) { #>
|
||||
<div class="generatepress-font-category">
|
||||
<label>
|
||||
<input name="{{{ data.category.id }}}" type="hidden" {{{ data.category.link }}} value="{{{ data.category.value }}}" class="gp-hidden-input" />
|
||||
<# if ( '' !== data.category_title ) { #>
|
||||
<p class="description">{{ data.category_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<div class="generatepress-weight-transform-wrapper">
|
||||
<# if ( 'undefined' !== typeof ( data.weight ) ) { #>
|
||||
<div class="generatepress-font-weight">
|
||||
<label>
|
||||
<select {{{ data.weight.link }}}>
|
||||
|
||||
<# _.each( data.weight.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.weight.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
<# if ( '' !== data.weight_title ) { #>
|
||||
<p class="description">{{ data.weight_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.transform ) ) { #>
|
||||
<div class="generatepress-font-transform">
|
||||
<label>
|
||||
<select {{{ data.transform.link }}}>
|
||||
|
||||
<# _.each( data.transform.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.transform.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
<# if ( '' !== data.transform_title ) { #>
|
||||
<p class="description">{{ data.transform_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function get_font_weight_choices() {
|
||||
return array(
|
||||
'normal' => esc_html( 'normal' ),
|
||||
'bold' => esc_html( 'bold' ),
|
||||
'100' => esc_html( '100' ),
|
||||
'200' => esc_html( '200' ),
|
||||
'300' => esc_html( '300' ),
|
||||
'400' => esc_html( '400' ),
|
||||
'500' => esc_html( '500' ),
|
||||
'600' => esc_html( '600' ),
|
||||
'700' => esc_html( '700' ),
|
||||
'800' => esc_html( '800' ),
|
||||
'900' => esc_html( '900' ),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_font_transform_choices() {
|
||||
return array(
|
||||
'none' => esc_html( 'none' ),
|
||||
'capitalize' => esc_html( 'capitalize' ),
|
||||
'uppercase' => esc_html( 'uppercase' ),
|
||||
'lowercase' => esc_html( 'lowercase' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* The upsell Customizer controll.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Customize_Misc_Control' ) ) {
|
||||
/**
|
||||
* Create our in-section upsell controls.
|
||||
* Escape your URL in the Customizer using esc_url().
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
class Generate_Customize_Misc_Control extends WP_Customize_Control {
|
||||
public $description = '';
|
||||
public $url = '';
|
||||
public $type = 'addon';
|
||||
public $label = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_style( 'generate-customizer-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/upsell-customizer.css', array(), GENERATE_VERSION );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['url'] = esc_url( $this->url );
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<p class="description" style="margin-top: 5px;">{{{ data.description }}}</p>
|
||||
<span class="get-addon">
|
||||
<a href="{{{ data.url }}}" class="button button-primary" target="_blank">{{ data.label }}</a>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* The upsell Customizer section.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Section' ) && ! class_exists( 'GeneratePress_Upsell_Section' ) ) {
|
||||
/**
|
||||
* Create our upsell section.
|
||||
* Escape your URL in the Customizer using esc_url().
|
||||
*
|
||||
* @since unknown
|
||||
*/
|
||||
class GeneratePress_Upsell_Section extends WP_Customize_Section {
|
||||
public $type = 'gp-upsell-section';
|
||||
public $pro_url = '';
|
||||
public $pro_text = '';
|
||||
public $id = '';
|
||||
|
||||
public function json() {
|
||||
$json = parent::json();
|
||||
$json['pro_text'] = $this->pro_text;
|
||||
$json['pro_url'] = esc_url( $this->pro_url );
|
||||
$json['id'] = $this->id;
|
||||
return $json;
|
||||
}
|
||||
|
||||
protected function render_template() {
|
||||
?>
|
||||
<li id="accordion-section-{{ data.id }}" class="generate-upsell-accordion-section control-section-{{ data.type }} cannot-expand accordion-section">
|
||||
<h3><a href="{{{ data.pro_url }}}" target="_blank">{{ data.pro_text }}</a></h3>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customizer_controls_css' ) ) {
|
||||
add_action( 'customize_controls_enqueue_scripts', 'generate_customizer_controls_css' );
|
||||
/**
|
||||
* Add CSS for our controls
|
||||
*
|
||||
* @since 1.3.41
|
||||
*/
|
||||
function generate_customizer_controls_css() {
|
||||
wp_enqueue_style( 'generate-customizer-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/upsell-customizer.css', array(), GENERATE_VERSION );
|
||||
wp_enqueue_script( 'generatepress-upsell', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/upsell-control.js', array( 'customize-controls' ), false, true );
|
||||
}
|
||||
}
|
1
wp-content/themes/generatepress/inc/customizer/controls/css/selectWoo.min.css
vendored
Normal file
1
wp-content/themes/generatepress/inc/customizer/controls/css/selectWoo.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,142 @@
|
||||
.customize-control-generatepress-range-slider .generatepress-slider {
|
||||
position: relative;
|
||||
width: calc(100% - 60px);
|
||||
height: 6px;
|
||||
background-color: rgba(0,0,0,.10);
|
||||
cursor: pointer;
|
||||
-webkit-transition: background .5s;
|
||||
-moz-transition: background .5s;
|
||||
transition: background .5s;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .has-unit .generatepress-slider {
|
||||
width: calc(100% - 90px);
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp_range_value.hide-value {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp_range_value.hide-value + .generatepress-slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .generatepress-slider .ui-slider-handle {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
background-color: #3498D9;
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%) translateX(-4px);
|
||||
transform: translateY(-50%) translateX(-4px);
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.gp-range-title-area {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.gp-range-slider-controls {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .wrapper {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp_range_value {
|
||||
font-size: 14px;
|
||||
padding: 0;
|
||||
font-weight: 400;
|
||||
width: 50px;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .has-unit .gp_range_value {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp_range_value span.value {
|
||||
font-size: 12px;
|
||||
width: calc(100% - 2px);
|
||||
text-align: center;
|
||||
min-height: 30px;
|
||||
background: #FFF;
|
||||
line-height: 30px;
|
||||
border: 1px solid #DDD;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .has-unit .gp_range_value span.value {
|
||||
width: calc(100% - 32px);
|
||||
display: block;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp_range_value .unit {
|
||||
width: 29px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
line-height: 30px;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .generatepress-range-slider-reset span {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp_range_value input {
|
||||
font-size: 12px;
|
||||
padding: 0px;
|
||||
text-align: center;
|
||||
min-height: 30px;
|
||||
height: auto;
|
||||
border-radius: 0;
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .has-unit .gp_range_value input {
|
||||
width: calc(100% - 30px);
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp-range-title-area .dashicons {
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
color: #222;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp-range-title-area .dashicons:hover {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp-range-title-area .dashicons.selected {
|
||||
background: #fff;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .gp-device-controls > span:first-child:last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-range-slider .sub-description {
|
||||
margin-top: 10px;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
.generatepress-font-family {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.generatepress-weight-transform-wrapper {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.generatepress-font-weight,
|
||||
.generatepress-font-transform {
|
||||
width: calc(50% - 5px);
|
||||
}
|
||||
|
||||
span.select2-container.select2-container--default.select2-container--open li.select2-results__option {
|
||||
margin:0;
|
||||
}
|
||||
|
||||
span.select2-container.select2-container--default.select2-container--open{
|
||||
z-index:999999;
|
||||
}
|
||||
|
||||
.select2-selection__rendered li {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single,
|
||||
.select2-container--default.select2-container .select2-selection--multiple,
|
||||
.select2-dropdown,
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||
border-color: #ddd;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-results__option[aria-selected=true] {
|
||||
color: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
#customize-control-font_heading_1_control,
|
||||
#customize-control-font_heading_2_control,
|
||||
#customize-control-font_heading_3_control {
|
||||
margin-top: 20px;
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
.customize-control-addon:before {
|
||||
content: "";
|
||||
height: 1px;
|
||||
width: 50px;
|
||||
background: rgba(0,0,0,.10);
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.customize-control-addon {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
li#accordion-section-generatepress_upsell_section {
|
||||
border-top: 1px solid #D54E21;
|
||||
border-bottom: 1px solid #D54E21;
|
||||
}
|
||||
.generate-upsell-accordion-section a {
|
||||
background: #FFF;
|
||||
display: block;
|
||||
padding: 10px 10px 11px 14px;
|
||||
line-height: 21px;
|
||||
color: #D54E21;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.generate-upsell-accordion-section a:hover {
|
||||
background:#FAFAFA;
|
||||
}
|
||||
|
||||
.generate-upsell-accordion-section h3 {
|
||||
margin: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.generate-upsell-accordion-section h3 a:after {
|
||||
content: "\f345";
|
||||
color: #D54E21;
|
||||
position: absolute;
|
||||
top: 11px;
|
||||
right: 10px;
|
||||
z-index: 1;
|
||||
float: right;
|
||||
border: none;
|
||||
background: none;
|
||||
font: normal 20px/1 dashicons;
|
||||
speak: none;
|
||||
display: block;
|
||||
padding: 0;
|
||||
text-indent: 0;
|
||||
text-align: center;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
@ -0,0 +1,338 @@
|
||||
( function( api ) {
|
||||
'use strict';
|
||||
|
||||
// Add callback for when the header_textcolor setting exists.
|
||||
api( 'generate_settings[nav_position_setting]', function( setting ) {
|
||||
var isNavFloated, linkSettingValueToControlActiveState;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation location setting's value.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
linkSettingValueToControlActiveState = 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 );
|
||||
};
|
||||
|
||||
// Call linkSettingValueToControlActiveState on the navigation dropdown point.
|
||||
api.control( 'generate_settings[nav_drop_point]', linkSettingValueToControlActiveState );
|
||||
} );
|
||||
|
||||
var setOption = function( headerAlignment, navLocation, navAlignment ) {
|
||||
if ( headerAlignment ) {
|
||||
api.control( 'generate_settings[header_alignment_setting]' ).setting.set( headerAlignment );
|
||||
}
|
||||
|
||||
if ( navLocation ) {
|
||||
api.control( 'generate_settings[nav_position_setting]' ).setting.set( navLocation );
|
||||
}
|
||||
|
||||
if ( navAlignment ) {
|
||||
api.control( 'generate_settings[nav_alignment_setting]' ).setting.set( navAlignment );
|
||||
}
|
||||
};
|
||||
|
||||
api( 'generate_header_helper', function( value ) {
|
||||
var headerAlignment = false,
|
||||
navLocation = false,
|
||||
navAlignment = false;
|
||||
|
||||
value.bind( function( newval ) {
|
||||
var headerAlignmentSetting = api.control( 'generate_settings[header_alignment_setting]' ).setting;
|
||||
var navLocationSetting = api.control( 'generate_settings[nav_position_setting]' ).setting;
|
||||
var navAlignmentSetting = api.control( 'generate_settings[nav_alignment_setting]' ).setting;
|
||||
|
||||
if ( ! headerAlignmentSetting._dirty ) {
|
||||
headerAlignment = headerAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navLocationSetting._dirty ) {
|
||||
navLocation = navLocationSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navAlignmentSetting._dirty ) {
|
||||
navAlignment = navAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( 'current' === newval ) {
|
||||
setOption( headerAlignment, navLocation, navAlignment );
|
||||
}
|
||||
|
||||
if ( 'default' === newval ) {
|
||||
setOption( generatepress_defaults.header_alignment_setting, generatepress_defaults.nav_position_setting, generatepress_defaults.nav_alignment_setting );
|
||||
}
|
||||
|
||||
if ( 'nav-before-centered' === newval ) {
|
||||
setOption( 'center', 'nav-above-header', 'center' );
|
||||
}
|
||||
|
||||
if ( 'nav-after-centered' === newval ) {
|
||||
setOption( 'center', 'nav-below-header', 'center' );
|
||||
}
|
||||
|
||||
if ( 'nav-right' === newval ) {
|
||||
setOption( 'left', 'nav-float-right', 'left' );
|
||||
}
|
||||
|
||||
if ( 'nav-left' === newval ) {
|
||||
setOption( 'right', 'nav-float-left', 'right' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
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 ( 'white' === newval ) {
|
||||
backgroundColorSetting.set( '#ffffff' );
|
||||
textColorSetting.set( '#000000' );
|
||||
|
||||
backgroundColorHoverSetting.set( '#ffffff' );
|
||||
textColorHoverSetting.set( '#8f919e' );
|
||||
|
||||
currentBackgroundColorSetting.set( '#ffffff' );
|
||||
currentTextColorSetting.set( '#8f919e' );
|
||||
|
||||
subMenuBackgroundColorSetting.set( '#f6f9fc' );
|
||||
subMenuTextColorSetting.set( '#000000' );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( '#f6f9fc' );
|
||||
subMenuTextColorHoverSetting.set( '#8f919e' );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( '#f6f9fc' );
|
||||
subMenuCurrentTextColorSetting.set( '#8f919e' );
|
||||
}
|
||||
|
||||
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 ) );
|
@ -0,0 +1,609 @@
|
||||
/**
|
||||
* Theme Customizer enhancements for a better user experience.
|
||||
*
|
||||
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*/
|
||||
function generatepress_colors_live_update( id, selector, property, default_value, get_value ) {
|
||||
default_value = typeof default_value !== 'undefined' ? default_value : 'initial';
|
||||
get_value = typeof get_value !== 'undefined' ? get_value : '';
|
||||
|
||||
wp.customize( 'generate_settings[' + id + ']', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
default_value = ( '' !== get_value ) ? wp.customize.value('generate_settings[' + get_value + ']')() : default_value;
|
||||
newval = ( '' !== newval ) ? newval : default_value;
|
||||
|
||||
if ( jQuery( 'style#' + id ).length ) {
|
||||
jQuery( 'style#' + id ).html( selector + '{' + property + ':' + newval + ';}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="' + id + '">' + selector + '{' + property + ':' + newval + '}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#' + id ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
function generatepress_classes_live_update( id, classes, selector, prefix ) {
|
||||
classes = typeof classes !== 'undefined' ? classes : '';
|
||||
prefix = typeof prefix !== 'undefined' ? prefix : '';
|
||||
wp.customize( 'generate_settings[' + id + ']', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
jQuery.each( classes, function( i, v ) {
|
||||
jQuery( selector ).removeClass( prefix + v );
|
||||
});
|
||||
jQuery( selector ).addClass( prefix + newval );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
function generatepress_typography_live_update( id, selector, property, unit, media, settings ) {
|
||||
settings = typeof settings !== 'undefined' ? settings : 'generate_settings';
|
||||
wp.customize( settings + '[' + id + ']', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
// Get our unit if applicable
|
||||
unit = typeof unit !== 'undefined' ? unit : '';
|
||||
|
||||
var isTablet = ( 'tablet' == id.substring( 0, 6 ) ) ? true : false,
|
||||
isMobile = ( 'mobile' == id.substring( 0, 6 ) ) ? true : false;
|
||||
|
||||
if ( isTablet ) {
|
||||
if ( '' == wp.customize(settings + '[' + id + ']').get() ) {
|
||||
var desktopID = id.replace( 'tablet_', '' );
|
||||
newval = wp.customize(settings + '[' + desktopID + ']').get();
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMobile ) {
|
||||
if ( '' == wp.customize(settings + '[' + id + ']').get() ) {
|
||||
var desktopID = id.replace( 'mobile_', '' );
|
||||
newval = wp.customize(settings + '[' + desktopID + ']').get();
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'buttons_font_size' == id && '' == wp.customize('generate_settings[buttons_font_size]').get() ) {
|
||||
newval = wp.customize('generate_settings[body_font_size]').get();
|
||||
}
|
||||
|
||||
// We're using a desktop value
|
||||
if ( ! isTablet && ! isMobile ) {
|
||||
|
||||
var tabletValue = ( typeof wp.customize(settings + '[tablet_' + id + ']') !== 'undefined' ) ? wp.customize(settings + '[tablet_' + id + ']').get() : '',
|
||||
mobileValue = ( typeof wp.customize(settings + '[mobile_' + id + ']') !== 'undefined' ) ? wp.customize(settings + '[mobile_' + id + ']').get() : '';
|
||||
|
||||
// The tablet setting exists, mobile doesn't
|
||||
if ( '' !== tabletValue && '' == mobileValue ) {
|
||||
media = generatepress_live_preview.desktop + ', ' + generatepress_live_preview.mobile;
|
||||
}
|
||||
|
||||
// The tablet setting doesn't exist, mobile does
|
||||
if ( '' == tabletValue && '' !== mobileValue ) {
|
||||
media = generatepress_live_preview.desktop + ', ' + generatepress_live_preview.tablet;
|
||||
}
|
||||
|
||||
// The tablet setting doesn't exist, neither does mobile
|
||||
if ( '' == tabletValue && '' == mobileValue ) {
|
||||
media = generatepress_live_preview.desktop + ', ' + generatepress_live_preview.tablet + ', ' + generatepress_live_preview.mobile;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check if media query
|
||||
media_query = typeof media !== 'undefined' ? 'media="' + media + '"' : '';
|
||||
|
||||
jQuery( 'head' ).append( '<style id="' + id + '" ' + media_query + '>' + selector + '{' + property + ':' + newval + unit + ';}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#' + id ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
|
||||
setTimeout("jQuery('body').trigger('generate_spacing_updated');", 1000);
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
( function( $ ) {
|
||||
|
||||
// Update the site title in real time...
|
||||
wp.customize( 'blogname', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
$( '.main-title a' ).html( newval );
|
||||
} );
|
||||
} );
|
||||
|
||||
//Update the site description in real time...
|
||||
wp.customize( 'blogdescription', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
$( '.site-description' ).html( newval );
|
||||
} );
|
||||
} );
|
||||
|
||||
wp.customize( 'generate_settings[logo_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
$( '.site-header .header-image' ).css( 'width', newval + 'px' );
|
||||
|
||||
if ( '' == newval ) {
|
||||
$( '.site-header .header-image' ).css( 'width', '' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Body background color
|
||||
* Empty: white
|
||||
*/
|
||||
generatepress_colors_live_update( 'background_color', 'body', 'background-color', '#FFFFFF' );
|
||||
|
||||
/**
|
||||
* Text color
|
||||
* Empty: black
|
||||
*/
|
||||
generatepress_colors_live_update( 'text_color', 'body', 'color', '#000000' );
|
||||
|
||||
/**
|
||||
* Link color
|
||||
* Empty: initial
|
||||
*/
|
||||
generatepress_colors_live_update( 'link_color', 'a, a:visited', 'color', 'initial' );
|
||||
|
||||
/**
|
||||
* Link color hover
|
||||
* Empty: initial
|
||||
*/
|
||||
generatepress_colors_live_update( 'link_color_hover', 'a:hover', 'color', 'initial' );
|
||||
|
||||
/**
|
||||
* Live update for content & navigation colors thanks to our preset option.
|
||||
* We only want to run this if GP Premium isn't already doing it.
|
||||
*/
|
||||
if ( 'undefined' == typeof generate_colors_live_update ) {
|
||||
/**
|
||||
* Blog post title color
|
||||
* Empty: Body link color
|
||||
*/
|
||||
generatepress_colors_live_update( 'blog_post_title_color', '.entry-title a, .entry-title a:visited', 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Blog post title color on hover
|
||||
* Empty: Body link color on hover
|
||||
*/
|
||||
generatepress_colors_live_update( 'blog_post_title_hover_color', '.entry-title a:hover', 'color', '', 'link_color_hover' );
|
||||
|
||||
/**
|
||||
* Navigation background color
|
||||
* Empty: Transparent
|
||||
*/
|
||||
generatepress_colors_live_update( 'navigation_background_color', '.main-navigation', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Primary navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generatepress_colors_live_update( 'navigation_text_color',
|
||||
'.main-navigation .main-nav ul li a,\
|
||||
.menu-toggle,button.menu-toggle:hover,\
|
||||
button.menu-toggle:focus,\
|
||||
.main-navigation .mobile-bar-items a,\
|
||||
.main-navigation .mobile-bar-items a:hover,\
|
||||
.main-navigation .mobile-bar-items a:focus',
|
||||
'color',
|
||||
'',
|
||||
'link_color'
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary navigation text color hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generatepress_colors_live_update( 'navigation_text_hover_color',
|
||||
'.navigation-search input[type="search"],\
|
||||
.navigation-search input[type="search"]:active,\
|
||||
.navigation-search input[type="search"]:focus,\
|
||||
.main-navigation .main-nav ul li:hover > a,\
|
||||
.main-navigation .main-nav ul li:focus > a,\
|
||||
.main-navigation .main-nav ul li.sfHover > a',
|
||||
'color',
|
||||
'',
|
||||
'link_color_hover'
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary navigation menu item hover
|
||||
* Empty: transparent
|
||||
*/
|
||||
generatepress_colors_live_update( 'navigation_background_hover_color',
|
||||
'.navigation-search input[type="search"],\
|
||||
.navigation-search input[type="search"]:focus,\
|
||||
.main-navigation .main-nav ul li:hover > a,\
|
||||
.main-navigation .main-nav ul li:focus > a,\
|
||||
.main-navigation .main-nav ul li.sfHover > a',
|
||||
'background-color',
|
||||
'transparent'
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary sub-navigation color
|
||||
* Empty: transparent
|
||||
*/
|
||||
generatepress_colors_live_update( 'subnavigation_background_color', '.main-navigation ul ul', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generatepress_colors_live_update( 'subnavigation_text_color', '.main-navigation .main-nav ul ul li a', 'color', 'link_color' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation hover
|
||||
*/
|
||||
var subnavigation_hover = '.main-navigation .main-nav ul ul li:hover > a, \
|
||||
.main-navigation .main-nav ul ul li:focus > a, \
|
||||
.main-navigation .main-nav ul ul li.sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary sub-navigation text hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generatepress_colors_live_update( 'subnavigation_text_hover_color', subnavigation_hover, 'color', '', 'link_color_hover' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation background hover
|
||||
* Empty: transparent
|
||||
*/
|
||||
generatepress_colors_live_update( 'subnavigation_background_hover_color', subnavigation_hover, 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Navigation current selectors
|
||||
*/
|
||||
var navigation_current = '.main-navigation .main-nav ul li[class*="current-menu-"] > a, \
|
||||
.main-navigation .main-nav ul li[class*="current-menu-"]:hover > a, \
|
||||
.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generatepress_colors_live_update( 'navigation_text_current_color', navigation_current, 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Primary navigation current background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generatepress_colors_live_update( 'navigation_background_current_color', navigation_current, 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation current selectors
|
||||
*/
|
||||
var subnavigation_current = '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
|
||||
.main-navigation .main-nav ul ul li[class*="current-menu-"]:hover > a, \
|
||||
.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary sub-navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generatepress_colors_live_update( 'subnavigation_text_current_color', subnavigation_current, 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Primary navigation current item background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generatepress_colors_live_update( 'subnavigation_background_current_color', subnavigation_current, 'background-color', 'transparent' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Container width
|
||||
*/
|
||||
wp.customize( 'generate_settings[container_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( jQuery( 'style#container_width' ).length ) {
|
||||
jQuery( 'style#container_width' ).html( 'body .grid-container, .wp-block-group__inner-container{max-width:' + newval + 'px;}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="container_width">body .grid-container, .wp-block-group__inner-container{max-width:' + newval + 'px;}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#container_width' ).not( ':last' ).remove();
|
||||
}, 100);
|
||||
}
|
||||
jQuery('body').trigger('generate_spacing_updated');
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Live update for typography options.
|
||||
* We only want to run this if GP Premium isn't already doing it.
|
||||
*/
|
||||
if ( 'undefined' == typeof gp_premium_typography_live_update ) {
|
||||
/**
|
||||
* Body font size, weight and transform
|
||||
*/
|
||||
generatepress_typography_live_update( 'body_font_size', 'body, button, input, select, textarea', 'font-size', 'px' );
|
||||
generatepress_typography_live_update( 'body_line_height', 'body', 'line-height', '' );
|
||||
generatepress_typography_live_update( 'paragraph_margin', 'p, .entry-content > [class*="wp-block-"]:not(:last-child)', 'margin-bottom', 'em' );
|
||||
generatepress_typography_live_update( 'body_font_weight', 'body, button, input, select, textarea', 'font-weight' );
|
||||
generatepress_typography_live_update( 'body_font_transform', 'body, button, input, select, textarea', 'text-transform' );
|
||||
|
||||
/**
|
||||
* H1 font size, weight and transform
|
||||
*/
|
||||
generatepress_typography_live_update( 'heading_1_font_size', 'h1', 'font-size', 'px', generatepress_live_preview.desktop );
|
||||
generatepress_typography_live_update( 'mobile_heading_1_font_size', 'h1', 'font-size', 'px', generatepress_live_preview.mobile );
|
||||
generatepress_typography_live_update( 'heading_1_weight', 'h1', 'font-weight' );
|
||||
generatepress_typography_live_update( 'heading_1_transform', 'h1', 'text-transform' );
|
||||
generatepress_typography_live_update( 'heading_1_line_height', 'h1', 'line-height', 'em' );
|
||||
|
||||
/**
|
||||
* H2 font size, weight and transform
|
||||
*/
|
||||
generatepress_typography_live_update( 'heading_2_font_size', 'h2', 'font-size', 'px', generatepress_live_preview.desktop );
|
||||
generatepress_typography_live_update( 'mobile_heading_2_font_size', 'h2', 'font-size', 'px', generatepress_live_preview.mobile );
|
||||
generatepress_typography_live_update( 'heading_2_weight', 'h2', 'font-weight' );
|
||||
generatepress_typography_live_update( 'heading_2_transform', 'h2', 'text-transform' );
|
||||
generatepress_typography_live_update( 'heading_2_line_height', 'h2', 'line-height', 'em' );
|
||||
|
||||
/**
|
||||
* H3 font size, weight and transform
|
||||
*/
|
||||
generatepress_typography_live_update( 'heading_3_font_size', 'h3', 'font-size', 'px' );
|
||||
generatepress_typography_live_update( 'heading_3_weight', 'h3', 'font-weight' );
|
||||
generatepress_typography_live_update( 'heading_3_transform', 'h3', 'text-transform' );
|
||||
generatepress_typography_live_update( 'heading_3_line_height', 'h3', 'line-height', 'em' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Content layout
|
||||
*/
|
||||
generatepress_classes_live_update( 'content_layout_setting', [ 'one-container', 'separate-containers' ], 'body' );
|
||||
|
||||
/**
|
||||
* Top bar width
|
||||
*/
|
||||
wp.customize( 'generate_settings[top_bar_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'full' == newval ) {
|
||||
$( '.top-bar' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
if ( 'contained' == wp.customize.value('generate_settings[top_bar_inner_width]')() ) {
|
||||
$( '.inside-top-bar' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
}
|
||||
if ( 'contained' == newval ) {
|
||||
$( '.top-bar' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
$( '.inside-top-bar' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Inner top bar width
|
||||
*/
|
||||
wp.customize( 'generate_settings[top_bar_inner_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'full' == newval ) {
|
||||
$( '.inside-top-bar' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
if ( 'contained' == newval ) {
|
||||
$( '.inside-top-bar' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Top bar alignment
|
||||
*/
|
||||
generatepress_classes_live_update( 'top_bar_alignment', [ 'left', 'center', 'right' ], '.top-bar', 'top-bar-align-' );
|
||||
|
||||
/**
|
||||
* Header layout
|
||||
*/
|
||||
wp.customize( 'generate_settings[header_layout_setting]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'fluid-header' == newval ) {
|
||||
$( '.site-header' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
if ( 'contained' == wp.customize.value('generate_settings[header_inner_width]')() ) {
|
||||
$( '.inside-header' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
}
|
||||
if ( 'contained-header' == newval ) {
|
||||
$( '.site-header' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
$( '.inside-header' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Inner Header layout
|
||||
*/
|
||||
wp.customize( 'generate_settings[header_inner_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'full-width' == newval ) {
|
||||
$( '.inside-header' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
if ( 'contained' == newval ) {
|
||||
$( '.inside-header' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Header alignment
|
||||
*/
|
||||
generatepress_classes_live_update( 'header_alignment_setting', [ 'left', 'center', 'right' ], 'body', 'header-aligned-' );
|
||||
|
||||
/**
|
||||
* Navigation width
|
||||
*/
|
||||
wp.customize( 'generate_settings[nav_layout_setting]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( $( 'body' ).hasClass( 'sticky-enabled' ) ) {
|
||||
wp.customize.preview.send( 'refresh' );
|
||||
} else {
|
||||
if ( 'fluid-nav' == newval ) {
|
||||
$( '.main-navigation' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
if ( 'full-width' !== wp.customize.value('generate_settings[nav_inner_width]')() ) {
|
||||
$( '.main-navigation .inside-navigation' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
}
|
||||
if ( 'contained-nav' == newval ) {
|
||||
$( '.main-navigation' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
$( '.main-navigation .inside-navigation' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Inner navigation width
|
||||
*/
|
||||
wp.customize( 'generate_settings[nav_inner_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'full-width' == newval ) {
|
||||
$( '.main-navigation .inside-navigation' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
if ( 'contained' == newval ) {
|
||||
$( '.main-navigation .inside-navigation' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Navigation position
|
||||
*/
|
||||
wp.customize( 'generate_settings[nav_position_setting]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
$( 'body' ).trigger( 'generate_navigation_location_updated' );
|
||||
|
||||
// Update navigation alignment settings.
|
||||
$( 'body' ).removeClass( 'nav-aligned-center' );
|
||||
$( 'body' ).removeClass( 'nav-aligned-left' );
|
||||
$( 'body' ).removeClass( 'nav-aligned-right' );
|
||||
$( 'body' ).addClass( 'nav-aligned-' + wp.customize.value('generate_settings[nav_alignment_setting]')() );
|
||||
|
||||
if ( $( '.gen-sidebar-nav' ).length ) {
|
||||
wp.customize.preview.send( 'refresh' );
|
||||
return false;
|
||||
}
|
||||
if ( 'nav-left-sidebar' == newval ) {
|
||||
wp.customize.preview.send( 'refresh' );
|
||||
return false;
|
||||
}
|
||||
if ( 'nav-right-sidebar' == newval ) {
|
||||
wp.customize.preview.send( 'refresh' );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( '' !== wp.customize.value('generate_settings[nav_drop_point]')() ) {
|
||||
wp.customize.preview.send( 'refresh' );
|
||||
return false;
|
||||
}
|
||||
|
||||
var classes = [ 'nav-below-header', 'nav-above-header', 'nav-float-right', 'nav-float-left', 'nav-left-sidebar', 'nav-right-sidebar' ];
|
||||
if ( 'nav-left-sidebar' !== newval && 'nav-right-sidebar' !== newval ) {
|
||||
$.each( classes, function( i, v ) {
|
||||
$( 'body' ).removeClass( v );
|
||||
});
|
||||
}
|
||||
$( 'body' ).addClass( newval );
|
||||
if ( 'nav-below-header' == newval ) {
|
||||
$( '#site-navigation:first' ).insertAfter( '.site-header' ).show();
|
||||
}
|
||||
if ( 'nav-above-header' == newval ) {
|
||||
if ( $( '.top-bar:not(.secondary-navigation .top-bar)' ).length ) {
|
||||
$( '#site-navigation:first' ).insertAfter( '.top-bar' ).show();
|
||||
} else {
|
||||
$( '#site-navigation:first' ).prependTo( 'body' ).show();
|
||||
}
|
||||
}
|
||||
if ( 'nav-float-right' == newval ) {
|
||||
if ( ! $( 'body' ).hasClass( 'using-floats' ) && $( '.header-widget' ).length ) {
|
||||
$( '#site-navigation:first' ).insertBefore( '.header-widget' ).show();
|
||||
} else {
|
||||
$( '#site-navigation:first' ).appendTo( '.inside-header' ).show();
|
||||
}
|
||||
}
|
||||
if ( 'nav-float-left' == newval ) {
|
||||
$( '#site-navigation:first' ).appendTo( '.inside-header' ).show();
|
||||
}
|
||||
if ( '' == newval ) {
|
||||
if ( $( '.gen-sidebar-nav' ).length ) {
|
||||
wp.customize.preview.send( 'refresh' );
|
||||
} else {
|
||||
$( '#site-navigation:first' ).hide();
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Navigation alignment
|
||||
*/
|
||||
generatepress_classes_live_update( 'nav_alignment_setting', [ 'left', 'center', 'right' ], 'body', 'nav-aligned-' );
|
||||
|
||||
/**
|
||||
* Footer width
|
||||
*/
|
||||
wp.customize( 'generate_settings[footer_layout_setting]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'fluid-footer' == newval ) {
|
||||
$( '.site-footer' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
if ( 'contained-footer' == newval ) {
|
||||
$( '.site-footer' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Inner footer width
|
||||
*/
|
||||
wp.customize( 'generate_settings[footer_inner_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'full-width' == newval ) {
|
||||
if ( $( '.footer-widgets-container' ).length ) {
|
||||
$( '.footer-widgets-container' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
} else {
|
||||
$( '.inside-footer-widgets' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
$( '.inside-site-info' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
|
||||
}
|
||||
if ( 'contained' == newval ) {
|
||||
if ( $( '.footer-widgets-container' ).length ) {
|
||||
$( '.footer-widgets-container' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
} else {
|
||||
$( '.inside-footer-widgets' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
$( '.inside-site-info' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Footer bar alignment
|
||||
*/
|
||||
generatepress_classes_live_update( 'footer_bar_alignment', [ 'left', 'center', 'right' ], '.site-footer', 'footer-bar-align-' );
|
||||
|
||||
jQuery( 'body' ).on( 'generate_spacing_updated', function() {
|
||||
var containerAlignment = wp.customize( 'generate_settings[container_alignment]' ).get(),
|
||||
containerWidth = wp.customize( 'generate_settings[container_width]' ).get(),
|
||||
contentLeft = generatepress_live_preview.contentLeft,
|
||||
contentRight = generatepress_live_preview.contentRight;
|
||||
|
||||
if ( 'text' === containerAlignment ) {
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[content_left]' ) !== 'undefined' ) {
|
||||
contentLeft = wp.customize( 'generate_spacing_settings[content_left]' ).get();
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[content_right]' ) !== 'undefined' ) {
|
||||
contentRight = wp.customize( 'generate_spacing_settings[content_right]' ).get();
|
||||
}
|
||||
|
||||
var newContainerWidth = Number( containerWidth ) + Number( contentLeft ) + Number( contentRight );
|
||||
|
||||
if ( jQuery( 'style#wide_container_width' ).length ) {
|
||||
jQuery( 'style#wide_container_width' ).html( '#page{max-width:' + newContainerWidth + 'px;}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="wide_container_width">#page{max-width:' + newContainerWidth + 'px;}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#wide_container_width' ).not( ':last' ).remove();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
} );
|
||||
} )( jQuery );
|
1
wp-content/themes/generatepress/inc/customizer/controls/js/selectWoo.min.js
vendored
Normal file
1
wp-content/themes/generatepress/inc/customizer/controls/js/selectWoo.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,134 @@
|
||||
wp.customize.controlConstructor['generatepress-range-slider'] = wp.customize.Control.extend({
|
||||
|
||||
ready: function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
var control = this,
|
||||
value,
|
||||
thisInput,
|
||||
inputDefault,
|
||||
changeAction,
|
||||
controlClass = '.customize-control-generatepress-range-slider',
|
||||
footerActions = jQuery( '#customize-footer-actions' );
|
||||
|
||||
// Set up the sliders
|
||||
jQuery( '.generatepress-slider' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
var _input = _this.closest( 'label' ).find( 'input[type="number"]' );
|
||||
var _text = _input.next( '.value' );
|
||||
_this.slider({
|
||||
value: _input.val(),
|
||||
min: _this.data( 'min' ),
|
||||
max: _this.data( 'max' ),
|
||||
step: _this.data( 'step' ),
|
||||
slide: function( event, ui ) {
|
||||
_input.val( ui.value ).change();
|
||||
_text.text( ui.value );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Update the range value based on the input value
|
||||
jQuery( controlClass + ' .gp_range_value input[type=number]' ).on( 'input', function() {
|
||||
value = jQuery( this ).attr( 'value' );
|
||||
if ( '' == value ) {
|
||||
value = -1;
|
||||
}
|
||||
jQuery( this ).closest( 'label' ).find( '.generatepress-slider' ).slider( 'value', parseFloat(value)).change();
|
||||
});
|
||||
|
||||
// Handle the reset button
|
||||
jQuery( controlClass + ' .generatepress-reset' ).on( 'click', function() {
|
||||
var icon = jQuery( this ),
|
||||
visible_area = icon.closest( '.gp-range-title-area' ).next( '.gp-range-slider-areas' ).children( 'label:visible' ),
|
||||
input = visible_area.find( 'input[type=number]' ),
|
||||
slider_value = visible_area.find( '.generatepress-slider' ),
|
||||
visual_value = visible_area.find( '.gp_range_value' ),
|
||||
reset_value = input.attr( 'data-reset_value' );
|
||||
|
||||
input.val( reset_value ).change();
|
||||
visual_value.find( 'input' ).val( reset_value );
|
||||
visual_value.find( '.value' ).text( reset_value );
|
||||
|
||||
if ( '' == reset_value ) {
|
||||
reset_value = -1;
|
||||
}
|
||||
|
||||
slider_value.slider( 'value', parseFloat( reset_value ) );
|
||||
});
|
||||
|
||||
// Figure out which device icon to make active on load
|
||||
jQuery( controlClass + ' .generatepress-range-slider-control' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
_this.find( '.gp-device-controls' ).children( 'span:first-child' ).addClass( 'selected' );
|
||||
_this.find( '.range-option-area:first-child' ).show();
|
||||
});
|
||||
|
||||
// Do stuff when device icons are clicked
|
||||
jQuery( controlClass + ' .gp-device-controls > span' ).on( 'click', function( event ) {
|
||||
var device = jQuery( this ).data( 'option' );
|
||||
|
||||
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.addClass( 'selected' );
|
||||
_this.siblings().removeClass( 'selected' );
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.show();
|
||||
_this.siblings().hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Set the device we're currently viewing
|
||||
wp.customize.previewedDevice.set( jQuery( event.currentTarget ).data( 'option' ) );
|
||||
} );
|
||||
|
||||
// Set the selected devices in our control when the Customizer devices are clicked
|
||||
footerActions.find( '.devices button' ).on( 'click', function() {
|
||||
var device = jQuery( this ).data( 'device' );
|
||||
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.addClass( 'selected' );
|
||||
_this.siblings().removeClass( 'selected' );
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.show();
|
||||
_this.siblings().hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Apply changes when desktop slider is changed
|
||||
control.container.on( 'input change', '.desktop-range',
|
||||
function() {
|
||||
control.settings['desktop'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
// Apply changes when tablet slider is changed
|
||||
control.container.on( 'input change', '.tablet-range',
|
||||
function() {
|
||||
control.settings['tablet'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
// Apply changes when mobile slider is changed
|
||||
control.container.on( 'input change', '.mobile-range',
|
||||
function() {
|
||||
control.settings['mobile'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
});
|
@ -0,0 +1,154 @@
|
||||
( function( api ) {
|
||||
|
||||
api.controlConstructor['gp-customizer-typography'] = api.Control.extend( {
|
||||
ready: function() {
|
||||
var control = this;
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-family select',
|
||||
function() {
|
||||
var _this = jQuery( this ),
|
||||
_value = _this.val(),
|
||||
_categoryID = _this.attr( 'data-category' ),
|
||||
_variantsID = _this.attr( 'data-variants' );
|
||||
|
||||
// Set our font family
|
||||
control.settings['family'].set( _this.val() );
|
||||
|
||||
// Bail if our controls don't exist
|
||||
if ( 'undefined' == typeof control.settings['category'] || 'undefined' == typeof control.settings['variant'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout( function() {
|
||||
// Send our request to the generate_get_all_google_fonts_ajax function
|
||||
var response = jQuery.getJSON({
|
||||
type: 'POST',
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'generate_get_all_google_fonts_ajax',
|
||||
gp_customize_nonce: gp_customize.nonce
|
||||
},
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
});
|
||||
|
||||
// Get our response
|
||||
var fonts = response.responseJSON;
|
||||
|
||||
// Create an ID from our selected font
|
||||
var id = _value.split(' ').join('_').toLowerCase();
|
||||
|
||||
// Set our values if we have them
|
||||
if ( id in fonts ) {
|
||||
|
||||
// Get existing variants if this font is already selected
|
||||
var got_variants = false;
|
||||
jQuery( '.generatepress-font-family select' ).not( _this ).each( function( key, select ) {
|
||||
var parent = jQuery( this ).closest( '.generatepress-font-family' );
|
||||
|
||||
if ( _value == jQuery( select ).val() && _this.data( 'category' ) !== jQuery( select ).data( 'category' ) ) {
|
||||
if ( ! got_variants ) {
|
||||
updated_variants = jQuery( parent.next( '.generatepress-font-variant' ).find( 'select' ) ).val();
|
||||
got_variants = true;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// We're using a Google font, so show the variants field
|
||||
_this.closest( '.generatepress-font-family' ).next( 'div' ).show();
|
||||
|
||||
// Remove existing variants
|
||||
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
|
||||
|
||||
// Populate our select input with available variants
|
||||
jQuery.each( fonts[ id ].variants, function( key, value ) {
|
||||
jQuery( 'select[name="' + _variantsID + '"]' ).append( jQuery( '<option></option>' ).attr( 'value', value ).text( value ) );
|
||||
} );
|
||||
|
||||
// Set our variants
|
||||
if ( ! got_variants ) {
|
||||
control.settings[ 'variant' ].set( fonts[ id ].variants );
|
||||
} else {
|
||||
control.settings[ 'variant' ].set( updated_variants );
|
||||
}
|
||||
|
||||
// Set our font category
|
||||
control.settings[ 'category' ].set( fonts[ id ].category );
|
||||
jQuery( 'input[name="' + _categoryID + '"' ).val( fonts[ id ].category );
|
||||
} else {
|
||||
_this.closest( '.generatepress-font-family' ).next( 'div' ).hide();
|
||||
control.settings[ 'category' ].set( '' )
|
||||
control.settings[ 'variant' ].set( '' )
|
||||
jQuery( 'input[name="' + _categoryID + '"' ).val( '' );
|
||||
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
|
||||
}
|
||||
}, 25 );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-variant select',
|
||||
function() {
|
||||
var _this = jQuery( this );
|
||||
var variants = _this.val();
|
||||
|
||||
control.settings['variant'].set( variants );
|
||||
|
||||
jQuery( '.generatepress-font-variant select' ).each( function( key, value ) {
|
||||
var this_control = jQuery( this ).closest( 'li' ).attr( 'id' ).replace( 'customize-control-', '' );
|
||||
var parent = jQuery( this ).closest( '.generatepress-font-variant' );
|
||||
var font_val = api.control( this_control ).settings['family'].get();
|
||||
|
||||
if ( font_val == control.settings['family'].get() && _this.attr( 'name' ) !== jQuery( value ).attr( 'name' ) ) {
|
||||
jQuery( parent.find( 'select' ) ).not( _this ).val( variants ).triggerHandler( 'change' );
|
||||
api.control( this_control ).settings['variant'].set( variants );
|
||||
}
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-category input',
|
||||
function() {
|
||||
control.settings['category'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-weight select',
|
||||
function() {
|
||||
control.settings['weight'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-transform select',
|
||||
function() {
|
||||
control.settings['transform'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
} );
|
||||
|
||||
} )( wp.customize );
|
||||
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
|
||||
$( '.generatepress-font-family select' ).select2();
|
||||
|
||||
$( '.generatepress-font-variant' ).each( function( key, value ) {
|
||||
var _this = $( this );
|
||||
var value = _this.data( 'saved-value' );
|
||||
|
||||
if ( value ) {
|
||||
value = value.toString().split( ',' );
|
||||
}
|
||||
|
||||
_this.find( 'select' ).select2().val( value ).trigger( 'change.select2' );
|
||||
} );
|
||||
|
||||
$( ".generatepress-font-family" ).each( function( key, value ) {
|
||||
var _this = $( this );
|
||||
if ( $.inArray( _this.find( 'select' ).val(), typography_defaults ) !== -1 ) {
|
||||
_this.next( '.generatepress-font-variant' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
@ -0,0 +1,12 @@
|
||||
( function( $, api ) {
|
||||
api.sectionConstructor['gp-upsell-section'] = api.Section.extend( {
|
||||
|
||||
// No events for this type of section.
|
||||
attachEvents: function () {},
|
||||
|
||||
// Always make the section active.
|
||||
isContextuallyActive: function () {
|
||||
return true;
|
||||
}
|
||||
} );
|
||||
} )( jQuery, wp.customize );
|
Reference in New Issue
Block a user