1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-03 06:22:34 +02:00
TableFilter/docs/script/inherited-summary.js
koalyptus 4481fbe361 publish Docs to gh-pages (auto)
branch:       master
SHA:          c7d6de72f7
range SHA:    81f31a3106fb...c7d6de72f785
build id:     375208741
build number: 1103
2018-05-05 08:21:30 +00:00

29 lines
815 B
JavaScript

(function(){
function toggle(ev) {
var button = ev.target;
var parent = ev.target.parentElement;
while(parent) {
if (parent.tagName === 'TABLE' && parent.classList.contains('summary')) break;
parent = parent.parentElement;
}
if (!parent) return;
var tbody = parent.querySelector('tbody');
if (button.classList.contains('opened')) {
button.classList.remove('opened');
button.classList.add('closed');
tbody.style.display = 'none';
} else {
button.classList.remove('closed');
button.classList.add('opened');
tbody.style.display = 'block';
}
}
var buttons = document.querySelectorAll('.inherited-summary thead .toggle');
for (var i = 0; i < buttons.length; i++) {
buttons[i].addEventListener('click', toggle);
}
})();