cleanup, firefox scrolling

This commit is contained in:
Alex Yatskov 2017-03-25 16:45:43 -07:00
parent bc2bf51a07
commit 218db0771f
4 changed files with 16 additions and 16 deletions

View File

@ -192,32 +192,32 @@ window.yomichan = new class {
onMessage(request, sender, callback) { onMessage(request, sender, callback) {
const handlers = new class { const handlers = new class {
api_optionsGet({callback}) { optionsGet({callback}) {
promiseCallback(optionsLoad(), callback); promiseCallback(optionsLoad(), callback);
} }
api_kanjiFind({text, callback}) { kanjiFind({text, callback}) {
promiseCallback(this.kanjiFind(text), callback); promiseCallback(this.kanjiFind(text), callback);
} }
api_termsFind({text, callback}) { termsFind({text, callback}) {
promiseCallback(this.termsFind(text), callback); promiseCallback(this.termsFind(text), callback);
} }
api_templateRender({template, data, callback}) { templateRender({template, data, callback}) {
promiseCallback(this.templateRender(template, data), callback); promiseCallback(this.templateRender(template, data), callback);
} }
api_definitionAdd({definition, mode, callback}) { definitionAdd({definition, mode, callback}) {
promiseCallback(this.definitionAdd(definition, mode), callback); promiseCallback(this.definitionAdd(definition, mode), callback);
} }
api_definitionsAddable({definitions, modes, callback}) { definitionsAddable({definitions, modes, callback}) {
promiseCallback(this.definitionsAddable(definitions, modes), callback); promiseCallback(this.definitionsAddable(definitions, modes), callback);
} }
}; };
const {action, params} = request, method = handlers[`api_${action}`]; const {action, params} = request, method = handlers[action];
if (typeof(method) === 'function') { if (typeof(method) === 'function') {
params.callback = callback; params.callback = callback;
method.call(this, params); method.call(this, params);

View File

@ -58,20 +58,20 @@ window.displayFrame = new class extends Display {
onMessage(e) { onMessage(e) {
const handlers = new class { const handlers = new class {
api_showTermDefs({definitions, options, context}) { showTermDefs({definitions, options, context}) {
this.showTermDefs(definitions, options, context); this.showTermDefs(definitions, options, context);
} }
api_showKanjiDefs({definitions, options, context}) { showKanjiDefs({definitions, options, context}) {
this.showKanjiDefs(definitions, options, context); this.showKanjiDefs(definitions, options, context);
} }
api_showOrphaned() { showOrphaned() {
this.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') { if (typeof(method) === 'function') {
method.call(this, params); method.call(this, params);
} }

View File

@ -117,7 +117,7 @@ window.driver = new class {
onBgMessage({action, params}, sender, callback) { onBgMessage({action, params}, sender, callback) {
const handlers = new class { const handlers = new class {
api_optionsSet(options) { optionsSet(options) {
this.options = options; this.options = options;
if (!this.options.enable) { if (!this.options.enable) {
this.searchClear(); this.searchClear();
@ -125,7 +125,7 @@ window.driver = new class {
} }
}; };
const method = handlers[`api_${action}`]; const method = handlers[action];
if (typeof(method) === 'function') { if (typeof(method) === 'function') {
method.call(this, params); method.call(this, params);
} }

View File

@ -149,14 +149,14 @@ class Display {
$('.current').hide().eq(index).show(); $('.current').hide().eq(index).show();
const body = $('body').stop(); const container = $('html,body').stop();
const entry = $('.entry').eq(index); const entry = $('.entry').eq(index);
const target = index === 0 ? 0 : entry.offset().top; const target = index === 0 ? 0 : entry.offset().top;
if (smooth) { if (smooth) {
body.animate({scrollTop: target}, 200); container.animate({scrollTop: target}, 200);
} else { } else {
body.scrollTop(target); container.scrollTop(target);
} }
this.index = index; this.index = index;