summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-06-08 05:32:04 +0200
committerByron Jones <glob@mozilla.com>2015-06-08 05:32:04 +0200
commit9eaa85e9ec0d2c7d562d7e29e7ff027b18485982 (patch)
tree2f82097fe0aa679901ab76e37c72c2be91fecdf1 /extensions/BugModal
parent6c5fcca1d4fcef47bcbb7a3bf9fd2261ebeb9414 (diff)
downloadbugzilla-9eaa85e9ec0d2c7d562d7e29e7ff027b18485982.tar.gz
bugzilla-9eaa85e9ec0d2c7d562d7e29e7ff027b18485982.tar.xz
Bug 1171826: sort keywords by "start with" then "substring"
Diffstat (limited to 'extensions/BugModal')
-rw-r--r--extensions/BugModal/web/bug_modal.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js
index 38b19ac53..3d565e74f 100644
--- a/extensions/BugModal/web/bug_modal.js
+++ b/extensions/BugModal/web/bug_modal.js
@@ -325,7 +325,23 @@ $(function() {
keywords = data.keywords;
$('#keywords')
.devbridgeAutocomplete({
- lookup: keywords,
+ lookup: function(query, done) {
+ query = query.toLowerCase();
+ var matchStart =
+ $.grep(keywords, function(keyword) {
+ return keyword.toLowerCase().substr(0, query.length) === query;
+ });
+ var matchSub =
+ $.grep(keywords, function(keyword) {
+ return keyword.toLowerCase().indexOf(query) !== -1 &&
+ $.inArray(keyword, matchStart) === -1;
+ });
+ var suggestions =
+ $.map($.merge(matchStart, matchSub), function(suggestion) {
+ return { value: suggestion };
+ });
+ done({ suggestions: suggestions });
+ },
tabDisabled: true,
delimiter: /,\s*/,
minChars: 0,