Browse Source

CustomCategory: buttons 'Apply & keep editing', 'Apply & close'

master
parent
commit
842ed05521
  1. 3
      lang/en.json
  2. 25
      src/customCategory.js

3
lang/en.json

@ -10,7 +10,8 @@
"closed": "closed",
"default": "default",
"download": "Download",
"apply": "Apply",
"apply-keep": "Apply & keep editing",
"apply-close": "Apply & close",
"tip-tutorial": "Check out the [Tutorial]",
"customCategory:header": "Custom categories",
"customCategory:clone": "Clone as custom category",

25
src/customCategory.js

@ -114,13 +114,16 @@ class CustomCategoryEditor {
const input = document.createElement('input')
input.type = 'submit'
input.value = lang('apply')
input.value = lang('apply-keep')
controls.appendChild(input)
const inputClose = document.createElement('input')
inputClose.type = 'button'
inputClose.value = lang('close')
inputClose.onclick = () => this.window.close()
inputClose.value = lang('apply-close')
inputClose.onclick = () => {
this.submit()
this.window.close()
}
controls.appendChild(inputClose)
const icons = document.createElement('div')
@ -143,18 +146,22 @@ class CustomCategoryEditor {
controls.appendChild(tutorial)
input.onclick = (e) => {
const err = customCategoryTest(this.textarea.value)
if (err) {
return global.alert(err)
}
this.applyContent(this.textarea.value)
this.submit()
e.preventDefault()
}
this.window.show()
}
submit () {
const err = customCategoryTest(this.textarea.value)
if (err) {
return global.alert(err)
}
this.applyContent(this.textarea.value)
}
applyContent (content) {
this.content = content
this.repository.saveCategory(this.content, {}, () => {})

Loading…
Cancel
Save