feat: changes for citation ad dynamic

This commit is contained in:
mohamad
2026-05-17 18:51:26 +03:30
parent f0a9d5832b
commit b8ab67049f
22 changed files with 1170 additions and 287 deletions
+39
View File
@@ -152,12 +152,51 @@ function initIntersectionObserver() {
});
}
function initReadMore() {
var chevronSVG = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true"><path d="M2 4L6 8L10 4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
document.querySelectorAll('[data-readmore]').forEach(function (el) {
var threshold = parseInt(el.getAttribute('data-readmore'), 10) || 120;
var fullHeight = el.scrollHeight;
if (fullHeight <= threshold + 12) return;
var storedHeight = fullHeight;
el.classList.add('readmore-wrap', 'is-clamped');
el.style.maxHeight = threshold + 'px';
var btn = document.createElement('button');
btn.type = 'button';
btn.className = 'readmore-btn';
btn.setAttribute('aria-expanded', 'false');
btn.innerHTML = 'Read more ' + chevronSVG;
el.insertAdjacentElement('afterend', btn);
btn.addEventListener('click', function () {
var collapsed = el.classList.toggle('is-clamped');
if (collapsed) {
el.style.maxHeight = threshold + 'px';
btn.innerHTML = 'Read more ' + chevronSVG;
btn.setAttribute('aria-expanded', 'false');
btn.classList.remove('is-open');
} else {
el.style.maxHeight = storedHeight + 'px';
btn.innerHTML = 'Read less ' + chevronSVG;
btn.setAttribute('aria-expanded', 'true');
btn.classList.add('is-open');
}
});
});
}
function init() {
initNavbarScroll();
initMobileMenu();
initMegaMenu();
initFAQAccordion();
initIntersectionObserver();
initReadMore();
}
if (document.readyState === 'loading') {