Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2016-12-10 23:14:21 +0300
committerClement Ho <ClemMakesApps@gmail.com>2017-01-10 01:01:14 +0300
commitcf3504ed602aa1b979f13a394192dde50b8cffed (patch)
tree9082e499a16b66ba4793437a5a1591d0a153612a /app/assets/javascripts/droplab
parenta7ecbf7c79a4789d10493ad3bdb9b02cfd124334 (diff)
Make ajax filter more consistent and only filter when typed
Diffstat (limited to 'app/assets/javascripts/droplab')
-rw-r--r--app/assets/javascripts/droplab/droplab_ajax_filter.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/assets/javascripts/droplab/droplab_ajax_filter.js b/app/assets/javascripts/droplab/droplab_ajax_filter.js
index 7603556d2ef..f2720a0371b 100644
--- a/app/assets/javascripts/droplab/droplab_ajax_filter.js
+++ b/app/assets/javascripts/droplab/droplab_ajax_filter.js
@@ -12,7 +12,7 @@ require('../window')(function(w){
this.debounceTriggerWrapper = this.debounceTrigger.bind(this);
this.hook.trigger.addEventListener('keydown.dl', this.debounceTriggerWrapper);
this.hook.trigger.addEventListener('focus', this.debounceTriggerWrapper);
- this.trigger();
+ this.trigger(true);
},
notLoading: function notLoading() {
@@ -22,6 +22,7 @@ require('../window')(function(w){
debounceTrigger: function debounceTrigger(e) {
var NON_CHARACTER_KEYS = [16, 17, 18, 20, 37, 38, 39, 40, 91, 93];
var invalidKeyPressed = NON_CHARACTER_KEYS.indexOf(e.detail.which || e.detail.keyCode) > -1;
+ var focusEvent = false;
if (invalidKeyPressed || this.loading) {
return;
}
@@ -30,10 +31,14 @@ require('../window')(function(w){
clearTimeout(this.timeout);
}
- this.timeout = setTimeout(this.trigger.bind(this), 200);
+ if (e.type === 'focus') {
+ focusEvent = true;
+ }
+
+ this.timeout = setTimeout(this.trigger.bind(this, focusEvent), 200);
},
- trigger: function trigger() {
+ trigger: function trigger(getEntireList = false) {
var config = this.hook.config.droplabAjaxFilter;
var searchValue = this.trigger.value;
@@ -45,6 +50,10 @@ require('../window')(function(w){
searchValue = config.searchValueFunction();
}
+ if (getEntireList) {
+ searchValue = '';
+ }
+
if (searchValue === config.searchKey) {
return this.list.show();
}