Add Enter key functionality to save plugin settings and fix condition for minimum settings check

This commit is contained in:
Théophile Diot 2024-11-07 10:52:44 +01:00
parent 325bd51dc9
commit 33d07aef64
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -1120,6 +1120,13 @@ $(document).ready(() => {
}, 30);
});
$(".plugin-setting").on("keydown", function (e) {
if (e.key === "Enter") {
e.preventDefault();
$(".save-settings").trigger("click");
}
});
$(window).on("beforeunload", function (e) {
if (isReadOnly) return;
@ -1134,7 +1141,7 @@ $(document).ready(() => {
if (currentMode === "raw")
isDraft = form.find("input[name='IS_DRAFT']").val() === "yes";
if (form.children().length < minSettings && isDraft === wasDraft) return;
if (form.children().length <= minSettings && isDraft === wasDraft) return;
}
// Cross-browser compatibility (for older browsers)