From 4dd85d7d5d175165cc9e58a84a01493485b9f64f Mon Sep 17 00:00:00 2001 From: Chris Rohrer Date: Sat, 6 Jan 2024 10:55:14 +0100 Subject: [PATCH] fix: makes preview overlay also work with other languages --- javascript/localization.js | 3 +++ javascript/script.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/javascript/localization.js b/javascript/localization.js index 8fda68e2..0a8394ca 100644 --- a/javascript/localization.js +++ b/javascript/localization.js @@ -45,6 +45,9 @@ function processTextNode(node) { var tl = getTranslation(text); if (tl !== undefined) { node.textContent = tl; + if (text && node.parentElement) { + node.parentElement.setAttribute("data-original-text", text); + } } } diff --git a/javascript/script.js b/javascript/script.js index 05461cc1..74c8ed22 100644 --- a/javascript/script.js +++ b/javascript/script.js @@ -159,7 +159,8 @@ function initStylePreviewOverlay() { label.addEventListener("mouseout", onMouseLeave); overlayVisible = true; overlay.style.display = "block"; - const name = label.querySelector("span").textContent; + const originalText = label.querySelector("span").getAttribute("data-original-text"); + const name = originalText || label.querySelector("span").textContent; overlay.style.backgroundImage = `url("${samplesPath.replace( "Fooocus V2", name