Last active
July 13, 2023 11:05
-
-
Save suhodolskiy/7a9fead29b8d2794000c11d3e5477215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('feedspring:render-complete', () => { | |
const posts = document.querySelectorAll('[feedspring="post"]') | |
const selectorReadMoreButton = '.code-button' | |
const buttonExpandText = 'Hide' | |
posts.forEach((post) => { | |
const review = post.querySelector('[feed-field="review"]') | |
if (review && review.scrollHeight > review.clientHeight) { | |
const button = post.querySelector(selectorReadMoreButton) | |
if (button) { | |
button.style.setProperty('display', '-webkit-box') | |
button.addEventListener('click', () => { | |
if (review.scrollHeight > review.clientHeight) { | |
review.style.setProperty('-webkit-line-clamp', 'inherit') | |
button.setAttribute('text', button.innerText) | |
button.innerText = buttonExpandText | |
} else { | |
review.style.removeProperty('-webkit-line-clamp') | |
button.innerText = button.getAttribute('text') | |
} | |
}) | |
} | |
} | |
}) | |
}, { once: true }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment