Commit b018d2d7 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add function to set hover title of cards

parent d876b4fb
Loading
Loading
Loading
Loading
+18 −0
Changes for static/js/cards.mjs: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -26,3 +26,21 @@ export function createCard(title, supplemental) {

    return cardEl
}

/**
 * Set the HTML title attribute (which controls the text that appears on mouseover) of the card
 * and if the title bar should appear clickable.
 * 
 * @param {HTMLElement} cardEl The .card element
 * @param {String} text The text for the hover title
 * @param {Boolean} clickable If the title bar should appear clickable
 */
 export function setCardHoverTitle(cardEl, text, clickable) {
    const titleEl = cardEl.querySelector(".title")
    titleEl.setAttribute("title", text)
    if(clickable) {
        titleEl.classList.add("clickable")
    } else {
        titleEl.classList.remove("clickable")
    }
}