js/dom: fix little quirks
This commit is contained in:
parent
7a6ebd461b
commit
fd7b4e1666
2 changed files with 12 additions and 3 deletions
|
|
@ -49,18 +49,20 @@ module.exports = {
|
|||
|
||||
close() {
|
||||
if (!this.state) return
|
||||
this.state = 0
|
||||
|
||||
if (this.escKey) document.removeEventListener('keydown', this.escKeyHandler)
|
||||
if (this.enterKey) document.removeEventListener('keydown', this.enterKeyHandler)
|
||||
document.body.removeChild(this.html)
|
||||
this.state = 0
|
||||
}
|
||||
|
||||
open() {
|
||||
if (this.state) return
|
||||
this.state = 1
|
||||
|
||||
if (this.escKey) document.addEventListener('keydown', this.escKeyHandler)
|
||||
if (this.enterKey) document.addEventListener('keydown', this.enterKeyHandler)
|
||||
document.body.appendChild(this.html)
|
||||
this.state = 1
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ module.exports = class Input extends _canvas_base {
|
|||
|
||||
this.value = ''
|
||||
this.stringValue = ''
|
||||
this.focused = false
|
||||
|
||||
if (this.getProp('vertical')) {
|
||||
this.widget.classList.add('vertical')
|
||||
|
|
@ -83,6 +84,9 @@ module.exports = class Input extends _canvas_base {
|
|||
|
||||
focus() {
|
||||
|
||||
if (this.focused) return
|
||||
this.focused = true
|
||||
|
||||
this.canvas.setAttribute('tabindex','-1')
|
||||
this.input.value = this.stringValue
|
||||
this.widget.insertBefore(this.input, this.canvas)
|
||||
|
|
@ -92,10 +96,13 @@ module.exports = class Input extends _canvas_base {
|
|||
|
||||
blur(change=true) {
|
||||
|
||||
if (!this.focused) return
|
||||
this.focused = false
|
||||
|
||||
if (change) this.inputChange()
|
||||
|
||||
this.canvas.setAttribute('tabindex','0')
|
||||
if (this.input.parentNode == this.widget) this.widget.removeChild(input)
|
||||
this.widget.removeChild(this.input)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue