initial
This commit is contained in:
commit
9883323161
17470 files changed
+4470592
No files matched your search
@@ -0,0 +1,277 @@
|
||||
/**
|
||||
* Alpha Color Picker JS
|
||||
*
|
||||
* This file includes several helper functions and the core control JS.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Override the stock color.js toString() method to add support for
|
||||
* outputting RGBa or Hex.
|
||||
*/
|
||||
Color.prototype.toString = function( flag ) {
|
||||
|
||||
// If our no-alpha flag has been passed in, output RGBa value with 100% opacity.
|
||||
// This is used to set the background color on the opacity slider during color changes.
|
||||
if ( 'no-alpha' == flag ) {
|
||||
return this.toCSS( 'rgba', '1' ).replace( /\s+/g, '' );
|
||||
}
|
||||
|
||||
// If we have a proper opacity value, output RGBa.
|
||||
if ( 1 > this._alpha ) {
|
||||
return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
|
||||
}
|
||||
|
||||
// Proceed with stock color.js hex output.
|
||||
var hex = parseInt( this._color, 10 ).toString( 16 );
|
||||
if ( this.error ) { return ''; }
|
||||
if ( hex.length < 6 ) {
|
||||
for ( var i = 6 - hex.length - 1; i >= 0; i-- ) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
}
|
||||
|
||||
return '#' + hex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Given an RGBa, RGB, or hex color value, return the alpha channel value.
|
||||
*/
|
||||
function generate_get_alpha_value_from_color( value ) {
|
||||
var alphaVal;
|
||||
|
||||
// Remove all spaces from the passed in value to help our RGBa regex.
|
||||
value = value.toString().replace( / /g, '' );
|
||||
|
||||
if ( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ ) ) {
|
||||
alphaVal = parseFloat( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ )[1] ).toFixed(2) * 100;
|
||||
alphaVal = parseInt( alphaVal );
|
||||
} else {
|
||||
alphaVal = 100;
|
||||
}
|
||||
|
||||
return alphaVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force update the alpha value of the color picker object and maybe the alpha slider.
|
||||
*/
|
||||
function generate_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, update_slider ) {
|
||||
var iris, colorPicker, color;
|
||||
|
||||
iris = $control.data( 'a8cIris' );
|
||||
colorPicker = $control.data( 'wpWpColorPicker' );
|
||||
|
||||
// Set the alpha value on the Iris object.
|
||||
iris._color._alpha = alpha;
|
||||
|
||||
// Store the new color value.
|
||||
color = iris._color.toString();
|
||||
|
||||
// Set the value of the input.
|
||||
$control.val( color );
|
||||
|
||||
// Update the background color of the color picker.
|
||||
colorPicker.toggler.css({
|
||||
'background-color': color
|
||||
});
|
||||
|
||||
// Maybe update the alpha slider itself.
|
||||
if ( update_slider ) {
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
}
|
||||
|
||||
// Update the color value of the color picker object.
|
||||
$control.wpColorPicker( 'color', color );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the slider handle position and label.
|
||||
*/
|
||||
function generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider ) {
|
||||
$alphaSlider.slider( 'value', alpha );
|
||||
//$alphaSlider.find( '.ui-slider-handle' ).text( alpha.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization trigger.
|
||||
*/
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
|
||||
// Loop over each control and transform it into our color picker.
|
||||
$( '.gp-alpha-color-control' ).each( function() {
|
||||
|
||||
// Scope the vars.
|
||||
var $control, startingColor, paletteInput, showOpacity, defaultColor, palette,
|
||||
colorPickerOptions, $container, $alphaSlider, alphaVal, sliderOptions, savedValue;
|
||||
|
||||
// Store the control instance.
|
||||
$control = $( this );
|
||||
|
||||
// Get our saved value
|
||||
savedValue = wp.customize.value( $control.attr( 'data-customize-setting-link' ) )();
|
||||
|
||||
// Get a clean starting value for the option.
|
||||
startingColor = savedValue.toString().replace( /\s+/g, '' );
|
||||
|
||||
// Get some data off the control.
|
||||
paletteInput = $control.attr( 'data-palette' );
|
||||
showOpacity = $control.attr( 'data-show-opacity' );
|
||||
defaultColor = $control.attr( 'data-default-color' );
|
||||
|
||||
// Process the palette.
|
||||
if ( paletteInput.indexOf( '|' ) !== -1 ) {
|
||||
palette = paletteInput.split( '|' );
|
||||
} else if ( 'false' == paletteInput ) {
|
||||
palette = false;
|
||||
} else {
|
||||
palette = true;
|
||||
}
|
||||
|
||||
// Set up the options that we'll pass to wpColorPicker().
|
||||
colorPickerOptions = {
|
||||
change: function( event, ui ) {
|
||||
var key, value, alpha, $transparency;
|
||||
|
||||
key = $control.attr( 'data-customize-setting-link' );
|
||||
value = $control.wpColorPicker( 'color' );
|
||||
|
||||
// Send ajax request to wp.customize to trigger the Save action.
|
||||
wp.customize( key, function( obj ) {
|
||||
obj.set( value );
|
||||
});
|
||||
|
||||
$transparency = $container.find( '.transparency' );
|
||||
|
||||
// Always show the background color of the opacity slider at 100% opacity.
|
||||
$alphaSlider.closest( '.gp-alpha-color-picker-container' ).css( 'background-color', ui.color.toString( 'no-alpha' ) );
|
||||
},
|
||||
palettes: palette
|
||||
};
|
||||
|
||||
// Create the colorpicker.
|
||||
$control.val( savedValue ).wpColorPicker( colorPickerOptions );
|
||||
|
||||
$container = $control.parents( '.wp-picker-container:first' );
|
||||
|
||||
// Insert our opacity slider.
|
||||
$( '<div class="gp-alpha-color-picker-container iris-slider iris-strip">' +
|
||||
'<div class="alpha-slider iris-slider-offset"></div>' +
|
||||
'</div>' ).appendTo( $container.find( '.iris-picker-inner' ) );
|
||||
|
||||
$alphaSlider = $container.find( '.alpha-slider' );
|
||||
|
||||
// If starting value is in format RGBa, grab the alpha channel.
|
||||
alphaVal = generate_get_alpha_value_from_color( startingColor );
|
||||
|
||||
// Get the solid color
|
||||
solidColor = startingColor.toString().replace( '0.' + alphaVal, '100' );
|
||||
|
||||
// Set up jQuery UI slider() options.
|
||||
sliderOptions = {
|
||||
create: function( event, ui ) {
|
||||
var value = $( this ).slider( 'value' );
|
||||
|
||||
// Set up initial values.
|
||||
//$( this ).find( '.ui-slider-handle' ).text( value );
|
||||
$( this ).closest( '.iris-slider' ).css( 'background-color', solidColor );
|
||||
},
|
||||
value: alphaVal,
|
||||
range: 'max',
|
||||
step: 1,
|
||||
min: 0,
|
||||
max: 100,
|
||||
animate: 300,
|
||||
orientation: "vertical"
|
||||
};
|
||||
|
||||
// Initialize jQuery UI slider with our options.
|
||||
$alphaSlider.slider( sliderOptions );
|
||||
|
||||
// Bind event handler for clicking on a palette color.
|
||||
$container.find( '.iris-palette' ).on( 'click', function() {
|
||||
var color, alpha;
|
||||
|
||||
color = $( this ).css( 'background-color' );
|
||||
alpha = generate_get_alpha_value_from_color( color );
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
|
||||
// Sometimes Iris doesn't set a perfect background-color on the palette,
|
||||
// for example rgba(20, 80, 100, 0.3) becomes rgba(20, 80, 100, 0.298039).
|
||||
// To compensante for this we round the opacity value on RGBa colors here
|
||||
// and save it a second time to the color picker object.
|
||||
if ( alpha != 100 ) {
|
||||
color = color.toString().replace( /[^,]+(?=\))/, ( alpha / 100 ).toFixed( 2 ) );
|
||||
}
|
||||
|
||||
$control.wpColorPicker( 'color', color );
|
||||
});
|
||||
|
||||
// Bind event handler for clicking on the 'Clear' button.
|
||||
$container.find( '.button.wp-picker-clear' ).on( 'click', function() {
|
||||
var key = $control.attr( 'data-customize-setting-link' );
|
||||
|
||||
// The #fff color is delibrate here. This sets the color picker to white instead of the
|
||||
// defult black, which puts the color picker in a better place to visually represent empty.
|
||||
$control.wpColorPicker( 'color', '#ffffff' );
|
||||
|
||||
// Set the actual option value to empty string.
|
||||
wp.customize( key, function( obj ) {
|
||||
obj.set( '' );
|
||||
});
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( 100, $alphaSlider );
|
||||
});
|
||||
|
||||
// Bind event handler for clicking on the 'Default' button.
|
||||
$container.find( '.button.wp-picker-default' ).on( 'click', function() {
|
||||
var alpha = generate_get_alpha_value_from_color( defaultColor );
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
});
|
||||
|
||||
// Bind event handler for typing or pasting into the input.
|
||||
$control.on( 'input', function() {
|
||||
var value = $( this ).val();
|
||||
|
||||
if ( '' === value ) {
|
||||
var key = $control.attr( 'data-customize-setting-link' );
|
||||
|
||||
// The #fff color is delibrate here. This sets the color picker to white instead of the
|
||||
// defult black, which puts the color picker in a better place to visually represent empty.
|
||||
$control.wpColorPicker( 'color', '' );
|
||||
|
||||
// Set the actual option value to empty string.
|
||||
wp.customize( key, function( obj ) {
|
||||
obj.set( '' );
|
||||
});
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( 100, $alphaSlider );
|
||||
} else {
|
||||
var alpha = generate_get_alpha_value_from_color( value );
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
}
|
||||
});
|
||||
|
||||
// Update all the things when the slider is interacted with.
|
||||
$alphaSlider.slider().on( 'slide', function( event, ui ) {
|
||||
var alpha = parseFloat( ui.value ) / 100.0;
|
||||
|
||||
generate_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, false );
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Move the opacity bar next to the hue bar
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
var container_width = $( '.customize-control-gp-alpha-color .iris-picker' ).width();
|
||||
var square_width = $( '.customize-control-gp-alpha-color .iris-square' ).width();
|
||||
var available_space = container_width - square_width;
|
||||
var strip_width = ( available_space / 2 ) - 20;
|
||||
var strip_height = $( '.customize-control-gp-alpha-color .iris-strip' ).height();
|
||||
$( '.customize-control-gp-alpha-color .iris-strip, .gp-alpha-color-picker-container' ).css( 'width', strip_width + 'px' );
|
||||
$( '.gp-alpha-color-picker-container' ).css( 'height', strip_height + 'px' );
|
||||
|
||||
});
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
( function( api ) {
|
||||
api.controlConstructor[ 'gp-background-images' ] = api.Control.extend( {
|
||||
ready() {
|
||||
var control = this;
|
||||
|
||||
control.container.on( 'change', '.generatepress-backgrounds-repeat select',
|
||||
function() {
|
||||
control.settings.repeat.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-backgrounds-size select',
|
||||
function() {
|
||||
control.settings.size.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-backgrounds-attachment select',
|
||||
function() {
|
||||
control.settings.attachment.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'input', '.generatepress-backgrounds-position input',
|
||||
function() {
|
||||
control.settings.position.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
},
|
||||
} );
|
||||
}( wp.customize ) );
|
||||
@@ -0,0 +1,43 @@
|
||||
jQuery( function( $ ) {
|
||||
$( '[data-type="overlay_design"]' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// eslint-disable-next-line no-alert
|
||||
if ( ! confirm( gpButtonActions.warning ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
( function( api ) {
|
||||
'use strict';
|
||||
|
||||
api.instance( 'generate_settings[slideout_background_color]' ).set( gpButtonActions.styling.backgroundColor );
|
||||
api.instance( 'generate_settings[slideout_text_color]' ).set( gpButtonActions.styling.textColor );
|
||||
api.instance( 'generate_settings[slideout_background_hover_color]' ).set( gpButtonActions.styling.backgroundHoverColor );
|
||||
api.instance( 'generate_settings[slideout_background_current_color]' ).set( gpButtonActions.styling.backgroundCurrentColor );
|
||||
|
||||
api.instance( 'generate_settings[slideout_submenu_background_color]' ).set( gpButtonActions.styling.subMenuBackgroundColor );
|
||||
api.instance( 'generate_settings[slideout_submenu_text_color]' ).set( gpButtonActions.styling.subMenuTextColor );
|
||||
api.instance( 'generate_settings[slideout_submenu_background_hover_color]' ).set( gpButtonActions.styling.subMenuBackgroundHoverColor );
|
||||
api.instance( 'generate_settings[slideout_submenu_background_current_color]' ).set( gpButtonActions.styling.subMenuBackgroundCurrentColor );
|
||||
|
||||
api.instance( 'generate_settings[slideout_font_weight]' ).set( gpButtonActions.styling.fontWeight );
|
||||
api.instance( 'generate_settings[slideout_font_size]' ).set( gpButtonActions.styling.fontSize );
|
||||
|
||||
$( '.wp-color-picker' ).wpColorPicker().change();
|
||||
}( wp.customize ) );
|
||||
} );
|
||||
|
||||
$( '[data-type="regenerate_external_css"]' ).on( 'click', function( e ) {
|
||||
var $thisButton = $( this ); // eslint-disable-line no-var
|
||||
e.preventDefault();
|
||||
|
||||
$thisButton.removeClass( 'success' ).addClass( 'loading' );
|
||||
|
||||
$.post( ajaxurl, {
|
||||
action: 'generatepress_regenerate_css_file',
|
||||
_nonce: $thisButton.data( 'nonce' ),
|
||||
} ).done( function() {
|
||||
$thisButton.removeClass( 'loading' ).addClass( 'success' );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
jQuery( function( $ ) {
|
||||
$( '.generatepress-control-toggles' ).each( function() {
|
||||
$( this ).find( 'button' ).first().addClass( 'active' );
|
||||
} );
|
||||
|
||||
$( document ).on( 'click', '.generatepress-control-toggles button', function( e ) {
|
||||
e.preventDefault();
|
||||
var button = $( this ),
|
||||
target = button.data( 'target' ),
|
||||
otherTargets = button.siblings();
|
||||
|
||||
button.addClass( 'active' );
|
||||
button.siblings().removeClass( 'active' );
|
||||
|
||||
$( 'li[data-control-section="' + target + '"]' ).css( {
|
||||
visibility: 'visible',
|
||||
height: '',
|
||||
width: '',
|
||||
margin: '',
|
||||
overflow: '',
|
||||
} );
|
||||
|
||||
$.each( otherTargets, function() {
|
||||
var otherTarget = $( this ).data( 'target' );
|
||||
|
||||
$( 'li[data-control-section="' + otherTarget + '"]' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0',
|
||||
overflow: 'hidden',
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
@@ -0,0 +1,12 @@
|
||||
( function( $, api ) {
|
||||
api.controlConstructor[ 'gp-copyright' ] = api.Control.extend( {
|
||||
ready() {
|
||||
var control = this;
|
||||
$( '.gp-copyright-area', control.container ).on( 'change keyup',
|
||||
function() {
|
||||
control.setting.set( $( this ).val() );
|
||||
}
|
||||
);
|
||||
},
|
||||
} );
|
||||
}( jQuery, wp.customize ) );
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
( function( $, api ) {
|
||||
/**
|
||||
* Set some controls when we're using the navigation as a header.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
api( 'generate_menu_plus_settings[navigation_as_header]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' ),
|
||||
navAlignment = gpControls.navigationAlignment,
|
||||
siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' ),
|
||||
mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
|
||||
siteTitleFontSize = gpControls.siteTitleFontSize,
|
||||
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize,
|
||||
mobileHeader = api.instance( 'generate_menu_plus_settings[mobile_header]' ).get(),
|
||||
navTextColorSetting = api.instance( 'generate_settings[navigation_text_color]' ),
|
||||
navTextColor = gpControls.navigationTextColor,
|
||||
siteTitleTextColorSetting = api.instance( 'generate_settings[site_title_color]' ),
|
||||
siteTitleTextColor = gpControls.siteTitleTextColor;
|
||||
|
||||
if ( siteTitleFontSizeSetting && ! siteTitleFontSizeSetting._dirty && 25 !== siteTitleFontSizeSetting.get() ) {
|
||||
siteTitleFontSize = siteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( mobileSiteTitleFontSizeSetting && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
|
||||
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( navTextColorSetting && ! navTextColorSetting._dirty ) {
|
||||
navTextColor = navTextColorSetting.get();
|
||||
}
|
||||
|
||||
if ( siteTitleTextColorSetting && ! siteTitleTextColorSetting._dirty ) {
|
||||
siteTitleTextColor = siteTitleTextColorSetting.get();
|
||||
}
|
||||
|
||||
if ( newval ) {
|
||||
navAlignmentSetting.set( 'right' );
|
||||
|
||||
if ( siteTitleFontSizeSetting ) {
|
||||
siteTitleFontSizeSetting.set( 25 );
|
||||
}
|
||||
|
||||
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
|
||||
api.instance( 'generate_settings[site_title_color]' ).set( navTextColor );
|
||||
}
|
||||
|
||||
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
|
||||
mobileSiteTitleFontSizeSetting.set( 20 );
|
||||
}
|
||||
} else {
|
||||
navAlignmentSetting.set( navAlignment );
|
||||
|
||||
if ( siteTitleFontSizeSetting ) {
|
||||
siteTitleFontSizeSetting.set( siteTitleFontSize );
|
||||
}
|
||||
|
||||
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
|
||||
api.instance( 'generate_settings[site_title_color]' ).set( siteTitleTextColor );
|
||||
}
|
||||
|
||||
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
|
||||
mobileSiteTitleFontSizeSetting.set( mobileSiteTitleFontSize );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
var showRegularHeader,
|
||||
showRegularHeaderCallback;
|
||||
|
||||
/**
|
||||
* Determine whether we should display our header controls.
|
||||
*
|
||||
* @return {boolean} Whether we should show the regular header.
|
||||
*/
|
||||
showRegularHeader = function() {
|
||||
if ( value.get() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation as header option.
|
||||
*
|
||||
* @param {wp.customize.Control} control The current control.
|
||||
*/
|
||||
showRegularHeaderCallback = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( showRegularHeader() );
|
||||
};
|
||||
|
||||
control.active.validate = showRegularHeader;
|
||||
setActiveState();
|
||||
value.bind( setActiveState );
|
||||
};
|
||||
|
||||
api.control( 'generate_header_helper', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_layout_setting]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_inner_width]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_alignment_setting]', showRegularHeaderCallback );
|
||||
api.control( 'header_spacing', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_background_color]', showRegularHeaderCallback );
|
||||
api.control( 'header_text_color', showRegularHeaderCallback );
|
||||
api.control( 'header_link_color', showRegularHeaderCallback );
|
||||
api.control( 'header_link_hover_color', showRegularHeaderCallback );
|
||||
api.control( 'site_tagline_color', showRegularHeaderCallback );
|
||||
api.control( 'font_site_tagline_control', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[site_tagline_font_size]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[nav_position_setting]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[logo_width]', showRegularHeaderCallback );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Set the navigation branding font size label on mobile header branding change.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
api( 'generate_menu_plus_settings[mobile_header_branding]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) && 'title' === newval ) {
|
||||
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Set the navigation branding font size label on mobile header change.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
api( 'generate_menu_plus_settings[mobile_header]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
var mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
|
||||
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize;
|
||||
|
||||
if ( mobileSiteTitleFontSizeSetting && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
|
||||
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) ) {
|
||||
if ( 'enable' === newval ) {
|
||||
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
|
||||
} else {
|
||||
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( mobileSiteTitleFontSize );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}( jQuery, wp.customize ) );
|
||||
@@ -0,0 +1,46 @@
|
||||
jQuery( function( $ ) {
|
||||
$( '.generatepress-shortcuts a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
var section = $( this ).attr( 'data-section' ),
|
||||
currentSection = $( this ).attr( 'data-current-section' ),
|
||||
destinationSectionElement = $( '[id$="' + section + '"]' );
|
||||
|
||||
if ( section ) {
|
||||
wp.customize.section( section ).focus();
|
||||
|
||||
destinationSectionElement.find( '.show-shortcuts' ).hide();
|
||||
destinationSectionElement.find( '.return-shortcut' ).show();
|
||||
destinationSectionElement.find( '.return-shortcut a' ).attr( 'data-return', currentSection );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.return-shortcut .dashicons' ).on( 'click', function() {
|
||||
var container = $( this ).closest( '.generatepress-shortcuts' );
|
||||
|
||||
container.find( '.show-shortcuts' ).show();
|
||||
container.find( '.return-shortcut' ).hide();
|
||||
} );
|
||||
|
||||
$( '.return-shortcut a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var section = $( this ).attr( 'data-return' );
|
||||
var container = $( this ).closest( '.generatepress-shortcuts' );
|
||||
|
||||
if ( section ) {
|
||||
wp.customize.section( section ).focus();
|
||||
|
||||
container.find( '.show-shortcuts' ).show();
|
||||
container.find( '.return-shortcut' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
var customizeSectionBack = $( '.customize-section-back' );
|
||||
|
||||
if ( customizeSectionBack ) {
|
||||
customizeSectionBack.on( 'click', function() {
|
||||
$( '.show-shortcuts' ).show();
|
||||
$( '.return-shortcut' ).hide();
|
||||
} );
|
||||
}
|
||||
} );
|
||||
@@ -0,0 +1 @@
|
||||
/*! Select2 1.0.8 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return v.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o=b&&b.split("/"),p=t.map,q=p&&p["*"]||{};if(a){for(a=a.split("/"),g=a.length-1,t.nodeIdCompat&&x.test(a[g])&&(a[g]=a[g].replace(x,"")),"."===a[0].charAt(0)&&o&&(n=o.slice(0,o.length-1),a=n.concat(a)),k=0;k<a.length;k++)if("."===(m=a[k]))a.splice(k,1),k-=1;else if(".."===m){if(0===k||1===k&&".."===a[2]||".."===a[k-1])continue;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}if((o||q)&&p){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),o)for(l=o.length;l>0;l-=1)if((e=p[o.slice(0,l).join("/")])&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&q&&q[d]&&(i=q[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=w.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),o.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){r[a]=b}}function j(a){if(e(s,a)){var c=s[a];delete s[a],u[a]=!0,n.apply(b,c)}if(!e(r,a)&&!e(u,a))throw new Error("No "+a);return r[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return a?k(a):[]}function m(a){return function(){return t&&t.config&&t.config[a]||{}}}var n,o,p,q,r={},s={},t={},u={},v=Object.prototype.hasOwnProperty,w=[].slice,x=/\.js$/;p=function(a,b){var c,d=k(a),e=d[0],g=b[1];return a=d[1],e&&(e=f(e,g),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(g)):f(a,g):(a=f(a,g),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},q={require:function(a){return g(a)},exports:function(a){var b=r[a];return void 0!==b?b:r[a]={}},module:function(a){return{id:a,uri:"",exports:r[a],config:m(a)}}},n=function(a,c,d,f){var h,k,m,n,o,t,v,w=[],x=typeof d;if(f=f||a,t=l(f),"undefined"===x||"function"===x){for(c=!c.length&&d.length?["require","exports","module"]:c,o=0;o<c.length;o+=1)if(n=p(c[o],t),"require"===(k=n.f))w[o]=q.require(a);else if("exports"===k)w[o]=q.exports(a),v=!0;else if("module"===k)h=w[o]=q.module(a);else if(e(r,k)||e(s,k)||e(u,k))w[o]=j(k);else{if(!n.p)throw new Error(a+" missing "+k);n.p.load(n.n,g(f,!0),i(k),{}),w[o]=r[k]}m=d?d.apply(r[a],w):void 0,a&&(h&&h.exports!==b&&h.exports!==r[a]?r[a]=h.exports:m===b&&v||(r[a]=m))}else a&&(r[a]=d)},a=c=o=function(a,c,d,e,f){if("string"==typeof a)return q[a]?q[a](c):j(p(a,l(c)).f);if(!a.splice){if(t=a,t.deps&&o(t.deps,t.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?n(b,a,c,d):setTimeout(function(){n(b,a,c,d)},4),o},o.config=function(a){return o(a)},a._defined=r,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(r,a)||e(s,a)||(s[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){"function"==typeof b[d]&&("constructor"!==d&&c.push(d))}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){return Array.prototype.unshift.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};return d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]Line truncated
|
||||
@@ -0,0 +1,137 @@
|
||||
wp.customize.controlConstructor[ 'generatepress-pro-range-slider' ] = wp.customize.Control.extend( {
|
||||
ready() {
|
||||
'use strict';
|
||||
|
||||
var control = this,
|
||||
value,
|
||||
controlClass = '.customize-control-generatepress-pro-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( 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 ),
|
||||
visibleArea = icon.closest( '.gp-range-title-area' ).next( '.gp-range-slider-areas' ).children( 'label:visible' ),
|
||||
input = visibleArea.find( 'input[type=number]' ),
|
||||
sliderValue = visibleArea.find( '.generatepress-slider' ),
|
||||
visualValue = visibleArea.find( '.gp_range_value' ),
|
||||
resetValue = input.attr( 'data-reset_value' );
|
||||
|
||||
input.val( resetValue ).change();
|
||||
visualValue.find( 'input' ).val( resetValue );
|
||||
visualValue.find( '.value' ).text( resetValue );
|
||||
|
||||
if ( '' == resetValue ) {
|
||||
resetValue = -1;
|
||||
}
|
||||
|
||||
sliderValue.slider( 'value', parseFloat( resetValue ) );
|
||||
} );
|
||||
|
||||
// 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,203 @@
|
||||
( function( $, api ) {
|
||||
// No longer needed as of 1.2.95
|
||||
// Keeping it here just in case
|
||||
api.controlConstructor.spacing = api.Control.extend( {
|
||||
ready() {
|
||||
var control = this;
|
||||
$( '.generate-number-control', control.container ).on( 'change keyup',
|
||||
function() {
|
||||
control.setting.set( $( this ).val() );
|
||||
}
|
||||
);
|
||||
},
|
||||
} );
|
||||
|
||||
api.controlConstructor[ 'gp-spacing-slider' ] = api.Control.extend( {
|
||||
ready() {
|
||||
var control = this;
|
||||
$( '.slider-input', control.container ).on( 'change keyup',
|
||||
function() {
|
||||
control.setting.set( $( this ).val() );
|
||||
}
|
||||
);
|
||||
},
|
||||
} );
|
||||
|
||||
api.controlConstructor[ 'generatepress-spacing' ] = api.Control.extend( {
|
||||
ready() {
|
||||
var control = this,
|
||||
controlClass = '.customize-control-generatepress-spacing',
|
||||
footerActions = jQuery( '#customize-footer-actions' );
|
||||
|
||||
// Figure out which device icon to make active on load
|
||||
jQuery( controlClass + ' .gp-spacing-control-section' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
_this.find( '.gp-device-controls' ).children( 'span:first-child' ).addClass( 'selected' );
|
||||
_this.find( '.spacing-values-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 + ' .spacing-values-container .spacing-values-area' ).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 + ' .spacing-values-container .spacing-values-area' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
|
||||
if ( device === _this.attr( 'data-option' ) ) {
|
||||
_this.show();
|
||||
_this.siblings().hide();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-top',
|
||||
function() {
|
||||
control.settings.desktop_top.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-right',
|
||||
function() {
|
||||
control.settings.desktop_right.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-bottom',
|
||||
function() {
|
||||
control.settings.desktop_bottom.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-left',
|
||||
function() {
|
||||
control.settings.desktop_left.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-top',
|
||||
function() {
|
||||
control.settings.tablet_top.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-right',
|
||||
function() {
|
||||
control.settings.tablet_right.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-bottom',
|
||||
function() {
|
||||
control.settings.tablet_bottom.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-left',
|
||||
function() {
|
||||
control.settings.tablet_left.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-top',
|
||||
function() {
|
||||
control.settings.mobile_top.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-right',
|
||||
function() {
|
||||
control.settings.mobile_right.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-bottom',
|
||||
function() {
|
||||
control.settings.mobile_bottom.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-left',
|
||||
function() {
|
||||
control.settings.mobile_left.set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
},
|
||||
} );
|
||||
}( jQuery, wp.customize ) );
|
||||
|
||||
jQuery( function( $ ) {
|
||||
$( '.gp-link-spacing' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// Set up variables
|
||||
var _this = $( this ),
|
||||
element = _this.data( 'element' );
|
||||
|
||||
// Add our linked-values class to the next 4 elements
|
||||
_this.parent( '.gp-spacing-section' ).prevAll().slice( 0, 4 ).find( 'input' ).addClass( 'linked-values' ).attr( 'data-element', element );
|
||||
|
||||
// Change our link icon class
|
||||
_this.hide();
|
||||
_this.next( 'span' ).show();
|
||||
} );
|
||||
|
||||
$( '.gp-unlink-spacing' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// Set up variables
|
||||
var _this = $( this );
|
||||
|
||||
// Remove our linked-values class to the next 4 elements
|
||||
_this.parent( '.gp-spacing-section' ).prevAll().slice( 0, 4 ).find( 'input' ).removeClass( 'linked-values' ).attr( 'data-element', '' );
|
||||
|
||||
// Change our link icon class
|
||||
_this.hide();
|
||||
_this.prev( 'span' ).show();
|
||||
} );
|
||||
|
||||
$( '.gp-spacing-section' ).on( 'input', '.linked-values', function() {
|
||||
var _this = $( this ),
|
||||
data = _this.attr( 'data-element' ),
|
||||
val = _this.val(),
|
||||
targetElements = _this.closest( '.spacing-values-area' ).find( '.linked-values[ data-element="' + data + '" ]' );
|
||||
|
||||
targetElements.each( function() {
|
||||
var element = $( this );
|
||||
element.val( val ).change();
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
( function( api ) {
|
||||
api.controlConstructor[ 'gp-pro-customizer-typography' ] = api.Control.extend( {
|
||||
ready() {
|
||||
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( $ ) {
|
||||
jQuery( '.generatepress-font-family select' ).selectWoo();
|
||||
jQuery( '.generatepress-font-variant' ).each( function( key, value ) {
|
||||
var _this = $( this );
|
||||
value = _this.data( 'saved-value' );
|
||||
|
||||
if ( value ) {
|
||||
value = value.toString().split( ',' );
|
||||
}
|
||||
|
||||
_this.find( 'select' ).selectWoo().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();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
Reference in new issue
Block a user