'wcf.date.datePicker.month': '{jslang}wcf.date.datePicker.month{/jslang}',
'wcf.date.datePicker.year': '{jslang}wcf.date.datePicker.year{/jslang}',
'wcf.date.datePicker.hour': '{jslang}wcf.date.datePicker.hour{/jslang}',
- 'wcf.date.datePicker.minute': '{jslang}wcf.date.datePicker.minute{/jslang}'
+ 'wcf.date.datePicker.minute': '{jslang}wcf.date.datePicker.minute{/jslang}',
+ 'wcf.global.form.password.button.hide': '{jslang}wcf.global.form.password.button.hide{/jslang}',
+ 'wcf.global.form.password.button.show': '{jslang}wcf.global.form.password.button.show{/jslang}'
{if MODULE_LIKE}
,'wcf.like.button.like': '{jslang}wcf.like.button.like{/jslang}',
'wcf.like.button.dislike': '{jslang}wcf.like.button.dislike{/jslang}',
import * as UiTabMenu from "./Ui/TabMenu";
import * as UiTooltip from "./Ui/Tooltip";
import * as UiPageJumpTo from "./Ui/Page/JumpTo";
+import * as UiPassword from "./Ui/Password";
// perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js
// eslint-disable-next-line @typescript-eslint/no-unused-vars
UiTabMenu.setup();
UiDialog.setup();
UiTooltip.setup();
+ UiPassword.setup();
// Convert forms with `method="get"` into `method="post"`
document.querySelectorAll("form[method=get]").forEach((form: HTMLFormElement) => {
--- /dev/null
+import DomChangeListener from "../Dom/Change/Listener";
+import * as Language from "../Language";
+
+const _knownElements = new WeakSet();
+
+export function setup(): void {
+ initElements();
+ DomChangeListener.add("WoltLabSuite/Core/Ui/Password", () => initElements());
+}
+
+function initElements(): void {
+ document.querySelectorAll("input[type=password]").forEach((input: HTMLInputElement) => {
+ if (!_knownElements.has(input)) {
+ initElement(input);
+ }
+ });
+}
+
+function initElement(input: HTMLInputElement): void {
+ _knownElements.add(input);
+
+ const inputAddon = document.createElement("div");
+ inputAddon.classList.add("inputAddon");
+ input.insertAdjacentElement("beforebegin", inputAddon);
+ inputAddon.appendChild(input);
+
+ const button = document.createElement("span");
+ button.title = Language.get("wcf.global.form.password.button.show");
+ button.classList.add("button", "inputSuffix", "jsTooltip");
+ button.setAttribute("role", "button");
+ button.tabIndex = 0;
+ button.setAttribute("aria-hidden", "true");
+ inputAddon.appendChild(button);
+
+ const icon = document.createElement("span");
+ icon.classList.add("icon", "icon16", "fa-eye-slash");
+ button.appendChild(icon);
+
+ button.addEventListener("click", () => {
+ toggle(input, button, icon);
+ });
+ button.addEventListener("keydown", (event) => {
+ if (event.key === "Enter" || event.key === " ") {
+ event.preventDefault();
+ toggle(input, button, icon);
+ }
+ });
+}
+
+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";
+}
'wcf.date.datePicker.month': '{jslang}wcf.date.datePicker.month{/jslang}',
'wcf.date.datePicker.year': '{jslang}wcf.date.datePicker.year{/jslang}',
'wcf.date.datePicker.hour': '{jslang}wcf.date.datePicker.hour{/jslang}',
- 'wcf.date.datePicker.minute': '{jslang}wcf.date.datePicker.minute{/jslang}'
+ 'wcf.date.datePicker.minute': '{jslang}wcf.date.datePicker.minute{/jslang}',
+ 'wcf.global.form.password.button.hide': '{jslang}wcf.global.form.password.button.hide{/jslang}',
+ 'wcf.global.form.password.button.show': '{jslang}wcf.global.form.password.button.show{/jslang}'
{event name='javascriptLanguageImport'}
});
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Bootstrap
*/
-define(["require", "exports", "tslib", "./Core", "./Date/Picker", "./Date/Time/Relative", "./Devtools", "./Dom/Change/Listener", "./Environment", "./Event/Handler", "./Language", "./StringUtil", "./Ui/Dialog", "./Ui/Dropdown/Simple", "./Ui/Mobile", "./Ui/Page/Action", "./Ui/TabMenu", "./Ui/Tooltip", "./Ui/Page/JumpTo"], function (require, exports, tslib_1, Core, Picker_1, DateTimeRelative, Devtools_1, Listener_1, Environment, EventHandler, Language, StringUtil, Dialog_1, Simple_1, UiMobile, UiPageAction, UiTabMenu, UiTooltip, UiPageJumpTo) {
+define(["require", "exports", "tslib", "./Core", "./Date/Picker", "./Date/Time/Relative", "./Devtools", "./Dom/Change/Listener", "./Environment", "./Event/Handler", "./Language", "./StringUtil", "./Ui/Dialog", "./Ui/Dropdown/Simple", "./Ui/Mobile", "./Ui/Page/Action", "./Ui/TabMenu", "./Ui/Tooltip", "./Ui/Page/JumpTo", "./Ui/Password"], function (require, exports, tslib_1, Core, Picker_1, DateTimeRelative, Devtools_1, Listener_1, Environment, EventHandler, Language, StringUtil, Dialog_1, Simple_1, UiMobile, UiPageAction, UiTabMenu, UiTooltip, UiPageJumpTo, UiPassword) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setup = void 0;
UiTabMenu = tslib_1.__importStar(UiTabMenu);
UiTooltip = tslib_1.__importStar(UiTooltip);
UiPageJumpTo = tslib_1.__importStar(UiPageJumpTo);
+ UiPassword = tslib_1.__importStar(UiPassword);
// non strict equals by intent
if (window.WCF == null) {
window.WCF = {};
UiTabMenu.setup();
Dialog_1.default.setup();
UiTooltip.setup();
+ UiPassword.setup();
// Convert forms with `method="get"` into `method="post"`
document.querySelectorAll("form[method=get]").forEach((form) => {
form.method = "post";
--- /dev/null
+define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Language"], function (require, exports, tslib_1, Listener_1, Language) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.setup = void 0;
+ Listener_1 = tslib_1.__importDefault(Listener_1);
+ Language = tslib_1.__importStar(Language);
+ const _knownElements = new WeakSet();
+ function setup() {
+ initElements();
+ Listener_1.default.add("WoltLabSuite/Core/Ui/Password", () => initElements());
+ }
+ exports.setup = setup;
+ function initElements() {
+ document.querySelectorAll("input[type=password]").forEach((input) => {
+ if (!_knownElements.has(input)) {
+ initElement(input);
+ }
+ });
+ }
+ function initElement(input) {
+ _knownElements.add(input);
+ const inputAddon = document.createElement("div");
+ inputAddon.classList.add("inputAddon");
+ input.insertAdjacentElement("beforebegin", inputAddon);
+ inputAddon.appendChild(input);
+ const button = document.createElement("span");
+ button.title = Language.get("wcf.global.form.password.button.show");
+ button.classList.add("button", "inputSuffix", "jsTooltip");
+ button.setAttribute("role", "button");
+ button.tabIndex = 0;
+ button.setAttribute("aria-hidden", "true");
+ inputAddon.appendChild(button);
+ const icon = document.createElement("span");
+ icon.classList.add("icon", "icon16", "fa-eye-slash");
+ button.appendChild(icon);
+ button.addEventListener("click", () => {
+ toggle(input, button, icon);
+ });
+ button.addEventListener("keydown", (event) => {
+ if (event.key === "Enter" || event.key === " ") {
+ event.preventDefault();
+ toggle(input, button, icon);
+ }
+ });
+ }
+ 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";
+ }
+});
<item name="wcf.global.form.error.greaterThan.javaScript"><![CDATA[{literal}Der eingegebene Wert muss größer sein als {#$greaterThan}.{/literal}]]></item>
<!-- /deprecated since 2.1 -->
<item name="wcf.global.form.required"><![CDATA[Benötigte Angaben]]></item>
+ <item name="wcf.global.form.password.button.hide"><![CDATA[Verbergen]]></item>
+ <item name="wcf.global.form.password.button.show"><![CDATA[Anzeigen]]></item>
</category>
<category name="wcf.form">
<item name="wcf.form.field.className"><![CDATA[Klasse]]></item>
<item name="wcf.global.form.error.lessThan.javaScript"><![CDATA[{literal}The entered value has to be less than {#$lessThan}.{/literal}]]></item>
<!-- /deprecated since 2.1 -->
<item name="wcf.global.form.required"><![CDATA[Required fields]]></item>
+ <item name="wcf.global.form.password.button.hide"><![CDATA[Hide]]></item>
+ <item name="wcf.global.form.password.button.show"><![CDATA[Show]]></item>
</category>
<category name="wcf.form">
<item name="wcf.form.field.className"><![CDATA[Class]]></item>