'use strict'; // document.querySelectorAll('.body-wrapper input').forEach( e => e.disabled = true); // document.querySelectorAll('.body-wrapper a').forEach( e => e.tabIndex = -1); // TODO: this (() => { })(); let stack = []; let maxZIndex = 100; const wrapper = document.querySelector('.window-wrapper'); if (!wrapper) { throw new Error('window wrapper is missing'); } const getWindowById = id => { if (typeof id !== 'string') { throw new Error('className is not a string'); } const window = document.getElementById(id); if (!window) { throw new Error('Window with ID ' + className + ' not found'); } return window; }; const openWindow = id => { const window = getWindowById(id); window.classList.add('active'); wrapper.classList.add('active'); if (!stack.includes(window)) { // hide all other windows if (stack.length) { stack.forEach( e => e.classList.remove('active')); } stack.push(window); ++maxZIndex; window.style.zIndex = maxZIndex; } }; const closeWindow = id => { const window = getWindowById(id); window.classList.remove('active'); if (stack.length && stack[stack.length - 1] === window) { stack.pop(); } if (!stack.length) { wrapper.classList.remove('active'); maxZIndex = 100; } else { stack.forEach( e => e.classList.add('active')); } }; wrapper.style.display = ""; // // document.querySelector('.window-wrapper .window .close-button').forEach( e => { // createListener(e, 'click', (ev, el, wrapper) => { // e // }); // // const createListener = function(element, event, callback, ...args) { // element.addEventListener(event, wrapListener(callback, element, ...args)); // }; // });