Skip to content

Commit

Permalink
Using class-based show/hide instead of the jquery/prototype methods r…
Browse files Browse the repository at this point in the history
…esults in significant speed improvements for very, very large select boxes. (at least in modern web browsers)
  • Loading branch information
pfiller committed Sep 29, 2011
1 parent 953d3ba commit d4c7005
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions chosen/chosen.css
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,15 @@
padding: 0;
}
.chzn-container .chzn-results li {
display: none;
line-height: 80%;
padding: 7px 7px 8px;
margin: 0;
list-style: none;
}
.chzn-container .chzn-results .active-result {
cursor: pointer;
display: list-item;
}
.chzn-container .chzn-results .highlighted {
background: #3875d7;
Expand All @@ -254,6 +256,7 @@
}
.chzn-container .chzn-results .no-results {
background: #f4f4f4;
display: list-item;
}
.chzn-container .chzn-results .group-result {
cursor: default;
Expand Down
4 changes: 2 additions & 2 deletions chosen/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@
}
};
Chosen.prototype.result_activate = function(el) {
return el.addClass("active-result").show();
return el.addClass("active-result");
};
Chosen.prototype.result_deactivate = function(el) {
return el.removeClass("active-result").hide();
return el.removeClass("active-result");
};
Chosen.prototype.result_deselect = function(pos) {
var result, result_data;
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chosen/chosen.proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@
}
};
Chosen.prototype.result_activate = function(el) {
return el.addClassName("active-result").show();
return el.addClassName("active-result");
};
Chosen.prototype.result_deactivate = function(el) {
return el.removeClassName("active-result").hide();
return el.removeClassName("active-result");
};
Chosen.prototype.result_deselect = function(pos) {
var result, result_data;
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.proto.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,10 @@ class Chosen
this.search_field_scale()

result_activate: (el) ->
el.addClass("active-result").show()
el.addClass("active-result")

result_deactivate: (el) ->
el.removeClass("active-result").hide()
el.removeClass("active-result")

result_deselect: (pos) ->
result_data = @results_data[pos]
Expand Down
4 changes: 2 additions & 2 deletions coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ class Chosen
this.search_field_scale()

result_activate: (el) ->
el.addClassName("active-result").show()
el.addClassName("active-result")

result_deactivate: (el) ->
el.removeClassName("active-result").hide()
el.removeClassName("active-result")

result_deselect: (pos) ->
result_data = @results_data[pos]
Expand Down

0 comments on commit d4c7005

Please sign in to comment.