Compare commits

..

2 Commits

Author SHA1 Message Date
459c8e6a57 Add shortcuts for saving 2023-03-05 23:13:58 +01:00
21b97bec6e Sanitize variable name 2023-03-05 22:53:52 +01:00

View File

@ -4,13 +4,22 @@ 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.ctrlKey){
if (e.key == "s"){
this.save_edit_button.click()
} else if (e.key == "p"){
this.save_publish_button.click()
}
} else {
if (e.key == "ArrowDown" || e.key == "n"){ if (e.key == "ArrowDown" || e.key == "n"){
preaction = () => { this.title_input.focus() } preaction = () => { this.title_input.focus() }
postaction = () => { this.tunit_editor.focus() } postaction = () => { this.tunit_editor.focus() }
@ -29,14 +38,14 @@ let TranslationFormHook = {
var handler = "tunit_status" var handler = "tunit_status"
payload = {status: "done"} payload = {status: "done"}
} else { } else {
donothing = true push_event = false
} }
if (!donothing) { if (push_event) {
preaction.call() preaction.call()
this.pushEventTo(this.el, handler, payload, postaction) this.pushEventTo(this.el, handler, payload, postaction)
} }
} }
// console.info(["keyupHandler", e, this]) }
}, },
} }