Permalink
Browse files

Show add item link even for prefix matches

  • Loading branch information...
1 parent 89cb2c6 commit e9858fd50eee62c502a03572cfaf19af98e3e4c8 @kamal kamal committed Aug 8, 2011
View
@@ -11,8 +11,7 @@
/*
Chosen source: generate output using 'cake build'
Copyright (c) 2011 by Harvest
- */
- var $, Chosen, get_side_border_padding, root;
+ */ var $, Chosen, get_side_border_padding, root;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
root = this;
$ = jQuery;
@@ -458,14 +457,15 @@
}
};
Chosen.prototype.winnow_results = function() {
- var found, option, part, parts, regex, result_id, results, searchText, selected, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
+ var exactRegex, found, option, part, parts, regex, result_id, results, searchText, selected, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
startTime = new Date();
this.no_results_clear();
results = 0;
selected = false;
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
+ exactRegex = new RegExp('^' + searchText + '$', 'i');
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
@@ -512,7 +512,7 @@
this.result_deactivate($("#" + result_id));
}
} else if (this.is_multiple && option.selected) {
- if (regex.test(option.html)) {
+ if (exactRegex.test(option.html)) {
selected = true;
}
}
Oops, something went wrong.

0 comments on commit e9858fd

Please sign in to comment.