2020-04-07 13:03:04 +00:00
|
|
|
( function( $, api ) {
|
|
|
|
// No longer needed as of 1.2.95
|
|
|
|
// Keeping it here just in case
|
2021-07-25 23:25:02 +00:00
|
|
|
api.controlConstructor.spacing = api.Control.extend( {
|
|
|
|
ready() {
|
2020-04-07 13:03:04 +00:00
|
|
|
var control = this;
|
|
|
|
$( '.generate-number-control', control.container ).on( 'change keyup',
|
|
|
|
function() {
|
|
|
|
control.setting.set( $( this ).val() );
|
|
|
|
}
|
|
|
|
);
|
2021-07-25 23:25:02 +00:00
|
|
|
},
|
2020-04-07 13:03:04 +00:00
|
|
|
} );
|
|
|
|
|
2021-07-25 23:25:02 +00:00
|
|
|
api.controlConstructor[ 'gp-spacing-slider' ] = api.Control.extend( {
|
|
|
|
ready() {
|
2020-04-07 13:03:04 +00:00
|
|
|
var control = this;
|
|
|
|
$( '.slider-input', control.container ).on( 'change keyup',
|
|
|
|
function() {
|
|
|
|
control.setting.set( $( this ).val() );
|
|
|
|
}
|
|
|
|
);
|
2021-07-25 23:25:02 +00:00
|
|
|
},
|
2020-04-07 13:03:04 +00:00
|
|
|
} );
|
|
|
|
|
2021-07-25 23:25:02 +00:00
|
|
|
api.controlConstructor[ 'generatepress-spacing' ] = api.Control.extend( {
|
|
|
|
ready() {
|
2020-04-07 13:03:04 +00:00
|
|
|
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();
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
// 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 );
|
2021-07-25 23:25:02 +00:00
|
|
|
|
|
|
|
if ( device === _this.attr( 'data-option' ) ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
_this.addClass( 'selected' );
|
|
|
|
_this.siblings().removeClass( 'selected' );
|
|
|
|
}
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
jQuery( controlClass + ' .spacing-values-container .spacing-values-area' ).each( function() {
|
|
|
|
var _this = jQuery( this );
|
2021-07-25 23:25:02 +00:00
|
|
|
|
|
|
|
if ( device === _this.attr( 'data-option' ) ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
_this.show();
|
|
|
|
_this.siblings().hide();
|
|
|
|
}
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
// 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 );
|
2021-07-25 23:25:02 +00:00
|
|
|
|
|
|
|
if ( device === _this.attr( 'data-option' ) ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
_this.addClass( 'selected' );
|
|
|
|
_this.siblings().removeClass( 'selected' );
|
|
|
|
}
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
jQuery( controlClass + ' .spacing-values-container .spacing-values-area' ).each( function() {
|
|
|
|
var _this = jQuery( this );
|
2021-07-25 23:25:02 +00:00
|
|
|
|
|
|
|
if ( device === _this.attr( 'data-option' ) ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
_this.show();
|
|
|
|
_this.siblings().hide();
|
|
|
|
}
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
|
|
|
} );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.spacing-top',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.desktop_top.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.spacing-right',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.desktop_right.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.spacing-bottom',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.desktop_bottom.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.spacing-left',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.desktop_left.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.tablet-spacing-top',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.tablet_top.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.tablet-spacing-right',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.tablet_right.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.tablet-spacing-bottom',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.tablet_bottom.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.tablet-spacing-left',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.tablet_left.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.mobile-spacing-top',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.mobile_top.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.mobile-spacing-right',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.mobile_right.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.mobile-spacing-bottom',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.mobile_bottom.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
control.container.on( 'change keyup', '.mobile-spacing-left',
|
|
|
|
function() {
|
2021-07-25 23:25:02 +00:00
|
|
|
control.settings.mobile_left.set( jQuery( this ).val() );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
);
|
2021-07-25 23:25:02 +00:00
|
|
|
},
|
2020-04-07 13:03:04 +00:00
|
|
|
} );
|
2021-07-25 23:25:02 +00:00
|
|
|
}( jQuery, wp.customize ) );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
2021-07-25 23:25:02 +00:00
|
|
|
jQuery( function( $ ) {
|
|
|
|
$( '.gp-link-spacing' ).on( 'click', function( e ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// Set up variables
|
|
|
|
var _this = $( this ),
|
2021-07-25 23:25:02 +00:00
|
|
|
element = _this.data( 'element' );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
// Add our linked-values class to the next 4 elements
|
2021-07-25 23:25:02 +00:00
|
|
|
_this.parent( '.gp-spacing-section' ).prevAll().slice( 0, 4 ).find( 'input' ).addClass( 'linked-values' ).attr( 'data-element', element );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
// Change our link icon class
|
|
|
|
_this.hide();
|
|
|
|
_this.next( 'span' ).show();
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
2021-07-25 23:25:02 +00:00
|
|
|
$( '.gp-unlink-spacing' ).on( 'click', function( e ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// Set up variables
|
|
|
|
var _this = $( this );
|
|
|
|
|
|
|
|
// Remove our linked-values class to the next 4 elements
|
2021-07-25 23:25:02 +00:00
|
|
|
_this.parent( '.gp-spacing-section' ).prevAll().slice( 0, 4 ).find( 'input' ).removeClass( 'linked-values' ).attr( 'data-element', '' );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
// Change our link icon class
|
|
|
|
_this.hide();
|
|
|
|
_this.prev( 'span' ).show();
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
$( '.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 + '" ]' );
|
|
|
|
|
2021-07-25 23:25:02 +00:00
|
|
|
targetElements.each( function() {
|
2020-04-07 13:03:04 +00:00
|
|
|
var element = $( this );
|
|
|
|
element.val( val ).change();
|
2021-07-25 23:25:02 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|