Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/mpp 509/add spinner during payment modal remove unmout in close modal #196

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions alma/views/css/alma.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,22 @@ p.payment_module a.disable-arrow-icon {
font-weight: normal;
}

.alma-loader--wrapper {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, .25);
z-index: 9999;
}

.loadingIndicator {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
29 changes: 13 additions & 16 deletions alma/views/js/alma-inpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ window.onload = function () {
let url = form.attr("action");
form.on('submit', function (e) {
e.preventDefault();
ajaxPayment(url, inPage, paymentOptionId);
ajaxPayment(url, inPage);
});
};

const ajaxPayment = function (url, inPage, paymentOptionId) {
const addLoader = function () {
let loading = "<div class='loadingIndicator'><img src='https://cdn.almapay.com/img/animated-logo-a.svg' alt='Loading' /></div>";
$( "body" ).append( "<div class='alma-loader--wrapper'>" + loading + "</div>" );
};

const ajaxPayment = function (url, inPage) {
if (isAlmaPayment(url)) {
addLoader();
$.ajax({
type: "POST",
url: url,
Expand All @@ -59,10 +65,9 @@ window.onload = function () {
onUserCloseModal: () => {
let selectorCheckboxPs17 = $('.ps-shown-by-js[type=checkbox]');
if (selectorCheckboxPs17.length > 0) {
$('#' + paymentOptionId).prop('checked', false);
selectorCheckboxPs17.prop('checked', false);
}
inPage.unmount();
$('.alma-loader--wrapper').remove();
}
}
);
Expand Down Expand Up @@ -90,7 +95,9 @@ window.onload = function () {
let purchaseAmount = selectorSetting.data('purchaseamount');
let locale = selectorSetting.data('locale');

const selectorIframeInPage = createsSelectorIframeInPage(selectorSetting, paymentOptionId);
selectorSetting.attr('id', 'alma-inpage-' + paymentOptionId);

let selectorIframeInPage = '#alma-inpage-' + paymentOptionId;

if (showPayButton) {
// No refactor inPage is use in callback function 1.6
Expand All @@ -103,7 +110,7 @@ window.onload = function () {
environment: selectorSetting.data("apimode"),
selector: selectorIframeInPage,
onIntegratedPayButtonClicked : () => {
ajaxPayment(url, inPage, paymentOptionId);
ajaxPayment(url, inPage);
}
}
);
Expand Down Expand Up @@ -168,16 +175,6 @@ window.onload = function () {
});
}

const createsSelectorIframeInPage = function (selectorSetting, paymentOptionId) {
let loading = "<div class='loadingIndicator'><img src='https://cdn.almapay.com/img/animated-logo-a.svg' alt='Loading' /></div>";

selectorSetting.attr('id', 'alma-inpage-' + paymentOptionId);
let selectorIframeInPage = '#alma-inpage-' + paymentOptionId;
$(selectorIframeInPage).html(loading);

return selectorIframeInPage;
}

almaInPageOnload();
};