32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
const compoundTurn = document.querySelector('.compound .turn');
|
|
const compoundText = document.querySelector('.compound__text');
|
|
const questItem = document.querySelectorAll('.quests-content__item .quest-level');
|
|
|
|
if (compoundTurn) {
|
|
const compoundTextHeight = compoundText.offsetHeight;
|
|
|
|
questItem.forEach(item => {
|
|
let levelIcons = item.querySelectorAll('img');
|
|
|
|
for (let i = 0; i < item.dataset.level; i++) {
|
|
levelIcons[i].classList.remove('icon-hidden')
|
|
}
|
|
});
|
|
|
|
compoundText.style.height = compoundTextHeight/3 + 'px';
|
|
|
|
compoundTurn.addEventListener('click', () => {
|
|
let currentHeight = compoundText.style.height.slice(0, -2);
|
|
|
|
if (currentHeight === compoundTextHeight) {
|
|
compoundTurn.textContent = 'Читать далее';
|
|
compoundText.style.height = compoundTextHeight/3 + 'px';
|
|
} else{
|
|
compoundTurn.textContent = 'Свернуть';
|
|
compoundText.style.height = compoundTextHeight + 'px';
|
|
}
|
|
})
|
|
}
|
|
|
|
document.querySelector('.carousel-item').classList.add('active');
|