1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 23:22:52 +01:00
invoiceninja/resources/js/clients/wait.js
Benjamin Beganović 0de492d96f
Stripe: New payment flow (#67)
* stripe: ach

* stripe: klarna

* stripe: bank transfer

* assets build

* stripe: bacs

* stripe: bancontact

* stripe: becs

* stripe: eps

* stripe: fpx

* stripe: giropay

* stripe: ideal

* stripe: przelewy24

* stripe: sepa

* stripe: sofort

* assets build

* assets build

* pass context payload into livewirePaymentView

* update checkout.com

* update livewire method interface

* stripe: acss

* align methods with interface (array $data)
2024-07-16 18:43:55 +10:00

58 lines
1.4 KiB
JavaScript
Vendored

/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
/**
* @param {...string} selectors
*/
export function wait(...selectors) {
return new Promise((resolve) => {
if (!selectors.length) {
resolve([]);
return;
}
const elements = selectors
.map((selector) => document.querySelector(selector))
.filter(Boolean);
if (elements.length === selectors.length) {
resolve(elements);
return;
}
const observer = new MutationObserver(() => {
const foundElements = selectors
.map((selector) => document.querySelector(selector))
.filter(Boolean);
if (foundElements.length === selectors.length) {
observer.disconnect();
resolve(foundElements);
}
});
observer.observe(document.body, { childList: true, subtree: true });
});
}
export function instant() {
const instant = document.querySelector('meta[name="instant-payment"]');
if (
instant &&
instant instanceof HTMLMetaElement &&
instant.content === 'yes'
) {
return true;
}
return false;
}