cupper-hugo-theme/public/js/dom-scripts.js

23 lines
598 B
JavaScript
Raw Normal View History

2017-06-26 17:21:58 +02:00
/* expandable sections */
(function () {
'use strict'
function toggle (button, target) {
var expanded = button.getAttribute('aria-expanded') === 'true' || false
button.setAttribute('aria-expanded', !expanded)
target.hidden = !target.hidden
}
var expanders = document.querySelectorAll('[data-expands]')
Array.prototype.forEach.call(expanders, function (expander) {
console.log(expander)
var target = document.getElementById(expander.getAttribute('data-expands'))
expander.addEventListener('click', function () {
toggle(expander, target)
})
})
}())