Initial commit.
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
.woopayments-plugin-warning-modal .button {
|
||||
height: 36px;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
padding: 6px 12px;
|
||||
border-radius: 2px;
|
||||
line-height: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
.woopayments-plugin-warning-modal .button-secondary {
|
||||
background: transparent;
|
||||
}
|
||||
.woopayments-plugin-warning-modal .button.busy {
|
||||
animation: wcpay-plugin-notice-submit-button-busy 3000ms infinite linear;
|
||||
background-image: linear-gradient(
|
||||
-45deg,
|
||||
transparent 33%,
|
||||
#0000004d 33%,
|
||||
#0000004d 70%,
|
||||
transparent 70%
|
||||
);
|
||||
background-size: 100px 100%;
|
||||
}
|
||||
.woopayments-plugin-warning-modal footer .inner > *:not( :first-child ) {
|
||||
margin-left: 16px;
|
||||
}
|
||||
.woopayments-plugin-warning-modal h1 {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
}
|
||||
.woopayments-plugin-warning-modal header,
|
||||
.woopayments-plugin-warning-modal footer {
|
||||
background: initial;
|
||||
box-shadow: initial;
|
||||
}
|
||||
.woopayments-plugin-warning-modal header {
|
||||
margin: 0 -24px;
|
||||
padding-top: 24px;
|
||||
padding-left: 24px;
|
||||
height: 60px;
|
||||
border-bottom: 1px solid #dcdcde;
|
||||
}
|
||||
.woopayments-plugin-warning-modal footer {
|
||||
padding: 24px;
|
||||
border-top: 1px solid #dcdcde;
|
||||
}
|
||||
.woopayments-plugin-warning-modal .wc-backbone-modal-content {
|
||||
border-radius: 2px;
|
||||
padding: 0 24px 24px;
|
||||
}
|
||||
.woopayments-plugin-warning-modal .modal-close-link {
|
||||
height: 100%;
|
||||
width: 60px;
|
||||
border-left: none;
|
||||
}
|
||||
.woopayments-plugin-warning-modal .modal-close-link:hover {
|
||||
background: transparent;
|
||||
}
|
||||
.woopayments-plugin-warning-modal article {
|
||||
padding: 1.5em 0;
|
||||
}
|
||||
.woopayments-plugin-warning-modal .wc-backbone-modal-main {
|
||||
padding-bottom: 60px;
|
||||
}
|
||||
.woopayments-plugin-warning-modal .modal-close-link:hover::before {
|
||||
color: initial;
|
||||
}
|
||||
.woopayments-plugin-warning-modal ul {
|
||||
padding-left: 24px;
|
||||
list-style: disc;
|
||||
}
|
||||
.woopayments-plugin-warning-modal ul > li > ul {
|
||||
margin-top: 6px;
|
||||
list-style: circle;
|
||||
}
|
||||
|
||||
@keyframes wcpay-plugin-notice-submit-button-busy {
|
||||
0% {
|
||||
background-position: 200px 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
jQuery( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
var wc_payments_plugin = {
|
||||
init: function () {
|
||||
this.init_deactivate_wc_subscriptions_warning();
|
||||
this.init_deactivate_wcpay_warning();
|
||||
},
|
||||
|
||||
// Initialise handlers for WC Pay deactivate warning.
|
||||
init_deactivate_wcpay_warning() {
|
||||
// Intercept click on WCPay deactivate link to show modal.
|
||||
$( '#deactivate-woocommerce-payments' ).on(
|
||||
'click',
|
||||
this.display_wcpay_warning
|
||||
);
|
||||
// Resume deactivate when user confirms modal.
|
||||
$( document ).on(
|
||||
'click',
|
||||
'#wcpay-plugin-deactivate-modal-submit',
|
||||
this.redirect_deactivate_wcpay
|
||||
);
|
||||
},
|
||||
// Show a modal to warn merchant that disabling WCPay plugin may leave Stripe subscriptions active (and renewing).
|
||||
display_wcpay_warning: function ( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
$( this ).WCBackboneModal( {
|
||||
template: 'wcpay-plugin-deactivate-warning',
|
||||
} );
|
||||
|
||||
return false;
|
||||
},
|
||||
// Trigger deactivate flow for WCPay.
|
||||
redirect_deactivate_wcpay: function ( event ) {
|
||||
$( '#wcpay-plugin-deactivate-modal-submit' ).addClass( 'busy' );
|
||||
|
||||
window.location = $( '#deactivate-woocommerce-payments' ).attr(
|
||||
'href'
|
||||
);
|
||||
},
|
||||
|
||||
// Initialise handlers for Woo Subscriptions deactivate warning.
|
||||
init_deactivate_wc_subscriptions_warning() {
|
||||
// Intercept click on Woo Subscriptions deactivate link to show modal.
|
||||
$( '#deactivate-' + this.get_woo_subscriptions_plugin_slug() ).on(
|
||||
'click',
|
||||
this.display_wcs_warning
|
||||
);
|
||||
// Resume deactivate when user confirms modal.
|
||||
$( document ).on(
|
||||
'click',
|
||||
'#wcpay-subscriptions-plugin-deactivation-submit',
|
||||
this.redirect_deactivate_wc_subscriptions
|
||||
);
|
||||
},
|
||||
// Show a modal to warn merchant that disabling WC Subscriptions plugin will switch to WCPay.
|
||||
display_wcs_warning: function ( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
$( this ).WCBackboneModal( {
|
||||
template: 'wcpay-subscriptions-plugin-warning',
|
||||
} );
|
||||
|
||||
return false;
|
||||
},
|
||||
// Trigger deactivate flow for WC Subscriptions.
|
||||
redirect_deactivate_wc_subscriptions: function ( event ) {
|
||||
$( '#wcpay-subscriptions-plugin-deactivation-submit' ).addClass(
|
||||
'busy'
|
||||
);
|
||||
|
||||
window.location = $(
|
||||
'#deactivate-' +
|
||||
wc_payments_plugin.get_woo_subscriptions_plugin_slug()
|
||||
).attr( 'href' );
|
||||
},
|
||||
// Gets the Woo Subscriptions plugin slug. When the site is connected to WooCommerce.com, the slug is different and includes a woocommerce-com- prefix.
|
||||
get_woo_subscriptions_plugin_slug() {
|
||||
const element = document.querySelector(
|
||||
'[data-slug="woocommerce-com-woocommerce-subscriptions"]'
|
||||
);
|
||||
|
||||
if ( element ) {
|
||||
return 'woocommerce-com-woocommerce-subscriptions';
|
||||
} else {
|
||||
return 'woocommerce-subscriptions';
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
wc_payments_plugin.init();
|
||||
} );
|
||||
Reference in New Issue
Block a user