Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to Chosen 0.9.11

  • Loading branch information...
commit 0124d57730d6f790713394c589d167bc2f32ede3 1 parent 13285c7
@pfiller pfiller authored
Showing with 21 additions and 9 deletions.
  1. +21 −9 chosen/chosen.jquery.js
View
30 chosen/chosen.jquery.js
@@ -1,7 +1,7 @@
// Chosen, a Select Box Enhancer for jQuery and Protoype
// by Patrick Filler for Harvest, http://getharvest.com
//
-// Version 0.9.9
+// Version 0.9.11
// Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com
@@ -133,10 +133,12 @@ Copyright (c) 2011 by Harvest
this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
this.disable_search_threshold = this.options.disable_search_threshold || 0;
this.disable_search = this.options.disable_search || false;
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
this.search_contains = this.options.search_contains || false;
this.choices = 0;
this.single_backstroke_delete = this.options.single_backstroke_delete || false;
- return this.max_selected_options = this.options.max_selected_options || Infinity;
+ this.max_selected_options = this.options.max_selected_options || Infinity;
+ return this.inherit_select_classes = this.options.inherit_select_classes || false;
};
AbstractChosen.prototype.set_default_text = function() {
@@ -336,13 +338,21 @@ Copyright (c) 2011 by Harvest
};
Chosen.prototype.set_up_html = function() {
- var container_div, container_props, dd_top, dd_width, sf_width;
+ var container_classes, container_div, container_props, dd_top, dd_width, sf_width;
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"];
+ container_classes.push("chzn-container-" + (this.is_multiple ? "multi" : "single"));
+ if (this.inherit_select_classes && this.form_field.className) {
+ container_classes.push(this.form_field.className);
+ }
+ if (this.is_rtl) {
+ container_classes.push("chzn-rtl");
+ }
this.f_width = this.form_field_jq.outerWidth();
container_props = {
id: this.container_id,
- "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
+ "class": container_classes.join(' '),
style: 'width: ' + this.f_width + 'px;',
title: this.form_field.title
};
@@ -354,7 +364,6 @@ Copyright (c) 2011 by Harvest
}
this.form_field_jq.hide().after(container_div);
this.container = $('#' + this.container_id);
- this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
this.dropdown = this.container.find('div.chzn-drop').first();
dd_top = this.container.height();
dd_width = this.f_width - get_side_border_padding(this.dropdown);
@@ -462,7 +471,7 @@ Copyright (c) 2011 by Harvest
if (!this.is_disabled) {
target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
if (evt && evt.type === "mousedown" && !this.results_showing) {
- evt.stopPropagation();
+ evt.preventDefault();
}
if (!this.pending_destroy_click && !target_closelink) {
if (!this.active_field) {
@@ -726,7 +735,8 @@ Copyright (c) 2011 by Harvest
if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
this.results_hide();
}
- return link.parents('li').first().remove();
+ link.parents('li').first().remove();
+ return this.search_field_scale();
}
};
@@ -775,7 +785,7 @@ Copyright (c) 2011 by Harvest
this.single_deselect_control_build();
}
}
- if (!(evt.metaKey && this.is_multiple)) {
+ if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
this.results_hide();
}
this.search_field.val("");
@@ -844,7 +854,7 @@ Copyright (c) 2011 by Harvest
if (regex.test(option.html)) {
found = true;
results += 1;
- } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
+ } else if (this.enable_split_word_search && (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0)) {
parts = option.html.replace(/\[|\]/g, "").split(" ");
if (parts.length) {
for (_j = 0, _len1 = parts.length; _j < _len1; _j++) {
@@ -1060,6 +1070,8 @@ Copyright (c) 2011 by Harvest
})(AbstractChosen);
+ root.Chosen = Chosen;
+
get_side_border_padding = function(elmt) {
var side_border_padding;
return side_border_padding = elmt.outerWidth() - elmt.width();
Please sign in to comment.
Something went wrong with that request. Please try again.