server/static/assets/js/organization.js
2020-07-17 22:12:11 +00:00

44 lines
1.3 KiB
JavaScript

/**
* Schedule collapsable section animation
*/
document.querySelectorAll('.schedule-category').forEach(node => {
let opened = false
let icon = node.querySelector('.schedule-category-collapse-icon')
let content = node.querySelector('.schedule-category-table')
let header = node.querySelector('.schedule-category-header')
header.onclick = () => {
if (!opened) {
// open the table
icon.style.transform = "rotate(180deg)"
content.style.maxHeight = content.scrollHeight + "px"
} else {
// close the table
icon.style.transform = "rotate(0deg)"
content.style.maxHeight = null
}
opened = !opened
}
})
/**
* Gallery modal to view media in large
*/
let mediaModal = document.querySelector('#media-modal')
let mediaModalImage = document.querySelector('#media-modal-image')
let openModal = url => {
mediaModal.style.visibility = 'visible'
mediaModal.style.opacity = 1
let attr = document.createAttribute('src')
attr.value = url
mediaModalImage.attributes.setNamedItem(attr)
document.body.style.height = "100vh"
document.body.style.overflow = "hidden"
}
let closeModal = () => {
mediaModal.style.visibility = 'hidden'
mediaModal.style.opacity = 0
document.body.style.overflow = "initial"
document.body.style.height = "initial"
}