diff options
-rw-r--r-- | ext/fg/js/popup.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 868f07ce..e48703bf 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -17,3 +17,29 @@ */ +class Popup { + constructor() { + this.offset = 10; + + this.popup = document.createElement('iframe'); + this.popup.id = 'yomichan-popup'; + this.popup.addEventListener('mousedown', (e) => e.stopPropagation()); + this.popup.addEventListener('scroll', (e) => e.stopPropagation()); + + document.body.appendChild(this.popup); + } + + show(cont, pos) { + this.popup.style.left = pos.x + 'px'; + this.popup.style.top = pos.y + 'px'; + this.popup.style.visibility = 'visible'; + } + + hide() { + this.popup.style.visibility = 'hidden'; + } + + update(cont) { + this.popup.setAttribute('srcdoc', cont); + } +} |