Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix my stupid sloppiness that led to a Prototype scrolling bug. #1301

Merged
merged 2 commits into from
Jun 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Chosen extends AbstractChosen
visible_top = @search_results.scrollTop
visible_bottom = maxHeight + visible_top

high_top = @result_highlight.positionedOffset().top + @search_results.scrollTop
high_top = @result_highlight.positionedOffset().top
high_bottom = high_top + @result_highlight.getHeight()

if high_bottom >= visible_bottom
Expand Down
33 changes: 33 additions & 0 deletions public/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

SelectParser.prototype.add_group = function(group) {
var group_position, option, _i, _len, _ref, _results;

group_position = this.parsed.length;
this.parsed.push({
array_index: group_position,
Expand Down Expand Up @@ -78,6 +79,7 @@

SelectParser.select_to_array = function(select) {
var child, parser, _i, _len, _ref;

parser = new SelectParser();
_ref = select.childNodes;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
Expand Down Expand Up @@ -114,6 +116,7 @@

AbstractChosen.prototype.set_default_values = function() {
var _this = this;

this.click_test_action = function(evt) {
return _this.test_active_click(evt);
};
Expand Down Expand Up @@ -156,6 +159,7 @@

AbstractChosen.prototype.input_focus = function(evt) {
var _this = this;

if (this.is_multiple) {
if (!this.active_field) {
return setTimeout((function() {
Expand All @@ -171,6 +175,7 @@

AbstractChosen.prototype.input_blur = function(evt) {
var _this = this;

if (!this.mouse_on_container) {
this.active_field = false;
return setTimeout((function() {
Expand All @@ -181,6 +186,7 @@

AbstractChosen.prototype.result_add_option = function(option) {
var classes, style;

option.dom_id = this.container_id + "_o_" + option.array_index;
classes = [];
if (!option.disabled && !(option.selected && this.is_multiple)) {
Expand Down Expand Up @@ -230,6 +236,7 @@

AbstractChosen.prototype.choices_count = function() {
var option, _i, _len, _ref;

if (this.selected_option_count != null) {
return this.selected_option_count;
}
Expand All @@ -253,6 +260,7 @@

AbstractChosen.prototype.keyup_checker = function(evt) {
var stroke, _ref;

stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
switch (stroke) {
Expand Down Expand Up @@ -289,13 +297,15 @@

AbstractChosen.prototype.generate_field_id = function() {
var new_id;

new_id = this.generate_random_id();
this.form_field.id = new_id;
return new_id;
};

AbstractChosen.prototype.generate_random_char = function() {
var chars, newchar, rand;

chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
rand = Math.floor(Math.random() * chars.length);
return newchar = chars.substring(rand, rand + 1);
Expand All @@ -311,6 +321,7 @@

AbstractChosen.browser_is_supported = function() {
var _ref;

if (window.navigator.appName === "Microsoft Internet Explorer") {
return (null !== (_ref = document.documentMode) && _ref >= 8);
}
Expand Down Expand Up @@ -347,6 +358,7 @@
}
return this.each(function(input_field) {
var $this;

$this = $(this);
if (!$this.hasClass("chzn-done")) {
return $this.data('chosen', new Chosen(this, options));
Expand Down Expand Up @@ -375,6 +387,7 @@

Chosen.prototype.set_up_html = function() {
var container_classes, container_props;

this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id();
this.container_id += "_chzn";
container_classes = ["chzn-container"];
Expand Down Expand Up @@ -420,6 +433,7 @@

Chosen.prototype.register_observers = function() {
var _this = this;

this.container.mousedown(function(evt) {
_this.container_mousedown(evt);
});
Expand Down Expand Up @@ -523,6 +537,7 @@

Chosen.prototype.search_results_mousewheel = function(evt) {
var delta, _ref1, _ref2;

delta = -((_ref1 = evt.originalEvent) != null ? _ref1.wheelDelta : void 0) || ((_ref2 = evt.originialEvent) != null ? _ref2.detail : void 0);
if (delta != null) {
evt.preventDefault();
Expand Down Expand Up @@ -566,6 +581,7 @@

Chosen.prototype.results_build = function() {
var content, data, _i, _len, _ref1;

this.parsing = true;
this.selected_option_count = null;
this.results_data = root.SelectParser.select_to_array(this.form_field);
Expand Down Expand Up @@ -613,6 +629,7 @@

Chosen.prototype.result_do_highlight = function(el) {
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;

if (el.length) {
this.result_clear_highlight();
this.result_highlight = el;
Expand Down Expand Up @@ -667,6 +684,7 @@

Chosen.prototype.set_tab_index = function(el) {
var ti;

if (this.form_field_jq.attr("tabindex")) {
ti = this.form_field_jq.attr("tabindex");
this.form_field_jq.attr("tabindex", -1);
Expand All @@ -676,6 +694,7 @@

Chosen.prototype.set_label_behavior = function() {
var _this = this;

this.form_field_label = this.form_field_jq.parents("label");
if (!this.form_field_label.length && this.form_field.id.length) {
this.form_field_label = $("label[for='" + this.form_field.id + "']");
Expand Down Expand Up @@ -703,6 +722,7 @@

Chosen.prototype.search_results_mouseup = function(evt) {
var target;

target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target.length) {
this.result_highlight = target;
Expand All @@ -713,6 +733,7 @@

Chosen.prototype.search_results_mouseover = function(evt) {
var target;

target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target) {
return this.result_do_highlight(target);
Expand All @@ -728,6 +749,7 @@
Chosen.prototype.choice_build = function(item) {
var choice, close_link,
_this = this;

choice = $('<li />', {
"class": "search-choice"
}).html("<span>" + item.html + "</span>");
Expand Down Expand Up @@ -788,6 +810,7 @@

Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position;

if (this.result_highlight) {
high = this.result_highlight;
high_id = high.attr("id");
Expand Down Expand Up @@ -849,6 +872,7 @@

Chosen.prototype.result_deselect = function(pos) {
var result, result_data;

result_data = this.results_data[pos];
if (!this.form_field.options[result_data.options_index].disabled) {
result_data.selected = false;
Expand Down Expand Up @@ -880,6 +904,7 @@

Chosen.prototype.winnow_results = function() {
var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref1;

this.no_results_clear();
results = 0;
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
Expand Down Expand Up @@ -942,6 +967,7 @@

Chosen.prototype.winnow_results_set_highlight = function() {
var do_high, selected_results;

if (!this.result_highlight) {
selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
Expand All @@ -953,6 +979,7 @@

Chosen.prototype.no_results = function(terms) {
var no_results_html;

no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
no_results_html.find("span").first().html(terms);
return this.search_results.append(no_results_html);
Expand All @@ -964,6 +991,7 @@

Chosen.prototype.keydown_arrow = function() {
var next_sib;

if (this.results_showing && this.result_highlight) {
next_sib = this.result_highlight.nextAll("li.active-result").first();
if (next_sib) {
Expand All @@ -976,6 +1004,7 @@

Chosen.prototype.keyup_arrow = function() {
var prev_sibs;

if (!this.results_showing && !this.is_multiple) {
return this.results_show();
} else if (this.result_highlight) {
Expand All @@ -993,6 +1022,7 @@

Chosen.prototype.keydown_backstroke = function() {
var next_available_destroy;

if (this.pending_backstroke) {
this.choice_destroy(this.pending_backstroke.find("a").first());
return this.clear_backstroke();
Expand All @@ -1018,6 +1048,7 @@

Chosen.prototype.keydown_checker = function(evt) {
var stroke, _ref1;

stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
this.search_field_scale();
if (stroke !== 8 && this.pending_backstroke) {
Expand Down Expand Up @@ -1048,6 +1079,7 @@

Chosen.prototype.search_field_scale = function() {
var div, h, style, style_block, styles, w, _i, _len;

if (this.is_multiple) {
h = 0;
w = 0;
Expand Down Expand Up @@ -1078,6 +1110,7 @@

Chosen.prototype.generate_random_id = function() {
var string;

string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
while ($("#" + string).length > 0) {
string += this.generate_random_char();
Expand Down
Loading