modified file smtp-mailer

This commit is contained in:
2024-06-27 12:11:15 +00:00
committed by Gitium
parent 91db4aebe1
commit 19e351ef3b
1005 changed files with 230351 additions and 8670 deletions

View File

@ -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' );
});

View File

@ -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 ) );

View File

@ -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' );
} );
} );
} );

View File

@ -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',
} );
} );
} );
} );

View File

@ -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 ) );

View File

@ -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 ) );

View File

@ -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();
} );
}
} );

File diff suppressed because one or more lines are too long

View File

@ -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() );
}
);
},
} );

View File

@ -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();
} );
} );
} );

View File

@ -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();
}
} );
} );