Update chosen to v0.9.5

This commit is contained in:
Bart Visscher 2011-11-24 21:04:34 +01:00
parent fab70cb590
commit cea6561632
5 changed files with 180 additions and 81 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 742 B

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -1,9 +1,4 @@
/* @group Base */ /* @group Base */
select.chzn-select {
visibility: hidden;
height: 28px !important;
min-height: 28px !important;
}
.chzn-container { .chzn-container {
font-size: 13px; font-size: 13px;
position: relative; position: relative;
@ -60,9 +55,21 @@ select.chzn-select {
white-space: nowrap; white-space: nowrap;
-o-text-overflow: ellipsis; -o-text-overflow: ellipsis;
-ms-text-overflow: ellipsis; -ms-text-overflow: ellipsis;
-moz-binding: url('/xml/ellipsis.xml#ellipsis');
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.chzn-container-single .chzn-single abbr {
display: block;
position: absolute;
right: 26px;
top: 8px;
width: 12px;
height: 13px;
font-size: 1px;
background: url(chosen-sprite.png) right top no-repeat;
}
.chzn-container-single .chzn-single abbr:hover {
background-position: right -11px;
}
.chzn-container-single .chzn-single div { .chzn-container-single .chzn-single div {
-webkit-border-radius: 0 4px 4px 0; -webkit-border-radius: 0 4px 4px 0;
-moz-border-radius : 0 4px 4px 0; -moz-border-radius : 0 4px 4px 0;
@ -94,18 +101,19 @@ select.chzn-select {
} }
.chzn-container-single .chzn-search { .chzn-container-single .chzn-search {
padding: 3px 4px; padding: 3px 4px;
position: relative;
margin: 0; margin: 0;
white-space: nowrap; white-space: nowrap;
} }
.chzn-container-single .chzn-search input { .chzn-container-single .chzn-search input {
background: #fff url('chosen-sprite.png') no-repeat 100% -20px; background: #fff url('chosen-sprite.png') no-repeat 100% -22px;
background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%); background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
background: url('chosen-sprite.png') no-repeat 100% -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
background: url('chosen-sprite.png') no-repeat 100% -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
background: url('chosen-sprite.png') no-repeat 100% -20px, linear-gradient(top, #ffffff 85%,#eeeeee 99%); background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
margin: 1px 0; margin: 1px 0;
padding: 4px 20px 4px 5px; padding: 4px 20px 4px 5px;
outline: 0; outline: 0;
@ -123,6 +131,11 @@ select.chzn-select {
} }
/* @end */ /* @end */
.chzn-container-single-nosearch .chzn-search input {
position: absolute;
left: -9000px;
}
/* @group Multi Chosen */ /* @group Multi Chosen */
.chzn-container-multi .chzn-choices { .chzn-container-multi .chzn-choices {
background-color: #fff; background-color: #fff;
@ -197,18 +210,18 @@ select.chzn-select {
.chzn-container-multi .chzn-choices .search-choice .search-choice-close { .chzn-container-multi .chzn-choices .search-choice .search-choice-close {
display: block; display: block;
position: absolute; position: absolute;
right: 5px; right: 3px;
top: 6px; top: 4px;
width: 8px; width: 12px;
height: 9px; height: 13px;
font-size: 1px; font-size: 1px;
background: url(chosen-sprite.png) right top no-repeat; background: url(chosen-sprite.png) right top no-repeat;
} }
.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover { .chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
background-position: right -9px; background-position: right -11px;
} }
.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close { .chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
background-position: right -9px; background-position: right -11px;
} }
/* @end */ /* @end */
@ -226,6 +239,7 @@ select.chzn-select {
padding: 0; padding: 0;
} }
.chzn-container .chzn-results li { .chzn-container .chzn-results li {
display: none;
line-height: 80%; line-height: 80%;
padding: 7px 7px 8px; padding: 7px 7px 8px;
margin: 0; margin: 0;
@ -233,6 +247,7 @@ select.chzn-select {
} }
.chzn-container .chzn-results .active-result { .chzn-container .chzn-results .active-result {
cursor: pointer; cursor: pointer;
display: list-item;
} }
.chzn-container .chzn-results .highlighted { .chzn-container .chzn-results .highlighted {
background: #3875d7; background: #3875d7;
@ -247,6 +262,7 @@ select.chzn-select {
} }
.chzn-container .chzn-results .no-results { .chzn-container .chzn-results .no-results {
background: #f4f4f4; background: #f4f4f4;
display: list-item;
} }
.chzn-container .chzn-results .group-result { .chzn-container .chzn-results .group-result {
cursor: default; cursor: default;
@ -309,6 +325,18 @@ select.chzn-select {
} }
/* @end */ /* @end */
/* @group Disabled Support */
.chzn-disabled {
cursor: default;
opacity:0.5 !important;
}
.chzn-disabled .chzn-single {
cursor: default;
}
.chzn-disabled .chzn-choices .search-choice .search-choice-close {
cursor: default;
}
/* @group Right to Left */ /* @group Right to Left */
.chzn-rtl { direction:rtl;text-align: right; } .chzn-rtl { direction:rtl;text-align: right; }
.chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; } .chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; }
@ -327,14 +355,14 @@ select.chzn-select {
.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; } .chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; }
.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; } .chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
.chzn-rtl .chzn-search input { .chzn-rtl .chzn-search input {
background: url('chosen-sprite.png') no-repeat -38px -20px, #ffffff; background: url('chosen-sprite.png') no-repeat -38px -22px, #ffffff;
background: url('chosen-sprite.png') no-repeat -38px -20px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background: url('chosen-sprite.png') no-repeat -38px -20px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('chosen-sprite.png') no-repeat -38px -20px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('chosen-sprite.png') no-repeat -38px -20px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%); background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
background: url('chosen-sprite.png') no-repeat -38px -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
background: url('chosen-sprite.png') no-repeat -38px -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
background: url('chosen-sprite.png') no-repeat -38px -20px, linear-gradient(top, #ffffff 85%,#eeeeee 99%); background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
padding: 4px 5px 4px 20px; padding: 4px 5px 4px 20px;
} }
/* @end */ /* @end */

View File

@ -1 +1 @@
0.9.1 0.9.5

View File

@ -1,7 +1,7 @@
// Chosen, a Select Box Enhancer for jQuery and Protoype // Chosen, a Select Box Enhancer for jQuery and Protoype
// by Patrick Filler for Harvest, http://getharvest.com // by Patrick Filler for Harvest, http://getharvest.com
// //
// Version 0.9 // Version 0.9.5
// Full source at https://github.com/harvesthq/chosen // Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com // Copyright (c) 2011 Harvest http://getharvest.com
@ -16,18 +16,22 @@
root = this; root = this;
$ = jQuery; $ = jQuery;
$.fn.extend({ $.fn.extend({
chosen: function(data, options) { chosen: function(options) {
if ($.browser === "msie" && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
return this;
}
return $(this).each(function(input_field) { return $(this).each(function(input_field) {
if (!($(this)).hasClass("chzn-done")) { if (!($(this)).hasClass("chzn-done")) {
return new Chosen(this, data, options); return new Chosen(this, options);
} }
}); });
} }
}); });
Chosen = (function() { Chosen = (function() {
function Chosen(elmn) { function Chosen(form_field, options) {
this.form_field = form_field;
this.options = options != null ? options : {};
this.set_default_values(); this.set_default_values();
this.form_field = elmn;
this.form_field_jq = $(this.form_field); this.form_field_jq = $(this.form_field);
this.is_multiple = this.form_field.multiple; this.is_multiple = this.form_field.multiple;
this.is_rtl = this.form_field_jq.hasClass("chzn-rtl"); this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
@ -40,22 +44,28 @@
this.click_test_action = __bind(function(evt) { this.click_test_action = __bind(function(evt) {
return this.test_active_click(evt); return this.test_active_click(evt);
}, this); }, this);
this.activate_action = __bind(function(evt) {
return this.activate_field(evt);
}, this);
this.active_field = false; this.active_field = false;
this.mouse_on_container = false; this.mouse_on_container = false;
this.results_showing = false; this.results_showing = false;
this.result_highlighted = null; this.result_highlighted = null;
this.result_single_selected = null; this.result_single_selected = null;
return this.choices = 0; this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
this.disable_search_threshold = this.options.disable_search_threshold || 0;
this.choices = 0;
return this.results_none_found = this.options.no_results_text || "No results match";
}; };
Chosen.prototype.set_up_html = function() { Chosen.prototype.set_up_html = function() {
var container_div, dd_top, dd_width, sf_width; var container_div, dd_top, dd_width, sf_width;
this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id(); this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
this.container_id += "_chzn"; this.container_id += "_chzn";
this.f_width = this.form_field_jq.width(); this.f_width = this.form_field_jq.outerWidth();
this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default; this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
container_div = $("<div />", { container_div = $("<div />", {
id: this.container_id, id: this.container_id,
"class": "chzn-container " + (this.is_rtl ? ' chzn-rtl' : void 0), "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
style: 'width: ' + this.f_width + 'px;' style: 'width: ' + this.f_width + 'px;'
}); });
if (this.is_multiple) { if (this.is_multiple) {
@ -66,6 +76,9 @@
this.form_field_jq.hide().after(container_div); this.form_field_jq.hide().after(container_div);
this.container = $('#' + this.container_id); this.container = $('#' + this.container_id);
this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single")); this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
if (!this.is_multiple && this.form_field.options.length <= this.disable_search_threshold) {
this.container.addClass("chzn-container-single-nosearch");
}
this.dropdown = this.container.find('div.chzn-drop').first(); this.dropdown = this.container.find('div.chzn-drop').first();
dd_top = this.container.height(); dd_top = this.container.height();
dd_width = this.f_width - get_side_border_padding(this.dropdown); dd_width = this.f_width - get_side_border_padding(this.dropdown);
@ -92,8 +105,11 @@
return this.set_tab_index(); return this.set_tab_index();
}; };
Chosen.prototype.register_observers = function() { Chosen.prototype.register_observers = function() {
this.container.click(__bind(function(evt) { this.container.mousedown(__bind(function(evt) {
return this.container_click(evt); return this.container_mousedown(evt);
}, this));
this.container.mouseup(__bind(function(evt) {
return this.container_mouseup(evt);
}, this)); }, this));
this.container.mouseenter(__bind(function(evt) { this.container.mouseenter(__bind(function(evt) {
return this.mouse_enter(evt); return this.mouse_enter(evt);
@ -101,8 +117,8 @@
this.container.mouseleave(__bind(function(evt) { this.container.mouseleave(__bind(function(evt) {
return this.mouse_leave(evt); return this.mouse_leave(evt);
}, this)); }, this));
this.search_results.click(__bind(function(evt) { this.search_results.mouseup(__bind(function(evt) {
return this.search_results_click(evt); return this.search_results_mouseup(evt);
}, this)); }, this));
this.search_results.mouseover(__bind(function(evt) { this.search_results.mouseover(__bind(function(evt) {
return this.search_results_mouseover(evt); return this.search_results_mouseover(evt);
@ -129,30 +145,52 @@
return this.search_field.focus(__bind(function(evt) { return this.search_field.focus(__bind(function(evt) {
return this.input_focus(evt); return this.input_focus(evt);
}, this)); }, this));
} else {
return this.selected_item.focus(__bind(function(evt) {
return this.activate_field(evt);
}, this));
} }
}; };
Chosen.prototype.container_click = function(evt) { Chosen.prototype.search_field_disabled = function() {
if (evt && evt.type === "click") { this.is_disabled = this.form_field_jq.attr('disabled');
evt.stopPropagation(); if (this.is_disabled) {
} this.container.addClass('chzn-disabled');
if (!this.pending_destroy_click) { this.search_field.attr('disabled', true);
if (!this.active_field) { if (!this.is_multiple) {
if (this.is_multiple) { this.selected_item.unbind("focus", this.activate_action);
this.search_field.val("");
}
$(document).click(this.click_test_action);
this.results_show();
} else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
evt.preventDefault();
this.results_toggle();
} }
return this.activate_field(); return this.close_field();
} else { } else {
return this.pending_destroy_click = false; this.container.removeClass('chzn-disabled');
this.search_field.attr('disabled', false);
if (!this.is_multiple) {
return this.selected_item.bind("focus", this.activate_action);
}
}
};
Chosen.prototype.container_mousedown = function(evt) {
var target_closelink;
if (!this.is_disabled) {
target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
if (evt && evt.type === "mousedown") {
evt.stopPropagation();
}
if (!this.pending_destroy_click && !target_closelink) {
if (!this.active_field) {
if (this.is_multiple) {
this.search_field.val("");
}
$(document).click(this.click_test_action);
this.results_show();
} else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
evt.preventDefault();
this.results_toggle();
}
return this.activate_field();
} else {
return this.pending_destroy_click = false;
}
}
};
Chosen.prototype.container_mouseup = function(evt) {
if (evt.target.nodeName === "ABBR") {
return this.results_reset(evt);
} }
}; };
Chosen.prototype.mouse_enter = function() { Chosen.prototype.mouse_enter = function() {
@ -164,7 +202,7 @@
Chosen.prototype.input_focus = function(evt) { Chosen.prototype.input_focus = function(evt) {
if (!this.active_field) { if (!this.active_field) {
return setTimeout((__bind(function() { return setTimeout((__bind(function() {
return this.container_click(); return this.container_mousedown();
}, this)), 50); }, this)), 50);
} }
}; };
@ -235,9 +273,13 @@
this.choice_build(data); this.choice_build(data);
} else if (data.selected && !this.is_multiple) { } else if (data.selected && !this.is_multiple) {
this.selected_item.find("span").text(data.text); this.selected_item.find("span").text(data.text);
if (this.allow_single_deselect) {
this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
}
} }
} }
} }
this.search_field_disabled();
this.show_search_field_default(); this.show_search_field_default();
this.search_field_scale(); this.search_field_scale();
this.search_results.html(content); this.search_results.html(content);
@ -252,7 +294,7 @@
} }
}; };
Chosen.prototype.result_add_option = function(option) { Chosen.prototype.result_add_option = function(option) {
var classes; var classes, style;
if (!option.disabled) { if (!option.disabled) {
option.dom_id = this.container_id + "_o_" + option.array_index; option.dom_id = this.container_id + "_o_" + option.array_index;
classes = option.selected && this.is_multiple ? [] : ["active-result"]; classes = option.selected && this.is_multiple ? [] : ["active-result"];
@ -262,7 +304,11 @@
if (option.group_array_index != null) { if (option.group_array_index != null) {
classes.push("group-option"); classes.push("group-option");
} }
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.html + '</li>'; if (option.classes !== "") {
classes.push(option.classes);
}
style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
} else { } else {
return ""; return "";
} }
@ -353,12 +399,12 @@
return this.search_field.removeClass("default"); return this.search_field.removeClass("default");
} }
}; };
Chosen.prototype.search_results_click = function(evt) { Chosen.prototype.search_results_mouseup = function(evt) {
var target; var target;
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target.length) { if (target.length) {
this.result_highlight = target; this.result_highlight = target;
return this.result_select(); return this.result_select(evt);
} }
}; };
Chosen.prototype.search_results_mouseover = function(evt) { Chosen.prototype.search_results_mouseover = function(evt) {
@ -391,8 +437,12 @@
}; };
Chosen.prototype.choice_destroy_link_click = function(evt) { Chosen.prototype.choice_destroy_link_click = function(evt) {
evt.preventDefault(); evt.preventDefault();
this.pending_destroy_click = true; if (!this.is_disabled) {
return this.choice_destroy($(evt.target)); this.pending_destroy_click = true;
return this.choice_destroy($(evt.target));
} else {
return evt.stopPropagation;
}
}; };
Chosen.prototype.choice_destroy = function(link) { Chosen.prototype.choice_destroy = function(link) {
this.choices -= 1; this.choices -= 1;
@ -403,18 +453,29 @@
this.result_deselect(link.attr("rel")); this.result_deselect(link.attr("rel"));
return link.parents('li').first().remove(); return link.parents('li').first().remove();
}; };
Chosen.prototype.result_select = function() { Chosen.prototype.results_reset = function(evt) {
this.form_field.options[0].selected = true;
this.selected_item.find("span").text(this.default_text);
this.show_search_field_default();
$(evt.target).remove();
this.form_field_jq.trigger("change");
if (this.active_field) {
return this.results_hide();
}
};
Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position; var high, high_id, item, position;
if (this.result_highlight) { if (this.result_highlight) {
high = this.result_highlight; high = this.result_highlight;
high_id = high.attr("id"); high_id = high.attr("id");
this.result_clear_highlight(); this.result_clear_highlight();
high.addClass("result-selected");
if (this.is_multiple) { if (this.is_multiple) {
this.result_deactivate(high); this.result_deactivate(high);
} else { } else {
this.search_results.find(".result-selected").removeClass("result-selected");
this.result_single_selected = high; this.result_single_selected = high;
} }
high.addClass("result-selected");
position = high_id.substr(high_id.lastIndexOf("_") + 1); position = high_id.substr(high_id.lastIndexOf("_") + 1);
item = this.results_data[position]; item = this.results_data[position];
item.selected = true; item.selected = true;
@ -423,18 +484,23 @@
this.choice_build(item); this.choice_build(item);
} else { } else {
this.selected_item.find("span").first().text(item.text); this.selected_item.find("span").first().text(item.text);
if (this.allow_single_deselect) {
this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
}
}
if (!(evt.metaKey && this.is_multiple)) {
this.results_hide();
} }
this.results_hide();
this.search_field.val(""); this.search_field.val("");
this.form_field_jq.trigger("change"); this.form_field_jq.trigger("change");
return this.search_field_scale(); return this.search_field_scale();
} }
}; };
Chosen.prototype.result_activate = function(el) { Chosen.prototype.result_activate = function(el) {
return el.addClass("active-result").show(); return el.addClass("active-result");
}; };
Chosen.prototype.result_deactivate = function(el) { Chosen.prototype.result_deactivate = function(el) {
return el.removeClass("active-result").hide(); return el.removeClass("active-result");
}; };
Chosen.prototype.result_deselect = function(pos) { Chosen.prototype.result_deselect = function(pos) {
var result, result_data; var result, result_data;
@ -530,17 +596,18 @@
return _results; return _results;
}; };
Chosen.prototype.winnow_results_set_highlight = function() { Chosen.prototype.winnow_results_set_highlight = function() {
var do_high; var do_high, selected_results;
if (!this.result_highlight) { if (!this.result_highlight) {
do_high = this.search_results.find(".active-result").first(); selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
if (do_high) { do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
if (do_high != null) {
return this.result_do_highlight(do_high); return this.result_do_highlight(do_high);
} }
} }
}; };
Chosen.prototype.no_results = function(terms) { Chosen.prototype.no_results = function(terms) {
var no_results_html; var no_results_html;
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>'); no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
no_results_html.find("span").first().html(terms); no_results_html.find("span").first().html(terms);
return this.search_results.append(no_results_html); return this.search_results.append(no_results_html);
}; };
@ -611,7 +678,7 @@
case 13: case 13:
evt.preventDefault(); evt.preventDefault();
if (this.results_showing) { if (this.results_showing) {
return this.result_select(); return this.result_select(evt);
} }
break; break;
case 27: case 27:
@ -623,6 +690,8 @@
case 38: case 38:
case 40: case 40:
case 16: case 16:
case 91:
case 17:
break; break;
default: default:
return this.results_search(); return this.results_search();
@ -758,7 +827,9 @@
html: option.innerHTML, html: option.innerHTML,
selected: option.selected, selected: option.selected,
disabled: group_disabled === true ? group_disabled : option.disabled, disabled: group_disabled === true ? group_disabled : option.disabled,
group_array_index: group_position group_array_index: group_position,
classes: option.className,
style: option.style.cssText
}); });
} else { } else {
this.parsed.push({ this.parsed.push({

File diff suppressed because one or more lines are too long