Replace native confirms with Ladill custom dialogs.
Deploy Ladill Mini / deploy (push) Successful in 36s

This commit is contained in:
isaacclad
2026-07-24 20:56:30 +00:00
parent faa0205ad6
commit 44ba69f63f
5 changed files with 213 additions and 51 deletions
+12 -1
View File
@@ -33,6 +33,10 @@ export function ladillNeedsTopup(balance, price) {
return normalizedBalance <= 0 || normalizedBalance < normalizedPrice;
}
/**
* Alpine store mirrors window.ladillConfirm (defined in partials/confirm-prompt).
* Prefer window.ladillConfirm for new code — it works without Alpine and powers data-confirm forms.
*/
export function registerLadillConfirmStore(Alpine) {
Alpine.store('ladillConfirm', {
open: false,
@@ -44,6 +48,11 @@ export function registerLadillConfirmStore(Alpine) {
_resolve: null,
ask(options = {}) {
// Delegate to the global custom dialog when available (no double UI).
if (typeof window.ladillConfirm === 'function' && window.__ladillConfirmInstalled) {
return window.ladillConfirm(options);
}
return new Promise((resolve) => {
this.title = options.title || 'Are you sure?';
this.message = options.message || '';
@@ -65,7 +74,9 @@ export function registerLadillConfirmStore(Alpine) {
},
});
window.ladillConfirm = (options = {}) => Alpine.store('ladillConfirm').ask(options);
if (typeof window.ladillConfirm !== 'function') {
window.ladillConfirm = (options = {}) => Alpine.store('ladillConfirm').ask(options);
}
}
export function registerLadillModalHelpers() {