Our books
Books
Books written by Institute scientists
<script>
// To enable code execution go to Bricks > Settings > Builder Access
function activateScript() {
if (window.innerWidth >= 992) {
const card = '.books-card';
const featureCards = document.querySelectorAll(card);
// Function to recalculate textHeight
const recalculateTextHeight = (cardText) => {
cardText.style.height = 'auto';
const textHeight = cardText.offsetHeight;
cardText.style.height = '1px';
return textHeight;
}
for (var i = 0; i < featureCards.length; i++) {
const c = featureCards[i];
const textSelector = `${card}__text`;
const cardText = c.querySelector(textSelector);
let textHeight = recalculateTextHeight(cardText); // Initial calculation
c.addEventListener('mouseover', function() {
this.querySelector(textSelector).style.height = textHeight + 'px';
this.querySelector(textSelector).style.opacity = '1';
});
c.addEventListener('mouseout', function() {
this.querySelector(textSelector).style.height = '1px';
this.querySelector(textSelector).style.opacity = '0';
});
// Recalculate textHeight on heading focus
const heading = c.querySelector(`${card}__heading > a`);
heading.addEventListener('focus', function() {
textHeight = recalculateTextHeight(cardText);
c.querySelector(textSelector).style.height = textHeight + 'px';
c.querySelector(textSelector).style.opacity = '1';
});
heading.addEventListener('blur', function() {
c.querySelector(textSelector).style.height = '1px';
c.querySelector(textSelector).style.opacity = '0';
});
}
}
}
activateScript();
window.addEventListener('resize', activateScript);
</script>