[FIX] point_of_sale : Virtual keyboard and product search fixed.
The pos search uses keypress instead of keydown event. The virtual keyboard has thus been fixed to trigger the same kind of event. Using keypress instead of keyup also made the search behaviour erratic. This is fixed with the appropriate use of a timeout. Finally a keydown listener is added to update the search after a backspace or delete.
This commit is contained in:
@@ -62,7 +62,7 @@ var OnscreenKeyboardWidget = Widget.extend({
|
||||
// Write a character to the input zone
|
||||
writeCharacter: function(character){
|
||||
var input = this.$target[0];
|
||||
input.dispatchEvent(this.generateEvent('keydown',{char: character}));
|
||||
input.dispatchEvent(this.generateEvent('keypress',{char: character}));
|
||||
if(character !== '\n'){
|
||||
input.value += character;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ var OnscreenKeyboardWidget = Widget.extend({
|
||||
// Removes the last character from the input zone.
|
||||
deleteCharacter: function(){
|
||||
var input = this.$target[0];
|
||||
input.dispatchEvent(this.generateEvent('keydown',{code: 8}));
|
||||
input.dispatchEvent(this.generateEvent('keypress',{code: 8}));
|
||||
input.value = input.value.substr(0, input.value.length -1);
|
||||
input.dispatchEvent(this.generateEvent('keyup',{code: 8}));
|
||||
},
|
||||
@@ -81,7 +81,7 @@ var OnscreenKeyboardWidget = Widget.extend({
|
||||
deleteAllCharacters: function(){
|
||||
var input = this.$target[0];
|
||||
if(input.value){
|
||||
input.dispatchEvent(this.generateEvent('keydown',{code: 8}));
|
||||
input.dispatchEvent(this.generateEvent('keypress',{code: 8}));
|
||||
input.value = "";
|
||||
input.dispatchEvent(this.generateEvent('keyup',{code: 8}));
|
||||
}
|
||||
|
||||
@@ -594,13 +594,15 @@ var ProductCategoriesWidget = PosBaseWidget.extend({
|
||||
|
||||
var search_timeout = null;
|
||||
this.search_handler = function(event){
|
||||
clearTimeout(search_timeout);
|
||||
if(event.type == "keypress" || event.keyCode === 46 || event.keyCode === 8){
|
||||
clearTimeout(search_timeout);
|
||||
|
||||
var query = this.value;
|
||||
var searchbox = this;
|
||||
|
||||
search_timeout = setTimeout(function(){
|
||||
self.perform_search(self.category, query, event.which === 13);
|
||||
},70);
|
||||
search_timeout = setTimeout(function(){
|
||||
self.perform_search(self.category, searchbox.value, event.which === 13);
|
||||
},70);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
@@ -701,6 +703,8 @@ var ProductCategoriesWidget = PosBaseWidget.extend({
|
||||
|
||||
this.el.querySelector('.searchbox input').addEventListener('keypress',this.search_handler);
|
||||
|
||||
this.el.querySelector('.searchbox input').addEventListener('keydown',this.search_handler);
|
||||
|
||||
this.el.querySelector('.search-clear').addEventListener('click',this.clear_search_handler);
|
||||
|
||||
if(this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard){
|
||||
|
||||
Reference in New Issue
Block a user