class Controller { constructor(presenter) { this.presenter = presenter; }…
- User
class Controller { constructor(presenter) { this.presenter = presenter; }
codehandleEvent(element) { this.presenter.setLayout(element); }}
class Presenter { constructor(containerId) { this.container = document.getElementById(containerId); this.divs = this.container.querySelectorAll('.inner-div'); }
codesetLayout(layoutType) { // Wyczyść wszystkie style dla divs this.divs.forEach(div => { div.style.removeProperty('left'); div.style.removeProperty('top'); div.style.removeProperty('right'); div.style.removeProperty('bottom'); div.textContent = ''; }); // Stosuj nowe style w zależności od układu switch (layoutType) { case 'A': // Układ X this.divs[0].style.left = '0'; this.divs[0].style.top = '0'; this.divs[0].textContent = 'Jan'; this.divs[1].style.left = '45%'; this.divs[1].style.top = '45%'; this.divs[1].textContent = 'Kowalski'; this.divs[2].style.right = '0'; this.divs[2].style.bottom = '0'; break; case 'B': // Układ Y this.divs.forEach((div, index) => { div.style.left = `${index * 33.3}%`; div.style.top = '45%'; }); this.divs[0].textContent = 'Jan'; this.divs[1].textContent = 'Kowalski'; break; case 'C': // Układ Z this.divs[0].style.left = '0'; this.divs[0].style.top = '0'; this.divs[1].style.left = '12%'; this.divs[1].style.top = '0'; this.divs[2].style.right = '0'; this.divs[2].style.bottom = '0'; this.divs[2].textContent = 'Jan'; this.divs[3].style.right = '12%'; this.divs[3].style.bottom = '0'; this.divs[3].textContent = 'Kowalski'; break; } } - Assistant