diff options
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r-- | ext/fg/js/popup.js | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 35d7a00f..21f4a9d7 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -30,7 +30,7 @@ class Popup { document.body.appendChild(this.container); } - show(rect) { + showAt(rect) { this.container.style.left = rect.x + 'px'; this.container.style.top = rect.y + 'px'; this.container.style.height = rect.height + 'px'; @@ -59,22 +59,26 @@ class Popup { y = elementRect.top - height - this.offset; } - this.show({x, y, width, height}); + this.showAt({x, y, width, height}); } - visible() { - return this.container !== null && this.container.style.visibility !== 'hidden'; + hide() { + this.container.style.visibility = 'hidden'; } - hide() { - if (this.container !== null) { - this.container.style.visibility = 'hidden'; - } + isVisible() { + return this.container.style.visibility !== 'hidden'; } - invoke(action, params) { - if (this.container !== null) { - this.container.contentWindow.postMessage({action, params}, '*'); - } + showTermDefs(definitions, options) { + this.invokeApi('showTermDefs', {definitions, options}); + } + + showKanjiDefs(definitions, options) { + this.invokeApi('showKanjiDefs', {definitions, options}); + } + + invokeApi(action, params) { + this.container.contentWindow.postMessage({action, params}, '*'); } } |