Reduce confusion

This commit is contained in:
Umar Bolatov
2022-09-08 21:21:39 -07:00
committed by Andrew Camilleri
parent 1626bd7a18
commit 267905b5e7
7 changed files with 15 additions and 11 deletions

View File

@@ -32,7 +32,7 @@
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200 && this.responseText) {
window.btcpay.showInvoice(JSON.parse(this.responseText).invoiceId);
window.btcpay.appendInvoiceFrame(JSON.parse(this.responseText).invoiceId);
}
};
xhttp.open('POST', event.target.getAttribute('action'), true);

View File

@@ -51,7 +51,7 @@
delegate('click', '.showInvoice', e => {
e.preventDefault();
const { invoiceId } = e.target.dataset;
btcpay.showInvoice(invoiceId);
btcpay.appendInvoiceFrame(invoiceId);
})
$('#btnCustomRangeDate').on('click', function (sender) {

View File

@@ -219,8 +219,7 @@ document.addEventListener("DOMContentLoaded",function (ev) {
this.sound = this.srvModel.soundsEnabled;
this.animation = this.srvModel.animationsEnabled;
eventAggregator.$on("invoice-created", function (invoiceId) {
btcpay.showInvoice(invoiceId);
btcpay.showFrame();
btcpay.appendAndShowInvoiceFrame(invoiceId);
self.contributeModalOpen = false;
self.setLoading(false);

View File

@@ -105,7 +105,7 @@
onModalReceiveMessageMethod(event);
}
function showInvoice(invoiceId, params) {
function appendInvoiceFrame(invoiceId, params) {
showingInvoice = true;
window.document.body.appendChild(iframe);
var invoiceUrl = origin + '/invoice?id=' + invoiceId + '&view=modal';
@@ -115,6 +115,11 @@
iframe.src = invoiceUrl;
}
function appendAndShowInvoiceFrame(invoiceId, params) {
appendInvoiceFrame(invoiceId, params);
showFrame();
}
function setButtonListeners() {
var buttons = window.document.querySelectorAll('[data-btcpay-button]');
for (var i = 0; i < buttons.length; i++) {
@@ -133,7 +138,9 @@
window.btcpay = {
showFrame: showFrame,
hideFrame: hideFrame,
showInvoice: showInvoice,
showInvoice: appendInvoiceFrame,
appendInvoiceFrame: appendInvoiceFrame,
appendAndShowInvoiceFrame: appendAndShowInvoiceFrame,
onModalWillEnter: onModalWillEnter,
onModalWillLeave: onModalWillLeave,
setApiUrlPrefix: setApiUrlPrefix,

View File

@@ -128,8 +128,7 @@ document.addEventListener("DOMContentLoaded",function (ev) {
eventAggregator.$on("invoice-created", function (invoiceId) {
self.setLoading(false);
btcpay.showInvoice(invoiceId);
btcpay.showFrame();
btcpay.appendAndShowInvoiceFrame(invoiceId);
});
eventAggregator.$on("invoice-cancelled", function (){
self.setLoading(false);

View File

@@ -132,8 +132,7 @@ window.BTCPayShopifyIntegrationModule = function () {
handleInvoiceData(d, {backgroundCheck: true})
});
});
window.btcpay.showInvoice(currentInvoiceData.invoiceId);
window.btcpay.showFrame();
btcpay.appendAndShowInvoiceFrame(currentInvoiceData.invoiceId);
}
}

View File

@@ -8,7 +8,7 @@
window.onload = function(){
const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('invoice');
btcpay.showInvoice(myParam);
btcpay.appendInvoiceFrame(myParam);
}
</script>
</head>