mirror of
https://github.com/morris/vanilla-todo.git
synced 2025-08-22 21:52:54 +02:00
first commit
This commit is contained in:
29
public/scripts/AppCollapsible.js
Normal file
29
public/scripts/AppCollapsible.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/* global VT */
|
||||
window.VT = window.VT || {};
|
||||
|
||||
VT.AppCollapsible = function (el) {
|
||||
var state = {
|
||||
show: true,
|
||||
};
|
||||
|
||||
el.querySelector('.bar > .toggle').addEventListener('click', function () {
|
||||
update({ show: !state.show });
|
||||
});
|
||||
|
||||
el.appCollapsible = {
|
||||
update: update,
|
||||
};
|
||||
|
||||
function update(next) {
|
||||
Object.assign(state, next);
|
||||
|
||||
el.querySelector('.bar > .toggle > .app-icon').classList.toggle(
|
||||
'-r180',
|
||||
state.show
|
||||
);
|
||||
|
||||
el.querySelectorAll('.body').forEach(function (el) {
|
||||
el.style.height = state.show ? el.children[0].offsetHeight + 'px' : '0';
|
||||
});
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user