44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
let TranslationFormHook = {
|
|
|
|
mounted() {
|
|
this.el.addEventListener("keyup", this.keyupHandler.bind(this))
|
|
this.title_input = this.el.querySelector("#translation-form_title")
|
|
this.tunit_editor = this.el.querySelector("#tunit-editor-content")
|
|
},
|
|
keyupHandler(e) {
|
|
var donothing = false
|
|
var preaction = () => { }
|
|
var postaction = () => { }
|
|
var payload = {}
|
|
if (e.altKey){
|
|
if (e.key == "ArrowDown" || e.key == "n"){
|
|
preaction = () => { this.title_input.focus() }
|
|
postaction = () => { this.tunit_editor.focus() }
|
|
var handler = "select_next_tunit"
|
|
} else if (e.key == "ArrowUp" || e.key == "v"){
|
|
preaction = () => { this.title_input.focus() }
|
|
postaction = () => { this.tunit_editor.focus() }
|
|
var handler = "select_previous_tunit"
|
|
} else if (e.key == "u") {
|
|
var handler = "tunit_status"
|
|
payload = {status: "untranslated"}
|
|
} else if (e.key == "p") {
|
|
var handler = "tunit_status"
|
|
payload = {status: "passable"}
|
|
} else if (e.key == "o") {
|
|
var handler = "tunit_status"
|
|
payload = {status: "done"}
|
|
} else {
|
|
donothing = true
|
|
}
|
|
if (!donothing) {
|
|
preaction.call()
|
|
this.pushEventTo(this.el, handler, payload, postaction)
|
|
}
|
|
}
|
|
// console.info(["keyupHandler", e, this])
|
|
},
|
|
}
|
|
|
|
export {TranslationFormHook}
|