[FIX] point_of_sale: barcode scanner was not working in firefox due to usage of event.keyCode instead of event.which
bzr revid: fva@openerp.com-20130918153347-fy4nuvbm82ngfb8x
This commit is contained in:
parent
130afb812d
commit
6fb8cb4756
|
@ -437,10 +437,9 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
|
||||||
|
|
||||||
// The barcode readers acts as a keyboard, we catch all keyup events and try to find a
|
// The barcode readers acts as a keyboard, we catch all keyup events and try to find a
|
||||||
// barcode sequence in the typed keys, then act accordingly.
|
// barcode sequence in the typed keys, then act accordingly.
|
||||||
$('body').delegate('','keypress', function (e){
|
this.handler = function(e){
|
||||||
//console.log('keyup:'+String.fromCharCode(e.keyCode)+' '+e.keyCode,e);
|
|
||||||
//We only care about numbers
|
//We only care about numbers
|
||||||
if (e.keyCode >= 48 && e.keyCode < 58){
|
if (e.which >= 48 && e.which < 58){
|
||||||
|
|
||||||
// The barcode reader sends keystrokes with a specific interval.
|
// The barcode reader sends keystrokes with a specific interval.
|
||||||
// We look if the typed keys fit in the interval.
|
// We look if the typed keys fit in the interval.
|
||||||
|
@ -453,7 +452,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
|
||||||
timeStamp = new Date().getTime();
|
timeStamp = new Date().getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeNumbers.push(e.keyCode - 48);
|
codeNumbers.push(e.which - 48);
|
||||||
lastTimeStamp = new Date().getTime();
|
lastTimeStamp = new Date().getTime();
|
||||||
if (codeNumbers.length === 13) {
|
if (codeNumbers.length === 13) {
|
||||||
//We have found what seems to be a valid codebar
|
//We have found what seems to be a valid codebar
|
||||||
|
@ -464,12 +463,13 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
|
||||||
// NaN
|
// NaN
|
||||||
codeNumbers = [];
|
codeNumbers = [];
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
$('body').on('keypress', this.handler);
|
||||||
},
|
},
|
||||||
|
|
||||||
// stops catching keyboard events
|
// stops catching keyboard events
|
||||||
disconnect: function(){
|
disconnect: function(){
|
||||||
$('body').undelegate('', 'keyup')
|
$('body').off('keypress', this.handler)
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue