2017-06-09 15:27:09 +02:00
|
|
|
/* expandable sections */
|
|
|
|
(function () {
|
|
|
|
function toggle (button, target) {
|
2017-07-01 12:48:01 +02:00
|
|
|
var expanded = button.getAttribute('aria-expanded') === 'true'
|
2017-06-09 15:27:09 +02:00
|
|
|
button.setAttribute('aria-expanded', !expanded)
|
|
|
|
target.hidden = !target.hidden
|
|
|
|
}
|
|
|
|
|
|
|
|
var expanders = document.querySelectorAll('[data-expands]')
|
|
|
|
|
|
|
|
Array.prototype.forEach.call(expanders, function (expander) {
|
|
|
|
var target = document.getElementById(expander.getAttribute('data-expands'))
|
|
|
|
|
|
|
|
expander.addEventListener('click', function () {
|
|
|
|
toggle(expander, target)
|
|
|
|
})
|
|
|
|
})
|
2017-07-01 12:48:01 +02:00
|
|
|
}());
|
2017-06-09 15:27:09 +02:00
|
|
|
|
2017-07-01 12:48:01 +02:00
|
|
|
/* menu button */
|
|
|
|
(function () {
|
|
|
|
var button = document.getElementById('menu-button')
|
|
|
|
var menu = document.getElementById('patterns-list')
|
|
|
|
button.addEventListener('click', function() {
|
|
|
|
var expanded = this.getAttribute('aria-expanded') === 'true'
|
|
|
|
this.setAttribute('aria-expanded', !expanded)
|
|
|
|
})
|
|
|
|
}());
|
2017-06-30 18:14:15 +02:00
|
|
|
|
|
|
|
/* persist navigation scroll point */
|
2017-07-01 12:48:01 +02:00
|
|
|
(function () {
|
2017-07-21 09:53:42 +02:00
|
|
|
window.onunload = function () {
|
2017-07-01 12:48:01 +02:00
|
|
|
var scrollPoint = document.getElementById('patterns-nav').scrollTop
|
|
|
|
localStorage.setItem('scrollPoint', scrollPoint)
|
2017-07-21 09:53:42 +02:00
|
|
|
}
|
2017-06-30 18:14:15 +02:00
|
|
|
|
2017-07-21 09:53:42 +02:00
|
|
|
window.addEventListener('DOMContentLoaded', function () {
|
2017-07-23 12:31:23 +02:00
|
|
|
if (window.location.href.indexOf('patterns/') !== -1) {
|
|
|
|
document.getElementById('patterns-nav').scrollTop = parseInt(localStorage.getItem('scrollPoint'))
|
|
|
|
} else {
|
|
|
|
document.getElementById('patterns-nav').scrollTop = 0
|
|
|
|
}
|
2017-07-01 12:48:01 +02:00
|
|
|
})
|
|
|
|
}());
|