1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-24 15:12:58 +00:00

Start handling clicks on the tags

This commit is contained in:
2024-04-04 03:03:04 +04:00
parent f6a35eb2a4
commit 50b1a4eab5

View File

@@ -51,6 +51,7 @@ export class MaintenancePopup extends BaseComponent {
this.#mediaBoxTools = mediaBoxTools;
MaintenancePopup.#watchActiveProfile(this.#onActiveProfileChanged.bind(this));
this.#tagsListElement.addEventListener('click', this.#handleTagClick.bind(this));
}
/**
@@ -90,6 +91,33 @@ export class MaintenancePopup extends BaseComponent {
});
}
/**
* Detect and process clicks made directly to the tags.
* @param {MouseEvent} event
*/
#handleTagClick(event) {
/** @type {HTMLElement} */
let tagElement = event.target;
if (!tagElement.classList.contains('tag')) {
tagElement = tagElement.closest('.tag');
}
if (!tagElement) {
return;
}
if (tagElement.classList.contains('is-present')) {
tagElement.classList.toggle('is-removed');
}
if (tagElement.classList.contains('is-missing')) {
tagElement.classList.toggle('is-added');
}
// TODO: Execute the submission on timeout or after user moved the mouse away from the popup.
}
/**
* @return {boolean}
*/