mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Refactor AXO module
This commit is contained in:
parent
a9d2f97a80
commit
578a5426dc
7 changed files with 337 additions and 121 deletions
|
@ -23,8 +23,15 @@ class DomElementCollection {
|
|||
className: 'ppcp-axo-watermark-container'
|
||||
});
|
||||
|
||||
this.allFields = new DomElement({
|
||||
selector: '#customer_details .form-row, #customer_details .woocommerce-shipping-fields'
|
||||
this.customerDetails = new DomElement({
|
||||
selector: '#customer_details > *:not(#ppcp-axo-customer-details)'
|
||||
});
|
||||
|
||||
this.axoCustomerDetails = new DomElement({
|
||||
id: 'ppcp-axo-customer-details',
|
||||
selector: '#ppcp-axo-customer-details',
|
||||
className: 'ppcp-axo-customer-details',
|
||||
anchorSelector: '#customer_details'
|
||||
});
|
||||
|
||||
this.emailWidgetContainer = new DomElement({
|
||||
|
@ -36,15 +43,13 @@ class DomElementCollection {
|
|||
this.shippingAddressContainer = new DomElement({
|
||||
id: 'ppcp-axo-shipping-address-container',
|
||||
selector: '#ppcp-axo-shipping-address-container',
|
||||
className: 'ppcp-axo-shipping-address-container',
|
||||
anchorSelector: '.woocommerce-shipping-fields'
|
||||
className: 'ppcp-axo-shipping-address-container'
|
||||
});
|
||||
|
||||
this.billingAddressContainer = new DomElement({
|
||||
id: 'ppcp-axo-billing-address-container',
|
||||
selector: '#ppcp-axo-billing-address-container',
|
||||
className: 'ppcp-axo-billing-address-container',
|
||||
anchorSelector: '.woocommerce-billing-fields__field-wrapper'
|
||||
className: 'ppcp-axo-billing-address-container'
|
||||
});
|
||||
|
||||
this.fieldBillingEmail = new DomElement({
|
||||
|
|
|
@ -48,36 +48,40 @@ class MockData {
|
|||
|
||||
content.innerHTML = '';
|
||||
|
||||
if (!this.active) {
|
||||
this.hideField(this.contentSelector);
|
||||
} else {
|
||||
this.showField(this.contentSelector);
|
||||
}
|
||||
|
||||
Object.keys(this.fields).forEach((key) => {
|
||||
const field = this.fields[key];
|
||||
|
||||
if (this.active) {
|
||||
this.hideField(field.selector);
|
||||
//this.showField(this.contentSelector);
|
||||
} else {
|
||||
this.showField(field.selector);
|
||||
//this.hideField(this.contentSelector);
|
||||
}
|
||||
|
||||
if (typeof this.template === 'function') {
|
||||
content.innerHTML = this.template({
|
||||
value: (valueKey) => {
|
||||
return this.getDataValue(this.fields[valueKey].valuePath);
|
||||
},
|
||||
isEmpty: () => {
|
||||
let isEmpty = true;
|
||||
Object.values(this.fields).forEach((valueField) => {
|
||||
if (this.getDataValue(valueField.valuePath)) {
|
||||
isEmpty = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return isEmpty;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (typeof this.template === 'function') {
|
||||
content.innerHTML = this.template({
|
||||
value: (valueKey) => {
|
||||
return this.getDataValue(this.fields[valueKey].valuePath);
|
||||
},
|
||||
isEmpty: () => {
|
||||
let isEmpty = true;
|
||||
Object.values(this.fields).forEach((valueField) => {
|
||||
if (this.getDataValue(valueField.valuePath)) {
|
||||
isEmpty = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return isEmpty;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
showField(selector) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue