🚧 Remove more legacy code

This commit is contained in:
Philipp Stracker 2024-10-09 14:31:36 +02:00
parent 8aa4d47b68
commit ca93e8e56d
No known key found for this signature in database

View file

@ -2,8 +2,6 @@
/* global PayPalCommerceGateway */ /* global PayPalCommerceGateway */
import { createAppleErrors } from './Helper/applePayError'; import { createAppleErrors } from './Helper/applePayError';
import { setVisible } from '../../../ppcp-button/resources/js/modules/Helper/Hiding';
import { setEnabled } from '../../../ppcp-button/resources/js/modules/Helper/ButtonDisabler';
import FormValidator from '../../../ppcp-button/resources/js/modules/Helper/FormValidator'; import FormValidator from '../../../ppcp-button/resources/js/modules/Helper/FormValidator';
import ErrorHandler from '../../../ppcp-button/resources/js/modules/ErrorHandler'; import ErrorHandler from '../../../ppcp-button/resources/js/modules/ErrorHandler';
import widgetBuilder from '../../../ppcp-button/resources/js/modules/Renderer/WidgetBuilder'; import widgetBuilder from '../../../ppcp-button/resources/js/modules/Renderer/WidgetBuilder';
@ -234,7 +232,6 @@ class ApplePayButton extends PaymentButton {
} }
super.init(); super.init();
this.initEventHandlers();
if ( this.isSeparateGateway ) { if ( this.isSeparateGateway ) {
document document
@ -283,41 +280,6 @@ class ApplePayButton extends PaymentButton {
this.transactionInfo = await this.contextHandler.transactionInfo(); this.transactionInfo = await this.contextHandler.transactionInfo();
} }
initEventHandlers() {
const ppcpButtonWrapper = `#${ this.ppcpButtonWrapperId }`;
const wrapperId = `#${ this.wrapperId }`;
if ( wrapperId === ppcpButtonWrapper ) {
throw new Error(
`[ApplePayButton] "wrapper" and "ppcpButtonWrapper" values must differ to avoid infinite loop. Current value: "${ wrapperId }"`
);
}
const syncButtonVisibility = () => {
if ( ! this.isEligible ) {
return;
}
const $ppcpButtonWrapper = jQuery( ppcpButtonWrapper );
setVisible( wrapperId, $ppcpButtonWrapper.is( ':visible' ) );
setEnabled(
wrapperId,
! $ppcpButtonWrapper.hasClass( 'ppcp-disabled' )
);
};
jQuery( document ).on(
'ppcp-shown ppcp-hidden ppcp-enabled ppcp-disabled',
( ev, data ) => {
if ( jQuery( data.selector ).is( ppcpButtonWrapper ) ) {
syncButtonVisibility();
}
}
);
syncButtonVisibility();
}
/** /**
* Starts an Apple Pay session, which means that the user interacted with the Apple Pay button. * Starts an Apple Pay session, which means that the user interacted with the Apple Pay button.
* *