aboutsummaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2018-03-12 13:04:37 -0700
committerAlex Yatskov <alex@foosoft.net>2018-03-12 13:04:37 -0700
commit68cdd7d85b741d34133ea04b95a4eb1e49553ace (patch)
treeb6041ae3bbd2c327e57ca0766d77f3e11c654066 /ext/fg
parentf0e9716aa5e763480cf6accceefcea4fa73bc149 (diff)
parent2470b6209a27ceea814a13d920a20683bacf09a6 (diff)
Merge branch 'dev'
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/float.js18
-rw-r--r--ext/fg/js/frontend.js1
-rw-r--r--ext/fg/js/popup.js6
3 files changed, 25 insertions, 0 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index ff50483d..1f08702d 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -20,6 +20,8 @@
class DisplayFloat extends Display {
constructor() {
super($('#spinner'), $('#definitions'));
+ this.autoPlayAudioTimer = null;
+
$(window).on('message', utilAsync(this.onMessage.bind(this)));
}
@@ -54,6 +56,10 @@ class DisplayFloat extends Display {
this.kanjiShow(definitions, options, context);
},
+ clearAutoPlayTimer: () => {
+ this.clearAutoPlayTimer();
+ },
+
orphaned: () => {
this.onOrphaned();
}
@@ -83,6 +89,18 @@ class DisplayFloat extends Display {
super.onKeyDown(e);
}
}
+
+ autoPlayAudio() {
+ this.clearAutoPlayTimer();
+ this.autoPlayAudioTimer = window.setTimeout(() => super.autoPlayAudio(), 400);
+ }
+
+ clearAutoPlayTimer() {
+ if (this.autoPlayAudioTimer) {
+ window.clearTimeout(this.autoPlayAudioTimer);
+ this.autoPlayAudioTimer = null;
+ }
+ }
}
window.yomichan_display = new DisplayFloat();
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 3a90b3ad..266f9640 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -254,6 +254,7 @@ class Frontend {
searchClear() {
docImposterDestroy();
this.popup.hide();
+ this.popup.clearAutoPlayTimer();
if (this.options.scanning.selectText && this.textSourceLast) {
this.textSourceLast.deselect();
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index d1009fe9..a17b184a 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -125,6 +125,12 @@ class Popup {
this.invokeApi('kanjiShow', {definitions, options, context});
}
+ clearAutoPlayTimer() {
+ if (this.injected) {
+ this.invokeApi('clearAutoPlayTimer');
+ }
+ }
+
invokeApi(action, params={}) {
this.container.contentWindow.postMessage({action, params}, '*');
}