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