mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-10 11:32:54 +00:00
2.6.1
This commit is contained in:

committed by
Remco Tolsma

parent
42964bef17
commit
a60db3815d
@@ -1,10 +1,15 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
// Auto Renewal Toggle
|
||||
var $toggleContainer = $( '.wcs-auto-renew-toggle' );
|
||||
var $toggle = $( '.subscription-auto-renew-toggle', $toggleContainer );
|
||||
var $icon = $toggle.find( 'i' );
|
||||
var txtColor = null;
|
||||
var $paymentMethod = $( '.subscription-payment-method' );
|
||||
|
||||
// Early Renewal
|
||||
var $early_renewal_modal_submit = $( '#early_renewal_modal_submit' );
|
||||
var $early_renewal_modal_content = $( '.wcs-modal > .content-wrapper' );
|
||||
|
||||
function getTxtColor() {
|
||||
if ( !txtColor && ( $icon && $icon.length ) ) {
|
||||
txtColor = getComputedStyle( $icon[0] ).color;
|
||||
@@ -33,6 +38,11 @@ jQuery( document ).ready( function( $ ) {
|
||||
// Remove focus from the toggle element.
|
||||
$toggle.blur();
|
||||
|
||||
// Ignore the request if the toggle is disabled.
|
||||
if ( $toggle.hasClass( 'subscription-auto-renew-toggle--disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var ajaxHandler = function( action ) {
|
||||
var data = {
|
||||
subscription_id: WCSViewSubscription.subscription_id,
|
||||
@@ -53,6 +63,9 @@ jQuery( document ).ready( function( $ ) {
|
||||
$paymentMethod.html( result.payment_method ).fadeIn();
|
||||
});
|
||||
}
|
||||
if ( undefined !== result.is_manual ) {
|
||||
$paymentMethod.data( 'is_manual', result.is_manual );
|
||||
}
|
||||
},
|
||||
error: function( jqxhr, status, exception ) {
|
||||
alert( 'Exception:', exception );
|
||||
@@ -100,8 +113,26 @@ jQuery( document ).ready( function( $ ) {
|
||||
$toggleContainer.unblock();
|
||||
}
|
||||
|
||||
function blockEarlyRenewalModal() {
|
||||
$early_renewal_modal_content.block({
|
||||
message: null,
|
||||
overlayCSS: {
|
||||
background: '#fff',
|
||||
opacity: 0.6
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Don't display the modal for manual subscriptions, they will need to renew via the checkout.
|
||||
function shouldShowEarlyRenewalModal() {
|
||||
return $paymentMethod.data( 'is_manual' ) === 'no';
|
||||
};
|
||||
|
||||
$toggle.on( 'click', onToggle );
|
||||
maybeApplyColor();
|
||||
displayToggle();
|
||||
|
||||
$early_renewal_modal_submit.on( 'click', blockEarlyRenewalModal );
|
||||
$( document ).on( 'wcs_show_modal', shouldShowEarlyRenewalModal );
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user