From f851728d0f73620208ca540fa8ab50b8155c9e72 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 1 May 2017 18:53:56 +0200 Subject: [PATCH] [ADD] search only a few milliseconds after a keypress --- .../src/js/web_search_autocomplete_prefetch.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index 1ff401ef..4ae89e9f 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -84,6 +84,7 @@ openerp.web_search_autocomplete_prefetch = function(instance) }); instance.web.search.AutoComplete.include({ + keypress_timeout: 200, select_item: function() { if(!this.current_result) @@ -92,5 +93,18 @@ openerp.web_search_autocomplete_prefetch = function(instance) } return this._super.apply(this, arguments); }, + initiate_search: function(query) + { + var self = this, + _super = this._super, + last_timeout = null; + this.last_timeout = last_timeout = window.setTimeout(function() + { + if(self.last_timeout == last_timeout) + { + _super.apply(self, [query]); + } + }, this.keypress_timeout) + }, }); }