|
|
@ -117,7 +117,7 @@ function pos_keyboard_widgets(instance, module){ |
|
|
|
|
|
|
|
//cancel return to the previous page when press backspace
|
|
|
|
var rx = /INPUT|SELECT|TEXTAREA/i; |
|
|
|
$(document).bind("keydown keypress", function(e){ |
|
|
|
$(document).on("keydown keypress", function(e){ |
|
|
|
if( e.which == 8 ){ // 8 == backspace
|
|
|
|
if(!rx.test(e.target.tagName) || e.target.disabled || e.target.readOnly ){ |
|
|
|
e.preventDefault(); |
|
|
@ -126,18 +126,21 @@ function pos_keyboard_widgets(instance, module){ |
|
|
|
}); |
|
|
|
|
|
|
|
//usb keyboard keyup event
|
|
|
|
$('body').delegate('','keyup', function (e){ |
|
|
|
var ok = false; |
|
|
|
var timeStamp = 0; |
|
|
|
$('body').on('keyup', '', function (e){ |
|
|
|
var statusHandler = !rx.test(e.target.tagName) || |
|
|
|
e.target.disabled || e.target.readOnly; |
|
|
|
if (statusHandler){ |
|
|
|
var ok =false; |
|
|
|
var is_number = false; |
|
|
|
var type = self.type; |
|
|
|
var buttonMode = self.pos.pos_widget.numpad.modeButton |
|
|
|
token = e.keyCode; |
|
|
|
var buttonMode = self.pos.pos_widget.numpad.modeButton; |
|
|
|
var token = e.keyCode; |
|
|
|
if ((token >= 96 && token <= 105 || token == 110) || |
|
|
|
(token >= 48 && token <= 57 || token == 190)) { |
|
|
|
self.data.type = type.numchar; |
|
|
|
self.data.val = kc_lookup[token]; |
|
|
|
is_number = true; |
|
|
|
ok = true; |
|
|
|
} |
|
|
|
else if (token == KC_PLU || token == KC_PLU_1) { |
|
|
@ -146,7 +149,7 @@ function pos_keyboard_widgets(instance, module){ |
|
|
|
} |
|
|
|
else if (token == KC_QTY || token == KC_QTY_1) { |
|
|
|
self.data.type = type.bmode; |
|
|
|
self.data.val = buttonMode.qty |
|
|
|
self.data.val = buttonMode.qty; |
|
|
|
ok = true; |
|
|
|
} |
|
|
|
else if (token == KC_AMT || token == KC_AMT_1) { |
|
|
@ -161,18 +164,28 @@ function pos_keyboard_widgets(instance, module){ |
|
|
|
} |
|
|
|
else if (token == KC_BACKSPACE) { |
|
|
|
self.data.type = type.backspace; |
|
|
|
self.action_callback(self.data); |
|
|
|
ok = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (is_number) { |
|
|
|
if (timeStamp + 50 > new Date().getTime()) { |
|
|
|
ok = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
timeStamp = new Date().getTime(); |
|
|
|
|
|
|
|
setTimeout(function(){ |
|
|
|
if (ok) {self.action_callback(self.data);} |
|
|
|
}, 50); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// stops catching keyboard events
|
|
|
|
disconnect: function(){ |
|
|
|
$('body').undelegate('', 'keyup') |
|
|
|
}, |
|
|
|
$('body').off('keyup', '') |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -183,4 +196,4 @@ function pos_keyboard_widgets(instance, module){ |
|
|
|
var module = instance.point_of_sale; |
|
|
|
pos_keyboard_widgets(instance, module); |
|
|
|
} |
|
|
|
})() |
|
|
|
})(); |