Minor code improvement
authorAlexander Ebert <ebert@woltlab.com>
Fri, 26 Feb 2021 16:11:33 +0000 (17:11 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 26 Feb 2021 16:11:33 +0000 (17:11 +0100)
ts/WoltLabSuite/Core/Ui/Password.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js
wcfsetup/install/files/style/layout/form.scss

index 611f52673751ea59ef505beee5b8848b452bd1de..5c73e44415d9ba8802bd2c2157d96053316c7ed2 100644 (file)
@@ -1,3 +1,12 @@
+/**
+ * Visibility toggle for password input fields.
+ *
+ * @author Marcel Werk
+ * @copyright  2001-2021 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module     WoltLabSuite/Core/Ui/Password
+ */
+
 import DomChangeListener from "../Dom/Change/Listener";
 import * as Language from "../Language";
 
@@ -48,10 +57,15 @@ function initElement(input: HTMLInputElement): void {
 }
 
 function toggle(input: HTMLInputElement, button: HTMLElement, icon: HTMLElement): void {
-  icon.classList.toggle("fa-eye");
-  icon.classList.toggle("fa-eye-slash");
-  button.dataset.tooltip = Language.get(
-    "wcf.global.form.password.button." + (input.type === "password" ? "hide" : "show"),
-  );
-  input.type = input.type === "password" ? "text" : "password";
+  if (input.type === "password") {
+    icon.classList.add("fa-eye");
+    icon.classList.remove("fa-eye-slash");
+    button.dataset.tooltip = Language.get("wcf.global.form.password.button.hide");
+    input.type = "text";
+  } else {
+    icon.classList.remove("fa-eye");
+    icon.classList.add("fa-eye-slash");
+    button.dataset.tooltip = Language.get("wcf.global.form.password.button.show");
+    input.type = "password";
+  }
 }
index 59b8136761b90f760861971c96cfb7f5f02b5597..816e2fe41987f193afefb2ccfe3abdbe43320df5 100644 (file)
@@ -1,3 +1,11 @@
+/**
+ * Visibility toggle for password input fields.
+ *
+ * @author Marcel Werk
+ * @copyright  2001-2021 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module     WoltLabSuite/Core/Ui/Password
+ */
 define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Language"], function (require, exports, tslib_1, Listener_1, Language) {
     "use strict";
     Object.defineProperty(exports, "__esModule", { value: true });
@@ -44,9 +52,17 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Language"],
         });
     }
     function toggle(input, button, icon) {
-        icon.classList.toggle("fa-eye");
-        icon.classList.toggle("fa-eye-slash");
-        button.dataset.tooltip = Language.get("wcf.global.form.password.button." + (input.type === "password" ? "hide" : "show"));
-        input.type = input.type === "password" ? "text" : "password";
+        if (input.type === "password") {
+            icon.classList.add("fa-eye");
+            icon.classList.remove("fa-eye-slash");
+            button.dataset.tooltip = Language.get("wcf.global.form.password.button.hide");
+            input.type = "text";
+        }
+        else {
+            icon.classList.remove("fa-eye");
+            icon.classList.add("fa-eye-slash");
+            button.dataset.tooltip = Language.get("wcf.global.form.password.button.show");
+            input.type = "password";
+        }
     }
 });
index 608253b608ba8c7da0a1ccf61bb9cbe6a84c06f6..1b7d5a622da757b8584bc7a5b3127148ae9417ed 100644 (file)
@@ -173,6 +173,10 @@ select {
 
                &.button {
                        border-radius: 0;
+
+                       .icon {
+                               cursor: inherit;
+                       }
                }
 
                &:not(.button) {