summaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-25 18:19:38 -0700
committerAlex Yatskov <alex@foosoft.net>2017-03-25 18:19:38 -0700
commit37321e8d52849b0824132e2339760e96308abbb6 (patch)
tree1e6b986768e65d07337bc31ae1d8c2641f60d9f4 /ext/fg
parent2c164fb65f286e2852c7e5eb5e7098c5a4fe6f1a (diff)
parent063f3d4dbf8c896f4f7b022cfae6e2b907769251 (diff)
Merge branch 'dev'
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/frame.html31
-rw-r--r--ext/fg/js/display-frame.js12
-rw-r--r--ext/fg/js/driver.js31
3 files changed, 51 insertions, 23 deletions
diff --git a/ext/fg/frame.html b/ext/fg/frame.html
index ec0acf64..35bc0284 100644
--- a/ext/fg/frame.html
+++ b/ext/fg/frame.html
@@ -6,28 +6,35 @@
<link rel="stylesheet" href="/mixed/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="/mixed/lib/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="/mixed/css/frame.css">
+ <style type="text/css">
+ .entry {
+ padding-left: 10px;
+ padding-right: 10px;
+ }
+ </style>
</head>
<body>
- <div class="container-fluid">
- <div id="spinner">
- <img src="/mixed/img/spinner.gif">
- </div>
+ <div id="spinner">
+ <img src="/mixed/img/spinner.gif">
+ </div>
- <div id="content"></div>
+ <div id="content"></div>
- <div id="orphan">
+ <div id="orphan">
+ <div class="container-fluid">
<h1>Yomichan Updated!</h1>
<p>
The Yomichan extension has been updated to a new version! In order to continue
viewing definitions on this page you must reload this tab or restart your browser.
</p>
</div>
-
- <script src="/mixed/lib/jquery-3.1.1.min.js"></script>
- <script src="/mixed/lib/wanakana.min.js"></script>
- <script src="/fg/js/util.js"></script>
- <script src="/mixed/js/display.js"></script>
- <script src="/fg/js/display-frame.js"></script>
</div>
+
+ <script src="/mixed/lib/jquery-3.1.1.min.js"></script>
+ <script src="/mixed/lib/wanakana.min.js"></script>
+ <script src="/fg/js/util.js"></script>
+ <script src="/mixed/js/util.js"></script>
+ <script src="/mixed/js/display.js"></script>
+ <script src="/fg/js/display-frame.js"></script>
</body>
</html>
diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js
index 8f15b1bc..41c2fb53 100644
--- a/ext/fg/js/display-frame.js
+++ b/ext/fg/js/display-frame.js
@@ -47,6 +47,10 @@ window.displayFrame = new class extends Display {
}
}
+ clearSearch() {
+ window.parent.postMessage('popupClose', '*');
+ }
+
showOrphaned() {
$('#content').hide();
$('#orphan').show();
@@ -54,20 +58,20 @@ window.displayFrame = new class extends Display {
onMessage(e) {
const handlers = new class {
- api_showTermDefs({definitions, options, context}) {
+ showTermDefs({definitions, options, context}) {
this.showTermDefs(definitions, options, context);
}
- api_showKanjiDefs({definitions, options, context}) {
+ showKanjiDefs({definitions, options, context}) {
this.showKanjiDefs(definitions, options, context);
}
- api_showOrphaned() {
+ showOrphaned() {
this.showOrphaned();
}
};
- const {action, params} = e.originalEvent.data, method = handlers[`api_${action}`];
+ const {action, params} = e.originalEvent.data, method = handlers[action];
if (typeof(method) === 'function') {
method.call(this, params);
}
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index fbe89ab8..036dc2d8 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -35,6 +35,7 @@ window.driver = new class {
window.addEventListener('mouseup', this.onMouseUp.bind(this));
window.addEventListener('mousemove', this.onMouseMove.bind(this));
window.addEventListener('resize', e => this.searchClear());
+ window.addEventListener('message', this.onFrameMessage.bind(this));
chrome.runtime.onMessage.addListener(this.onBgMessage.bind(this));
}).catch(this.handleError.bind(this));
}
@@ -45,14 +46,14 @@ window.driver = new class {
}
popupTimerClear() {
- if (this.popupTimer !== null) {
+ if (this.popupTimer) {
window.clearTimeout(this.popupTimer);
this.popupTimer = null;
}
}
onMouseOver(e) {
- if (e.target === this.popup.container && this.popuptimer !== null) {
+ if (e.target === this.popup.container && this.popupTimer) {
this.popupTimerClear();
}
}
@@ -101,14 +102,30 @@ window.driver = new class {
}
}
+ onFrameMessage(e) {
+ const handlers = {
+ popupClose: () => {
+ this.searchClear();
+ }
+ };
+
+ const handler = handlers[e.data];
+ if (handler) {
+ handler();
+ }
+ }
+
onBgMessage({action, params}, sender, callback) {
const handlers = new class {
- api_optionsSet(options) {
+ optionsSet(options) {
this.options = options;
+ if (!this.options.enable) {
+ this.searchClear();
+ }
}
};
- const method = handlers[`api_${action}`];
+ const method = handlers[action];
if (typeof(method) === 'function') {
method.call(this, params);
}
@@ -122,11 +139,11 @@ window.driver = new class {
}
const textSource = docRangeFromPoint(point, this.options.scanning.imposter);
- if (textSource === null || !textSource.containsPoint(point)) {
+ if (!textSource || !textSource.containsPoint(point)) {
return;
}
- if (this.lastTextSource !== null && this.lastTextSource.equals(textSource)) {
+ if (this.lastTextSource && this.lastTextSource.equals(textSource)) {
return;
}
@@ -200,7 +217,7 @@ window.driver = new class {
docImposterDestroy();
this.popup.hide();
- if (this.options.scanning.selectText && this.lastTextSource !== null) {
+ if (this.options.scanning.selectText && this.lastTextSource) {
this.lastTextSource.deselect();
}