Skip to content

Commit

Permalink
Regenerate js files for performance fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kamal committed Aug 6, 2011
1 parent 4b60f9d commit 89cb2c6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 42 deletions.
28 changes: 10 additions & 18 deletions chosen/chosen.jquery.js
Expand Up @@ -458,10 +458,11 @@
}
};
Chosen.prototype.winnow_results = function() {
var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
var 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');
Expand Down Expand Up @@ -510,11 +511,15 @@
}
this.result_deactivate($("#" + result_id));
}
} else if (this.is_multiple && option.selected) {
if (regex.test(option.html)) {
selected = true;
}
}
}
}
if (results < 1 && searchText.length) {
return this.no_results(searchText);
return this.no_results(searchText, selected);
} else {
return this.winnow_results_set_highlight();
}
Expand All @@ -541,24 +546,11 @@
}
}
};
Chosen.prototype.no_results = function(terms) {
var no_results_html, option, regex, selected;
Chosen.prototype.no_results = function(terms, selected) {
var no_results_html;
no_results_html = $('<li class="no-results">No results match "<span></span>".</li>');
no_results_html.find("span").first().html(terms);
regex = new RegExp('^' + terms + '$', 'i');
selected = (function() {
var _i, _len, _ref, _results;
_ref = this.results_data;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
if (regex.test(option.value) && option.selected) {
_results.push(option);
}
}
return _results;
}).call(this);
if (selected.length === 0) {
if (!selected) {
no_results_html.append(' <a href="javascript:void(0);" class="option-add">Add this item</a>');
no_results_html.find("a.option-add").bind("click", __bind(function(evt) {
return this.select_add_option(terms);
Expand Down

0 comments on commit 89cb2c6

Please sign in to comment.