From 40eff8e30e1cab18ac2bbdbcce34223bb5385a9f Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 22 Oct 2022 22:32:57 +0700 Subject: [PATCH] fix chrome compatibility issue for description text reveal, #327 --- tubearchivist/static/script.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 08e94d2..a1205d6 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -1102,12 +1102,12 @@ function textReveal() { function textExpand() { var textBox = document.getElementById("text-expand"); var button = document.getElementById("text-expand-button"); - var textBoxLineClamp = textBox.style["-webkit-line-clamp"]; - if (textBoxLineClamp === "none") { + var style = window.getComputedStyle(textBox) + if (style.webkitLineClamp === "none") { textBox.style["-webkit-line-clamp"] = "4"; button.innerText = "Show more"; } else { - textBox.style["-webkit-line-clamp"] = "none"; + textBox.style["-webkit-line-clamp"] = "unset"; button.innerText = "Show less"; } } @@ -1119,8 +1119,9 @@ function textExpandButtonVisibilityUpdate() { if (!textBox || !button) return; - var textBoxLineClamp = textBox.style["-webkit-line-clamp"]; - if (textBoxLineClamp === "none") + var styles = window.getComputedStyle(textBox); + var textBoxLineClamp = styles.webkitLineClamp; + if (textBoxLineClamp === "unset") return; // text box is in revealed state if (textBox.offsetHeight < textBox.scrollHeight