diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-08-13 16:11:51 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-08-13 16:11:51 -0700 |
commit | aac2a58b5f821c6f90c95bb19f3b0a755d5e1739 (patch) | |
tree | d6c4b503f6a8daeabfa15f757866ef18ef4c5c64 /ext/fg/js/display-frame.js | |
parent | 7fbe2ddaf33bad05fb26aec759806e0f6ae250d2 (diff) |
wip
Diffstat (limited to 'ext/fg/js/display-frame.js')
-rw-r--r-- | ext/fg/js/display-frame.js | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js index 09bd9255..5ea376c2 100644 --- a/ext/fg/js/display-frame.js +++ b/ext/fg/js/display-frame.js @@ -17,65 +17,45 @@ */ -window.displayFrame = new class extends Display { +window.yomichan_frame = new class extends Display { constructor() { super($('#spinner'), $('#content')); $(window).on('message', this.onMessage.bind(this)); } - definitionAdd(definition, mode) { - return apiDefinitionAdd(definition, mode); - } - - definitionsAddable(definitions, modes) { - return apiDefinitionsAddable(definitions, modes); - } - - noteView(noteId) { - return apiNoteView(noteId); - } - - templateRender(template, data) { - return apiTemplateRender(template, data); - } - - kanjiFind(character) { - return apiKanjiFind(character); - } - - handleError(error) { - if (window.yomichanOrphaned) { - this.showOrphaned(); + onError(error) { + if (window.yomichan_orphaned) { + this.onOrphaned(); } else { window.alert(`Error: ${error}`); } } - clearSearch() { - window.parent.postMessage('popupClose', '*'); + onOrphaned() { + $('#definitions').hide(); + $('#error-orphaned').show(); } - selectionCopy() { - window.parent.postMessage('selectionCopy', '*'); + onSearchClear() { + window.parent.postMessage('popupClose', '*'); } - showOrphaned() { - $('#content').hide(); - $('#orphan').show(); + onSelectionCopy() { + window.parent.postMessage('selectionCopy', '*'); } onMessage(e) { const handlers = { - showTermDefs: ({definitions, options, context}) => { - this.showTermDefs(definitions, options, context); + termsShow: ({definitions, options, context}) => { + this.termsShow(definitions, options, context); }, - showKanjiDefs: ({definitions, options, context}) => { - this.showKanjiDefs(definitions, options, context); + kanjiShow: ({definitions, options, context}) => { + this.kanjiShow(definitions, options, context); }, - showOrphaned: () => { - this.showOrphaned(); + orphaned: () => { + this.onOrphaned(); } }; @@ -89,8 +69,8 @@ window.displayFrame = new class extends Display { onKeyDown(e) { const handlers = { 67: /* c */ () => { - if (e.ctrlKey && window.getSelection().toString() === '') { - this.selectionCopy(); + if (e.ctrlKey && !window.getSelection().toString()) { + this.onSelectionCopy(); return true; } } |