0) ? domElements[0] : null ; if (domElement && domElement.offsetHeight > config.heightCal) { var elHeight = domElement.offsetHeight; domElement.innerHTML = '
' + domElement.innerHTML + "
"; var hiddenTextDom = domElement.getElementsByTagName("div")[0]; var link = document.createElement("a"); link.classList.add("more"); link.innerHTML = config.showMore; link.href = "#"; link.addEventListener("click", function (event) { event.preventDefault(); var scrollHeightBefore = window.scrollY; if (this.className === "more") { this.classList.remove("more"); this.classList.add("less"); this.innerHTML = config.showLess; setHeight(hiddenTextDom, elHeight); hiddenTextDom.classList.remove('show'); } else { this.classList.remove("less"); this.classList.add("more"); this.innerHTML = config.showMore; hiddenTextDom.classList.add(config.hiddenClass); setHeight(hiddenTextDom, config.heightShow); hiddenTextDom.classList.add("show"); } window.scroll(0,scrollHeightBefore); }); domElement.appendChild(link); setHeight(hiddenTextDom, config.heightShow); } };