Skip to content

Commit f6d6b9b

Browse files
committed
separate highlight logic from submit logic
1 parent ff174fe commit f6d6b9b

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

webroot/panel/account.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function getNewLoginShell() {
272272
}
273273
return $("#customLoginBox").val();
274274
}
275+
275276
function isLoginShellValid(x) {
276277
if (x.trim().length === 0) {
277278
return false;
@@ -282,21 +283,32 @@ function isLoginShellValid(x) {
282283
}
283284
return true;
284285
}
286+
287+
function enableOrDisableCustomLoginBoxHighlight() {
288+
if (
289+
($("#loginSelector").val() == "Custom") &&
290+
!isLoginShellValid($("#customLoginBox").val())
291+
) {
292+
$("#customLoginBox").css("box-shadow", "0 0 0 0.3rem rgba(220, 53, 69, 0.25)");
293+
} else {
294+
$("#customLoginBox").css("box-shadow", "none");
295+
}
296+
}
297+
$("#customLoginBox").on("input", enableOrDisableCustomLoginBoxHighlight);
298+
$("#loginSelector").change(enableOrDisableCustomLoginBoxHighlight);
299+
enableOrDisableCustomLoginBoxHighlight();
300+
285301
function enableOrDisableSubmitLoginShell() {
286-
var submitLoginShell = $("#submitLoginShell");
287302
var newLoginShell = getNewLoginShell();
288303
if (!isLoginShellValid(newLoginShell)) {
289-
submitLoginShell.attr("disabled", true);
290-
$("#customLoginBox").css("box-shadow", "0 0 0 0.3rem rgba(220, 53, 69, 0.25)");
304+
$("#submitLoginShell").attr("disabled", true);
291305
return;
292-
} else {
293-
$("#customLoginBox").css("box-shadow", "none");
294306
}
295307
if (newLoginShell == ldapLoginShell) {
296-
submitLoginShell.attr("disabled", true);
308+
$("#submitLoginShell").attr("disabled", true);
297309
return;
298310
}
299-
submitLoginShell.attr("disabled", false);
311+
$("#submitLoginShell").attr("disabled", false);
300312
}
301313
$("#customLoginBox").on("input", enableOrDisableSubmitLoginShell);
302314
$("#loginSelector").change(enableOrDisableSubmitLoginShell);

0 commit comments

Comments
 (0)