Mercurial > kallithea
changeset 6133:cc18e56220a2
compare: improve select2 performance with many branches
Like elsewhere for pure branch selectors.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 28 Jul 2016 16:34:49 +0200 |
parents | 190cb30841de |
children | 8bd957e6cccb |
files | kallithea/templates/compare/compare_diff.html |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/templates/compare/compare_diff.html Thu Jul 28 16:34:49 2016 +0200 +++ b/kallithea/templates/compare/compare_diff.html Thu Jul 28 16:34:49 2016 +0200 @@ -108,20 +108,25 @@ return '{0}@{1}'.format(repo_name, obj.text); }, dropdownAutoWidth: true, + maxResults: 50, query: function(query){ var key = cache_key; var cached = cache[key] ; if(cached) { var data = {results: []}; + var queryLower = query.term.toLowerCase(); //filter results $.each(cached.results, function(){ var section = this.text; var children = []; $.each(this.children, function(){ - if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){ + if(children.length < 50 ? + ((queryLower.length == 0) || (this.text.toLowerCase().indexOf(queryLower) >= 0)) : + ((queryLower.length != 0) && (this.text.toLowerCase().indexOf(queryLower) == 0))) { children.push(this); } }); + children = branchSort(children, undefined, query) data.results.push({'text': section, 'children': children}); }); //push the typed in changeset