-
Notifications
You must be signed in to change notification settings - Fork 0
/
readmore.min.js
9 lines (9 loc) · 1.15 KB
/
readmore.min.js
1
2
3
4
5
6
7
8
9
/*!
* Readmore.js v1.1.0 - JavaScript plugin
* Author: @RoS (CORGRAS)
* Project home: https://corgras.github.io/readmore/
* Github: https://github.com/corgras/Readmore.js
* Licensed under the MIT license
*/
function initReadMore(e,n,t){var i,r=document.querySelectorAll(e);function a(e){!t||e.matches?r.forEach((function(e){var t=!1,i=n.collapsedHeight||200,r=n.speed||100,a=n.heightMargin||16,o=n.moreLink||'<a href="#">Read More</a>',s=n.lessLink||'<a href="#">Close</a>',l=e.innerHTML,d=e.scrollHeight,h=document.createElement("div");h.innerHTML=o,h.classList.add("readmore-button"),e.style.overflow="hidden",e.style.height=i+"px",e.style.transition="height "+r+"ms ease-in-out",e.parentNode.insertBefore(h,e.nextSibling),d<=i&&(h.style.display="none"),h.addEventListener("click",(function(n){n.preventDefault(),(t=!t)?(e.style.height=d+a+"px",h.innerHTML=s):(e.style.height=i+"px",h.innerHTML=o)})),e.innerHTML=l})):r.forEach((function(e){var n=e.nextElementSibling;n&&n.classList.contains("readmore-button")&&e.parentNode.removeChild(n)}))}t?((i=window.matchMedia("(max-width: "+t+"px)")).addListener(a),a(i)):a({matches:!0})}
//# sourceMappingURL=readmore.min.js.map