diff --git a/service.js b/service.js index 7bc45f0..cdcc0f6 100644 --- a/service.js +++ b/service.js @@ -517,7 +517,7 @@ class BesService { } } } - popup.hide() + BesPopupEl.hide() } // This function should be able to handle both cases or find a way that works for both. @@ -722,7 +722,7 @@ class BesPopupEl extends HTMLElement {
- +
@@ -767,10 +767,6 @@ class BesPopupEl extends HTMLElement { } } - hide() { - this.classList.remove('show') - } - changeText(text) { this.clear() this.shadowRoot.querySelector('.popup-text').textContent = text @@ -783,14 +779,16 @@ class BesPopupEl extends HTMLElement { replacementBtn.textContent = replacement replacementBtn.classList.add('bes-replacement') replacementBtn.addEventListener('click', () => { - if (allowReplacements) service.replaceText(el, match, replacement) - // TODO: Close popup + if (allowReplacements) { + service.replaceText(el, match, replacement) + BesPopupEl.hide() + } }) replacementDiv.appendChild(replacementBtn) } dragMouseDown(e) { - e = e || window.event + e = e e.preventDefault() this.initialMouseX = e.clientX this.initialMouseY = e.clientY @@ -843,6 +841,13 @@ class BesPopupEl extends HTMLElement { this.isMouseDownRegistered = true } } + + static hide() { + let popups = document.querySelectorAll('bes-popup-el') + popups.forEach(popup => { + popup.classList.remove('show') + }) + } } window.onload = () => {