diff --git a/kallithea/public/js/select2/select2.js b/kallithea/public/js/select2/select2.js --- a/kallithea/public/js/select2/select2.js +++ b/kallithea/public/js/select2/select2.js @@ -1097,7 +1097,13 @@ the specific language governing permissi // collect the created nodes for bulk append var nodes = []; - for (i = 0, l = results.length; i < l; i = i + 1) { + + // Kallithea customization: maxResults + l = results.length; + if (query.term.length == 0 && l > opts.maxResults) { + l = opts.maxResults; + } + for (i = 0; i < l; i = i + 1) { result=results[i]; @@ -1138,6 +1144,10 @@ the specific language governing permissi nodes.push(node[0]); } + if (results.length >= opts.maxResults) { + nodes.push($('
  • Too many matches found
  • ')); + } + // bulk append the created nodes container.append(nodes); liveRegion.text(opts.formatMatches(results.length)); @@ -1161,16 +1171,25 @@ the specific language governing permissi if (select) { opts.query = this.bind(function (query) { + // Kallithea customization: maxResults var data = { results: [], more: false }, term = query.term, - children, placeholderOption, process; + children, placeholderOption, process, + maxResults = opts.maxResults || -1, + termLower = term.toLowerCase(); process=function(element, collection) { var group; if (element.is("option")) { + if (collection.length < maxResults) { if (query.matcher(term, element.text(), element)) { collection.push(self.optionToData(element)); } + } else { + if (element.text().toLowerCase().indexOf(termLower) == 0) { + collection.push(self.optionToData(element)); + } + } } else if (element.is("optgroup")) { group=self.optionToData(element); element.children().each2(function(i, elm) { process(elm, group.children); }); diff --git a/kallithea/templates/changelog/changelog.html b/kallithea/templates/changelog/changelog.html --- a/kallithea/templates/changelog/changelog.html +++ b/kallithea/templates/changelog/changelog.html @@ -308,7 +308,7 @@ ${self.repo_context_bar('changelog', c.f // change branch filter $("#branch_filter").select2({ dropdownAutoWidth: true, - minimumInputLength: 1, + maxResults: 50, sortResults: branchSort }); diff --git a/kallithea/templates/files/files.html b/kallithea/templates/files/files.html --- a/kallithea/templates/files/files.html +++ b/kallithea/templates/files/files.html @@ -233,7 +233,7 @@ $(document).ready(function(){ // change branch filter $("#branch_selector").select2({ dropdownAutoWidth: true, - minimumInputLength: 1, + maxResults: 50, sortResults: branchSort }); diff --git a/kallithea/templates/pullrequests/pullrequest.html b/kallithea/templates/pullrequests/pullrequest.html --- a/kallithea/templates/pullrequests/pullrequest.html +++ b/kallithea/templates/pullrequests/pullrequest.html @@ -202,6 +202,7 @@ ${self.repo_context_bar('showpullrequest $("#org_ref").select2({ dropdownAutoWidth: true, + maxResults: 50, sortResults: branchSort }); $("#org_ref").on("change", function(e){ @@ -217,6 +218,7 @@ ${self.repo_context_bar('showpullrequest $("#other_ref").select2({ dropdownAutoWidth: true, + maxResults: 50, sortResults: branchSort }); $("#other_ref").on("change", function(e){