Skip to content

Commit

Permalink
Merge branch 'develop' into feature/namespace-wp-background-process
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaHungDinh authored Aug 9, 2023
2 parents 56249e2 + 2348102 commit dc20ab6
Show file tree
Hide file tree
Showing 44 changed files with 38,602 additions and 21,395 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ phpcs.xml
# POT File
languages/*
!languages/README.md

# @wordpress/scripts build directory
build
**/build.*
**/build.asset.*
131 changes: 73 additions & 58 deletions assets/src/js/frontend/give-stripe-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,67 +308,82 @@ class GiveStripeElements {
* @param setupStripeElement
* @param cardElements
*
* @unreleased Scrolls Stripe checkout modal into view for all screen sizes.
*
* @since 2.8.0
*/
triggerStripeModal( formElement, stripeElements, setupStripeElement, cardElements ) {
const idPrefixElement = formElement.querySelector( 'input[name="give-form-id-prefix"]' );
const stripeModalDonateBtn = formElement.querySelector( `#give-stripe-checkout-modal-donate-button-${ idPrefixElement.value }` );
const cardholderName = formElement.querySelector( 'input[name="card_name"]' );
const completeCardElements = {};
let completeCardStatus = false;

cardElements.forEach( ( cardElement ) => {
completeCardElements.cardName = false;

cardElement.addEventListener( 'ready', ( e ) => {
completeCardElements[ e.elementType ] = false;
completeCardElements.cardName = 'card' === e.elementType;
} );

cardElement.addEventListener( 'change', ( e ) => {
completeCardElements[ e.elementType ] = e.complete;
completeCardStatus = Object.values( completeCardElements ).every( ( string ) => {
return true === string;
} );

completeCardStatus ? stripeModalDonateBtn.removeAttribute( 'disabled' ) : stripeModalDonateBtn.setAttribute( 'disabled', 'disabled' );
} );
} );

if ( null !== cardholderName ) {
cardholderName.addEventListener( 'keyup', ( e ) => {
completeCardElements.cardName = '' !== e.target.value;
completeCardStatus = Object.values( completeCardElements ).every( ( string ) => {
return true === string;
} );
completeCardStatus ? stripeModalDonateBtn.removeAttribute( 'disabled' ) : stripeModalDonateBtn.setAttribute( 'disabled', 'disabled' );
} );
}

if ( null !== stripeModalDonateBtn ) {
// Process donation on the click of the modal donate button.
stripeModalDonateBtn.addEventListener( 'click', ( e ) => {
const currentModalDonateBtn = e.target;
const loadingAnimationElement = currentModalDonateBtn.nextElementSibling;
const isLegacyForm = stripeModalDonateBtn.getAttribute( 'data-is_legacy_form' );

if ( isLegacyForm ) {
currentModalDonateBtn.value = give_global_vars.purchase_loading;
loadingAnimationElement.style.display = 'inline-block';
} else {
currentModalDonateBtn.value = '';
loadingAnimationElement.classList.add( 'sequoia-loader' );
loadingAnimationElement.classList.add( 'spinning' );
loadingAnimationElement.classList.remove( 'give-loading-animation' );
}

// Create Payment Method.
stripeElements.createPaymentMethod( formElement, setupStripeElement, cardElements );

e.preventDefault();
} );
}
}
const idPrefixElement = formElement.querySelector('input[name="give-form-id-prefix"]');
const stripeModalDonateBtn = formElement.querySelector(
`#give-stripe-checkout-modal-donate-button-${idPrefixElement.value}`
);
const cardholderName = formElement.querySelector('input[name="card_name"]');
const stripeModalContent = document.querySelector('.give-stripe-checkout-modal-container');
const purchaseButton = document.querySelector('#give-purchase-button');
const completeCardElements = {};
let completeCardStatus = false;

// Scroll checkout modal container into view.
purchaseButton.addEventListener('click', function () {
stripeModalContent.scrollIntoView({behavior: 'smooth'});
});

cardElements.forEach((cardElement) => {
completeCardElements.cardName = false;

cardElement.addEventListener('ready', (e) => {
completeCardElements[e.elementType] = false;
completeCardElements.cardName = 'card' === e.elementType;
});

cardElement.addEventListener('change', (e) => {
completeCardElements[e.elementType] = e.complete;
completeCardStatus = Object.values(completeCardElements).every((string) => {
return true === string;
});

completeCardStatus
? stripeModalDonateBtn.removeAttribute('disabled')
: stripeModalDonateBtn.setAttribute('disabled', 'disabled');
});
});

if (null !== cardholderName) {
cardholderName.addEventListener('keyup', (e) => {
completeCardElements.cardName = '' !== e.target.value;
completeCardStatus = Object.values(completeCardElements).every((string) => {
return true === string;
});
completeCardStatus
? stripeModalDonateBtn.removeAttribute('disabled')
: stripeModalDonateBtn.setAttribute('disabled', 'disabled');
});
}

if (null !== stripeModalDonateBtn) {
// Process donation on the click of the modal donate button.
stripeModalDonateBtn.addEventListener('click', (e) => {
const currentModalDonateBtn = e.target;
const loadingAnimationElement = currentModalDonateBtn.nextElementSibling;
const isLegacyForm = stripeModalDonateBtn.getAttribute('data-is_legacy_form');

if (isLegacyForm) {
currentModalDonateBtn.value = give_global_vars.purchase_loading;
loadingAnimationElement.style.display = 'inline-block';
} else {
currentModalDonateBtn.value = '';
loadingAnimationElement.classList.add('sequoia-loader');
loadingAnimationElement.classList.add('spinning');
loadingAnimationElement.classList.remove('give-loading-animation');
}

// Create Payment Method.
stripeElements.createPaymentMethod(formElement, setupStripeElement, cardElements);

e.preventDefault();
});
}
}
}

export { GiveStripeElements };
2 changes: 1 addition & 1 deletion blocks/donation-form-grid/edit/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const Inspector = ({attributes, setAttributes}) => {
</PanelBody>
</Panel>
<Panel>
<PanelBody title= {__('Grid Settings', 'give')} initialOpen={ true }>
<PanelBody className="give-donation-form-grid--grid-settings" title= {__('Grid Settings', 'give')} initialOpen={ true }>
<SelectControl
className="give-form-grid-inspector"
label={__('Order By', 'give')}
Expand Down
16 changes: 8 additions & 8 deletions blocks/donation-form-grid/edit/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.give-form-grid-inspector{
.give-form-grid-inspector {
flex-direction: row !important;
align-items: center !important;
justify-content: space-between !important;
Expand All @@ -14,8 +14,6 @@
margin: -15px 0 15px 0 !important;
}



.components-base-control__label {
margin: 0 !important;
}
Expand All @@ -36,7 +34,7 @@
align-items: center !important;
justify-content: center !important;

.components-input-control__label{
.components-input-control__label {
flex: 1 !important;
margin: 0 !important;
}
Expand All @@ -45,18 +43,20 @@
.components-input-control__container {
max-width: 135px !important;

> select {
line-height: 1.2 !important;
}
> select {
line-height: 1.2 !important;
}
}
}

.components-form-token-field{
.give-donation-form-grid--grid-settings {
.components-form-token-field {
label { display: none !important;}
}

.exclude__form {
margin-top: 20px !important;
border: 1px solid transparent;
}
}

2 changes: 1 addition & 1 deletion blocks/donor-wall/edit/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const { donorsPerPage,
</PanelBody>
</Panel>
<Panel>
<PanelBody title= {__('Wall Settings', 'give')} initialOpen={ false }>
<PanelBody className="give-wall--wall-settings" title= {__('Wall Settings', 'give')} initialOpen={ false }>
<SelectControl
className="give-donor-wall-inspector"
label={ __( 'Sort By', 'give' ) }
Expand Down
16 changes: 9 additions & 7 deletions blocks/donor-wall/edit/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.give-donor-wall-inspector{
.give-donor-wall-inspector {
flex-direction: row !important;
align-items: center !important;
justify-content: space-between !important;
Expand Down Expand Up @@ -32,13 +32,15 @@
.components-input-control__container {
max-width: 165px !important;

> select {
line-height: 1.2 !important;
}
> select {
line-height: 1.2 !important;
}
}
}

.components-form-token-field {
margin-top: -18px !important;
label { display: none !important;}
.give-wall--wall-settings {
.components-form-token-field {
margin-top: -18px !important;
label { display: none !important;}
}
}
10 changes: 8 additions & 2 deletions includes/class-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public function render_admin_notices() {
/**
* Render give frontend notices.
*
* @unreleased Display registered error on donation form.
* @since 1.8.9
* @access public
*
Expand All @@ -295,8 +296,13 @@ public function render_frontend_notices( $form_id = 0 ) {

$request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0;

// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
// Sanity checks first:
// - Ensure that gateway returned errors display on the appropriate form.
// - Error should not display on AJAX request.
if (
isset( $_POST['give_ajax'] )
|| ( $request_form_id && $request_form_id !== $form_id )
) {
return;
}

Expand Down
Loading

0 comments on commit dc20ab6

Please sign in to comment.