remove abortsignal, change to dialog.open/close

This commit is contained in:
Richard Schreiber
2025-05-14 13:09:26 +02:00
parent 0bc09a3583
commit 0eee35be86
2 changed files with 27 additions and 35 deletions

View File

@@ -225,8 +225,7 @@ $(function () {
async_task_old_url = location.href; async_task_old_url = location.href;
$("body").data('ajaxing', true); $("body").data('ajaxing', true);
const ac = new AbortController(); window.pretix.dialog.open({
window.pretix.dialog({
label: this.getAttribute("data-asynctask-headline") || gettext("We are processing your request …"), label: this.getAttribute("data-asynctask-headline") || gettext("We are processing your request …"),
message: (this.getAttribute("data-asynctask-text") || "") + gettext( message: (this.getAttribute("data-asynctask-text") || "") + gettext(
'We are currently sending your request to the server. If this takes longer ' + 'We are currently sending your request to the server. If this takes longer ' +
@@ -234,10 +233,10 @@ $(function () {
'this page and try again.' 'this page and try again.'
), ),
icon: 'cog', icon: 'cog',
}, ac.signal); });
window.setTimeout(function() { window.setTimeout(function() {
ac.abort(); window.pretix.dialog.close();
}, 2000); }, 2000);
return false; return false;

View File

@@ -382,14 +382,15 @@ function get_label_text_for_id(id) {
window.pretix = window.pretix || {}; window.pretix = window.pretix || {};
window.pretix.dialog = function(opt, signal) { window.pretix.dialog = {
// always close any open dialogs close: function() {
$("dialog[open]").each(function() { $("#dialog-alert[open], #dialog-info[open]").each(function() {
this.close(); this.close();
}); });
if (!opt) { },
return; open: function(opt) {
} window.pretix.dialog.close();
const id = "dialog-" + (opt.confirm ? "alert" : "info"); const id = "dialog-" + (opt.confirm ? "alert" : "info");
const dialog = document.getElementById(id); const dialog = document.getElementById(id);
$("#" + id + "-label").text(opt.label); $("#" + id + "-label").text(opt.label);
@@ -400,21 +401,13 @@ window.pretix.dialog = function(opt, signal) {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (signal) {
function onAbort() {
dialog.close();
}
signal.addEventListener('abort', onAbort, { once: true });
}
dialog.addEventListener('close', function() { dialog.addEventListener('close', function() {
if (signal) {
signal.removeEventListener('abort', onAbort);
}
resolve(dialog.returnValue); resolve(dialog.returnValue);
}, { once: true }); }, { once: true });
dialog.showModal(); dialog.showModal();
}) })
}
}; };
@@ -436,7 +429,7 @@ $(function () {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
window.pretix.dialog({ window.pretix.dialog.open({
label: gettext("You have not selected any ticket."), label: gettext("You have not selected any ticket."),
message: gettext("Please tick a checkbox or enter a quantity for one of the ticket types to add to the cart."), message: gettext("Please tick a checkbox or enter a quantity for one of the ticket types to add to the cart."),
icon: 'exclamation', icon: 'exclamation',