diff --git a/UI/Component/AdvancedInput.js b/UI/Component/AdvancedInput.js index 1a39934..36331bd 100644 --- a/UI/Component/AdvancedInput.js +++ b/UI/Component/AdvancedInput.js @@ -17,7 +17,7 @@ export class AdvancedInput * * @since 1.0.0 */ - constructor (e) + constructor (e, eventManager, observer) { this.id = e.id; this.inputComponent = e; @@ -113,6 +113,25 @@ export class AdvancedInput self.addToResultList(self, document.activeElement); jsOMS.removeClass(self.dropdownElement, 'active'); }); + + observer.observe(this.tagElement, { childList: true, attributes: false, subtree: false }); + eventManager.attach(this.id + '-tags-childList', function(data) { + const removes = data.target.querySelectorAll('.fa-times'), + removesLength = removes === null ? 0 : removes.length; + + if (removesLength < 1) { + return; + } + + removes[removesLength - 1].addEventListener('click', function(e) { + if (e.target.parentNode.parentNode === null) { + return; + } + + e.target.parentNode.parentNode.removeChild(e.target.parentNode); + }); + }); + }; /** diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index 3beba59..9e37493 100644 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -15,11 +15,14 @@ export class GeneralUI /** * @constructor * + * @param {Object} app Application object + * * @since 1.0.0 */ - constructor () + constructor (app) { this.visObs = null; + this.app = app; }; /** @@ -130,7 +133,7 @@ export class GeneralUI const length = e.length; for (let i = 0; i < length; ++i) { - new AdvancedInput(e[i]); + new AdvancedInput(e[i], this.app.eventManager, this.app.uiManager.getDOMObserver()); } }; }; diff --git a/UI/UIManager.js b/UI/UIManager.js index 51c531c..f2cd0f7 100644 --- a/UI/UIManager.js +++ b/UI/UIManager.js @@ -30,7 +30,7 @@ export class UIManager this.tableManager = new Table(this.app); this.actionManager = new ActionManager(this.app); this.dragNDrop = new DragNDrop(this.app); - this.generalUI = new GeneralUI(); + this.generalUI = new GeneralUI(this.app); const self = this; /** global: MutationObserver */