mirror of
https://github.com/pretix/pretix.git
synced 2026-05-17 17:14:04 +00:00
remove abortsignal, change to dialog.open/close
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -382,39 +382,32 @@ 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 dialog = document.getElementById(id);
|
|
||||||
$("#" + id + "-label").text(opt.label);
|
|
||||||
$("#" + id + "-description").text(opt.message);
|
|
||||||
$(".modal-card-icon .fa", dialog).attr('class', 'fa fa-' + (opt.icon || "exclamation-triangle"));
|
|
||||||
if (opt.confirm) {
|
|
||||||
$("button", dialog).attr("value", opt.confirm.toString()).text(opt.confirm === true ? gettext("OK") : opt.confirm);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
const id = "dialog-" + (opt.confirm ? "alert" : "info");
|
||||||
if (signal) {
|
const dialog = document.getElementById(id);
|
||||||
function onAbort() {
|
$("#" + id + "-label").text(opt.label);
|
||||||
dialog.close();
|
$("#" + id + "-description").text(opt.message);
|
||||||
}
|
$(".modal-card-icon .fa", dialog).attr('class', 'fa fa-' + (opt.icon || "exclamation-triangle"));
|
||||||
signal.addEventListener('abort', onAbort, { once: true });
|
if (opt.confirm) {
|
||||||
|
$("button", dialog).attr("value", opt.confirm.toString()).text(opt.confirm === true ? gettext("OK") : opt.confirm);
|
||||||
}
|
}
|
||||||
dialog.addEventListener('close', function() {
|
|
||||||
if (signal) {
|
|
||||||
signal.removeEventListener('abort', onAbort);
|
|
||||||
}
|
|
||||||
resolve(dialog.returnValue);
|
|
||||||
}, { once: true });
|
|
||||||
|
|
||||||
dialog.showModal();
|
return new Promise((resolve, reject) => {
|
||||||
})
|
dialog.addEventListener('close', function() {
|
||||||
|
resolve(dialog.returnValue);
|
||||||
|
}, { once: true });
|
||||||
|
|
||||||
|
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',
|
||||||
|
|||||||
Reference in New Issue
Block a user