Scaffold: setInterval -> activate listener
This commit is contained in:
parent
a40ab83b71
commit
dea9fc5e88
1 changed files with 2 additions and 17 deletions
|
@ -57,7 +57,6 @@ var Scaffold = new function () {
|
||||||
var _translatorsLoadedPromise;
|
var _translatorsLoadedPromise;
|
||||||
var _translatorProvider = null;
|
var _translatorProvider = null;
|
||||||
var _lastModifiedTime = 0;
|
var _lastModifiedTime = 0;
|
||||||
var _lastHadFocus = true;
|
|
||||||
|
|
||||||
var _editors = {};
|
var _editors = {};
|
||||||
|
|
||||||
|
@ -147,22 +146,8 @@ var Scaffold = new function () {
|
||||||
this.initCodeEditor();
|
this.initCodeEditor();
|
||||||
this.initTestsEditor();
|
this.initTestsEditor();
|
||||||
|
|
||||||
// Listen for Scaffold coming to the foreground and reload translators.
|
// Listen for Scaffold coming to the foreground and reload translators
|
||||||
// We can't just set a focus listener on the <window> because it'll fire
|
window.addEventListener('activate', () => this.reloadTranslators());
|
||||||
// when focus switches between the root window and any of the iframes.
|
|
||||||
setInterval(() => {
|
|
||||||
let hasFocus = document.hasFocus();
|
|
||||||
if (_lastHadFocus == hasFocus) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasFocus) {
|
|
||||||
this.reloadTranslators();
|
|
||||||
}
|
|
||||||
|
|
||||||
_lastHadFocus = hasFocus;
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
|
|
||||||
Scaffold_Translators.setLoadListener({
|
Scaffold_Translators.setLoadListener({
|
||||||
onLoadBegin: () => {
|
onLoadBegin: () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue