From b8ae54fb2c9e8f5899cda8fe856c9cf5fa423c73 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Thu, 27 Jun 2024 03:01:07 +0200 Subject: [PATCH] Add i18n to popup controls --- public/scripts/popup.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/scripts/popup.js b/public/scripts/popup.js index 7f61b8ac5..a34b9f1f0 100644 --- a/public/scripts/popup.js +++ b/public/scripts/popup.js @@ -178,7 +178,9 @@ export class Popup { // If custom button captions are provided, we set them beforehand this.okButton.textContent = typeof okButton === 'string' ? okButton : 'OK'; + this.okButton.dataset.i18n = this.okButton.textContent; this.cancelButton.textContent = typeof cancelButton === 'string' ? cancelButton : template.getAttribute('popup-button-cancel'); + this.cancelButton.dataset.i18n = this.cancelButton.textContent; this.defaultResult = defaultResult; this.customButtons = customButtons; @@ -191,6 +193,7 @@ export class Popup { buttonElement.classList.add(...(button.classes ?? [])); buttonElement.dataset.result = String(button.result ?? undefined); buttonElement.textContent = button.text; + buttonElement.dataset.i18n = buttonElement.textContent; buttonElement.tabIndex = 0; if (button.appendAtEnd) { @@ -226,8 +229,9 @@ export class Popup { if (input.tooltip) { const tooltip = document.createElement('div'); - tooltip.title = input.tooltip; tooltip.classList.add('fa-solid', 'fa-circle-info', 'opacity50p'); + tooltip.title = input.tooltip; + tooltip.dataset.i18n = '[title]' + input.tooltip; label.appendChild(tooltip); } @@ -462,7 +466,7 @@ export class Popup { if (!shouldClose) return; } - Popup.util.lastResult = { value, result }; + Popup.util.lastResult = { value, result, inputResults: this.inputResults }; this.#hide(); } @@ -518,10 +522,10 @@ export class Popup { * Contains the list of all currently open popups, and it'll remember the result of the last closed popup. */ static util = { - /** @type {Popup[]} Remember all popups */ + /** @readonly @type {Popup[]} Remember all popups */ popups: [], - /** @type {{value: any, result: POPUP_RESULT|number?}?} Last popup result */ + /** @type {{value: any, result: POPUP_RESULT|number?, inputResults: Map?}?} Last popup result */ lastResult: null, /** @returns {boolean} Checks if any modal popup dialog is open */