mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Create Assets for compat module
This commit is contained in:
parent
783c96b382
commit
9a8c413422
7 changed files with 2387 additions and 2 deletions
39
modules/ppcp-compat/resources/js/gzd-compat.js
Normal file
39
modules/ppcp-compat/resources/js/gzd-compat.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
() => {
|
||||
const orderTrackingContainerId = "ppcp_order-tracking";
|
||||
const orderTrackingContainerSelector = "#ppcp_order-tracking";
|
||||
const gzdSaveButton = document.getElementById('order-shipments-save');
|
||||
const loadLocation = location.href + " " + orderTrackingContainerSelector + ">*";
|
||||
|
||||
const disableTrackingFields = function () {
|
||||
var childNodes = document.getElementById(orderTrackingContainerId).getElementsByTagName('*');
|
||||
for (var node of childNodes) {
|
||||
node.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
const enableTrackingFields = function () {
|
||||
var childNodes = document.getElementById(orderTrackingContainerId).getElementsByTagName('*');
|
||||
for (var node of childNodes) {
|
||||
node.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
const waitForTrackingUpdate = function () {
|
||||
if (jQuery('#order-shipments-save').css('display') !== 'none') {
|
||||
disableTrackingFields();
|
||||
setTimeout(waitForTrackingUpdate, 100)
|
||||
} else {
|
||||
jQuery(orderTrackingContainerSelector).load(loadLocation,"");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(gzdSaveButton) != 'undefined' && gzdSaveButton != null) {
|
||||
gzdSaveButton.addEventListener('click', function (event) {
|
||||
waitForTrackingUpdate();
|
||||
enableTrackingFields();
|
||||
})
|
||||
}
|
||||
},
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue