refactor: separate task creation logic from Kanblendar class

Moved event listener for task button from Kanblendar init method to DOMContentLoaded handler. This change simplifies the Kanblendar class and improves modularity by placing event listening logic closer to the button initialization. Helps maintain separation of concerns and makes the code easier to manage and test.
This commit is contained in:
Kumi 2024-07-30 13:48:35 +02:00
parent cc4989cac4
commit 303258ce10
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 3 additions and 3 deletions

View file

@ -1,3 +1,5 @@
document.addEventListener('DOMContentLoaded', () => {
new Kanblendar();
const kanblendar = new Kanblendar();
const createTaskBtn = document.getElementById('createTaskBtn');
createTaskBtn.addEventListener('click', () => kanblendar.openModal());
});

View file

@ -33,7 +33,6 @@ class Kanblendar {
}
init() {
this.createTaskBtn = document.getElementById('createTaskBtn');
this.kanbanSection = document.getElementById('kanblendar');
if (this.config.generateModal) {
@ -44,7 +43,6 @@ class Kanblendar {
this.taskForm = document.getElementById('kanblendar-taskForm');
}
this.createTaskBtn.addEventListener('click', () => this.openModal());
this.closeModal.addEventListener('click', () => this.closeModalFunc());
window.addEventListener('click', (event) => {
if (event.target === this.taskModal) {