Compare commits
2 Commits
5d9238a65a
...
459c8e6a57
| Author | SHA1 | Date | |
|---|---|---|---|
| 459c8e6a57 | |||
| 21b97bec6e |
@ -4,39 +4,48 @@ let TranslationFormHook = {
|
|||||||
this.el.addEventListener("keyup", this.keyupHandler.bind(this))
|
this.el.addEventListener("keyup", this.keyupHandler.bind(this))
|
||||||
this.title_input = this.el.querySelector("#translation-form_title")
|
this.title_input = this.el.querySelector("#translation-form_title")
|
||||||
this.tunit_editor = this.el.querySelector("#tunit-editor-content")
|
this.tunit_editor = this.el.querySelector("#tunit-editor-content")
|
||||||
|
this.save_edit_button = this.el.querySelector("#save-edit-button")
|
||||||
|
this.save_publish_button = this.el.querySelector("#save-publish-button")
|
||||||
},
|
},
|
||||||
keyupHandler(e) {
|
keyupHandler(e) {
|
||||||
var donothing = false
|
var push_event = true
|
||||||
var preaction = () => { }
|
var preaction = () => { }
|
||||||
var postaction = () => { }
|
var postaction = () => { }
|
||||||
var payload = {}
|
var payload = {}
|
||||||
if (e.altKey){
|
if (e.altKey){
|
||||||
if (e.key == "ArrowDown" || e.key == "n"){
|
if (e.ctrlKey){
|
||||||
preaction = () => { this.title_input.focus() }
|
if (e.key == "s"){
|
||||||
postaction = () => { this.tunit_editor.focus() }
|
this.save_edit_button.click()
|
||||||
var handler = "select_next_tunit"
|
} else if (e.key == "p"){
|
||||||
} else if (e.key == "ArrowUp" || e.key == "v"){
|
this.save_publish_button.click()
|
||||||
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 {
|
} else {
|
||||||
donothing = true
|
if (e.key == "ArrowDown" || e.key == "n"){
|
||||||
}
|
preaction = () => { this.title_input.focus() }
|
||||||
if (!donothing) {
|
postaction = () => { this.tunit_editor.focus() }
|
||||||
preaction.call()
|
var handler = "select_next_tunit"
|
||||||
this.pushEventTo(this.el, handler, payload, postaction)
|
} 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 {
|
||||||
|
push_event = false
|
||||||
|
}
|
||||||
|
if (push_event) {
|
||||||
|
preaction.call()
|
||||||
|
this.pushEventTo(this.el, handler, payload, postaction)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.info(["keyupHandler", e, this])
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user