posts/show: load flag/appeal/replacement dialogs via ajax (#3922).

This commit is contained in:
evazion
2018-09-26 17:17:46 -05:00
parent d1e9f9c3ce
commit f886f2fdb3
18 changed files with 74 additions and 148 deletions

View File

@@ -36,6 +36,31 @@ Utility.error = function(msg) {
}
}
Utility.dialog = function(title, html) {
const $dialog = $(html).dialog({
title: title,
width: 700,
modal: true,
close: function() {
// Defer removing the dialog to avoid detaching the <form> tag before the
// form is submitted (which would prevent the submission from going through).
$(() => $dialog.dialog("destroy"));
},
buttons: {
"Submit": function() {
$dialog.find("form").submit();
},
"Cancel": function() {
$dialog.dialog("close");
}
}
});
$dialog.find("form").on("submit.danbooru", function() {
$dialog.dialog("close");
});
}
Utility.keydown = function(keys, namespace, handler) {
if (Utility.meta("enable-js-navigation") === "true") {
$(document).on("keydown.danbooru." + namespace, null, keys, handler);