mirror of
https://github.com/vrana/adminer.git
synced 2025-08-20 13:21:30 +02:00
Move beforeunload to plugin
This commit is contained in:
@@ -81,7 +81,6 @@ if ($in) {
|
||||
echo "\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo script("setupEditChange(qsl('form'));");
|
||||
}
|
||||
?>
|
||||
<p>
|
||||
|
@@ -513,7 +513,6 @@ function edit_form($table, $fields, $row, $update) {
|
||||
;
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo script("setupEditChange(qsl('form'));");
|
||||
}
|
||||
echo "<p>\n";
|
||||
if ($fields) {
|
||||
|
@@ -567,27 +567,6 @@ function fieldChange() {
|
||||
|
||||
|
||||
|
||||
let editChanged;
|
||||
|
||||
/** Setup saving editChanged on form fields
|
||||
* @this HTMLFormElement
|
||||
*/
|
||||
function setupEditChange(form) {
|
||||
for (const el of qsa('input, select, textarea', form)) {
|
||||
addEvent(el, 'change', () => {
|
||||
editChanged = true;
|
||||
});
|
||||
}
|
||||
form.onsubmit = () => {
|
||||
editChanged = null; // false doesn't work in Chrome
|
||||
}
|
||||
}
|
||||
|
||||
// all modern browsers ignore string returned from here
|
||||
onbeforeunload = () => editChanged;
|
||||
|
||||
|
||||
|
||||
/** Create AJAX request
|
||||
* @param string
|
||||
* @param function (XMLHttpRequest)
|
||||
@@ -637,6 +616,8 @@ function ajaxSetHtml(url) {
|
||||
});
|
||||
}
|
||||
|
||||
let editChanged; // used by plugins
|
||||
|
||||
/** Save form contents through AJAX
|
||||
* @param HTMLFormElement
|
||||
* @param string
|
||||
|
Reference in New Issue
Block a user