aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-01-07 18:39:36 -0800
committerAlex Yatskov <alex@foosoft.net>2017-01-07 18:39:36 -0800
commitfab7a03b6c345ccd9fec66adb08a45206557c306 (patch)
treeea9f92263485a742ea66de7d05fc19e86b525e3d /ext/fg/js/popup.js
parentdc4162eeed14d958c65d63b2568fce58890e14e3 (diff)
WIP
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js28
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}, '*');
}
}