From 8f88c5acdd4985e89df13c182db0dee67da0fa21 Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Tue, 19 Jun 2018 16:47:21 +0200 Subject: Debounce search and reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- core/search/js/search.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core/search') diff --git a/core/search/js/search.js b/core/search/js/search.js index 60316fcc46f..20d7f0f915f 100644 --- a/core/search/js/search.js +++ b/core/search/js/search.js @@ -86,15 +86,15 @@ // Register input event document .getElementById('searchbox') - .addEventListener('input', this.search, true); + .addEventListener('input', _.debounce(this.search, 500), true); document .querySelector('form.searchbox') - .addEventListener('submit', this.search, true); + .addEventListener('submit', _.debounce(this.search, 500), true); // Register reset document .querySelector('form.searchbox') - .addEventListener('reset', this.reset, true); + .addEventListener('reset', _.debounce(this.reset, 500), true); // Register esc key shortcut reset if focused document.addEventListener('keyup', function(event) { @@ -108,7 +108,7 @@ document.getElementById('searchbox').value === '' ) { if (key === 'Escape' || key === 'Esc' || key === 27) { - self.reset(event); + _.debounce(self.reset, 500); } } }); -- cgit v1.2.3