fix escaping focus

fix #67
This commit is contained in:
s72785 2015-07-21 21:22:06 +02:00
parent 802f9d775f
commit 9d9c80dd6a
1 changed files with 5 additions and 4 deletions

View File

@ -20,16 +20,17 @@ function hideBarcode() {
function barcodeKeyPress(event) { function barcodeKeyPress(event) {
var key = String.fromCharCode(event.charCode) var key = String.fromCharCode(event.charCode)
var input = document.getElementById('crement') var input = document.getElementById('crement')
if ( input ) { var inputcount = document.querySelectorAll('[type="text"]').length + document.querySelectorAll('[type="number"]').length
if ( input && inputcount == 1 ) {
input.focus() input.focus()
} }
var focused = document.activeElement var focused = document.activeElement
if (! focused || focused == document.body) { if ( !focused || focused == document.body ) {
focused = null focused = null
} else if (document.querySelector) { } else if ( document.querySelector ) {
focused = document.querySelector(":focus") focused = document.querySelector(":focus")
} }
if ( focused == null || focused.tagName != "INPUT" ) { if ( inputcount <= 1 && ( focused == null || focused.tagName != "INPUT" ) ) {
if ( event.keyCode === 13 ) { if ( event.keyCode === 13 ) {
var input = document.getElementById('barcodeInput') var input = document.getElementById('barcodeInput')
if (input && barcodeBuf.length > 0) { if (input && barcodeBuf.length > 0) {