Permalink
Browse files

MINOR Updated chosen.js from 0.9.7 to 0.9.8 while still maintaining l…

…ocal fixes
  • Loading branch information...
1 parent 66f537d commit a95b11d004c637070a4ede8f182dbf19f1221a9c @normann normann committed with chillu Mar 27, 2012
@@ -1,7 +1,7 @@
---
format: 1
handler:
- commit: 880a30dcb49555996a875cf4474999a2341aa055
+ commit: f584bc49d6de7cf68475c3e51baa4cf2008a130e
branch: master
lock: false
repository_class: Piston::Git::Repository
@@ -1 +1 @@
-0.9.7
+0.9.8
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -51,6 +51,9 @@
color: #444444;
text-decoration: none;
}
+.chzn-container-single .chzn-default {
+ color: #999;
+}
.chzn-container-single .chzn-single span {
margin-right: 26px;
display: block;
@@ -68,7 +71,7 @@
width: 12px;
height: 13px;
font-size: 1px;
- background: url(chosen-sprite.png) right top no-repeat;
+ background: url('chosen-sprite.png') right top no-repeat;
}
.chzn-container-single .chzn-single abbr:hover {
background-position: right -11px;
@@ -206,7 +209,7 @@
width: 12px;
height: 13px;
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 {
background-position: right -11px;
@@ -1,5 +1,15 @@
-//based on version 0.9.7 and applied a very simple patch that fix percentaage width support on select tag
-//the patch has been documented https://github.com/harvesthq/chosen/issues/300.
+// Chosen, a Select Box Enhancer for jQuery and Protoype
+// by Patrick Filler for Harvest, http://getharvest.com
+//
+// Version 0.9.8
+// Full source at https://github.com/harvesthq/chosen
+// Copyright (c) 2011 Harvest http://getharvest.com
+
+// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
+// This file is generated by `cake build`, do not edit it by hand.
+
+// based on version 0.9.7, applied a very simple patch that fix percentaage width support on select tag
+// the patch has been documented https://github.com/harvesthq/chosen/issues/300.
(function() {
var SelectParser;
@@ -123,6 +133,7 @@ Copyright (c) 2011 by Harvest
this.result_single_selected = null;
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.search_contains = this.options.search_contains || false;
this.choices = 0;
return this.results_none_found = this.options.no_results_text || "No results match";
};
@@ -303,7 +314,7 @@ Copyright (c) 2011 by Harvest
if (this.is_multiple) {
container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
} else {
- container_div.html('<a href="javascript:void(0)" class="chzn-single"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
+ container_div.html('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
}
this.form_field_jq.hide().after(container_div);
this.container = $('#' + this.container_id);
@@ -411,7 +422,9 @@ Copyright (c) 2011 by Harvest
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 (evt && evt.type === "mousedown" && !this.results_showing) {
+ evt.stopPropagation();
+ }
if (!this.pending_destroy_click && !target_closelink) {
if (!this.active_field) {
if (this.is_multiple) this.search_field.val("");
@@ -498,7 +511,7 @@ Copyright (c) 2011 by Harvest
if (data.selected && this.is_multiple) {
this.choice_build(data);
} else if (data.selected && !this.is_multiple) {
- this.selected_item.find("span").text(data.text);
+ this.selected_item.removeClass("chzn-default").find("span").text(data.text);
if (this.allow_single_deselect) this.single_deselect_control_build();
}
}
@@ -665,6 +678,7 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.results_reset = function(evt) {
this.form_field.options[0].selected = true;
this.selected_item.find("span").text(this.default_text);
+ if (!this.is_multiple) this.selected_item.addClass("chzn-default");
this.show_search_field_default();
$(evt.target).remove();
this.form_field_jq.trigger("change");
@@ -682,6 +696,7 @@ Copyright (c) 2011 by Harvest
} else {
this.search_results.find(".result-selected").removeClass("result-selected");
this.result_single_selected = high;
+ this.selected_item.removeClass("chzn-default");
}
high.addClass("result-selected");
position = high_id.substr(high_id.lastIndexOf("_") + 1);
@@ -729,11 +744,12 @@ Copyright (c) 2011 by Harvest
};
Chosen.prototype.winnow_results = function() {
- var found, option, part, parts, regex, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
+ var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
this.no_results_clear();
results = 0;
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
- regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
+ regexAnchor = this.search_contains ? "" : "^";
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
Oops, something went wrong.
@@ -1,7 +1,7 @@
// Chosen, a Select Box Enhancer for jQuery and Protoype
// by Patrick Filler for Harvest, http://getharvest.com
//
-// Version 0.9.7
+// Version 0.9.8
// Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com
@@ -129,6 +129,7 @@ Copyright (c) 2011 by Harvest
this.result_single_selected = null;
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.search_contains = this.options.search_contains || false;
this.choices = 0;
return this.results_none_found = this.options.no_results_text || "No results match";
};
@@ -281,7 +282,7 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.set_default_values = function() {
Chosen.__super__.set_default_values.call(this);
- this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
+ this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
@@ -407,7 +408,7 @@ Copyright (c) 2011 by Harvest
var target_closelink;
if (!this.is_disabled) {
target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false;
- if (evt && evt.type === "mousedown") evt.stop();
+ if (evt && evt.type === "mousedown" && !this.results_showing) evt.stop();
if (!this.pending_destroy_click && !target_closelink) {
if (!this.active_field) {
if (this.is_multiple) this.search_field.clear();
@@ -493,7 +494,7 @@ Copyright (c) 2011 by Harvest
if (data.selected && this.is_multiple) {
this.choice_build(data);
} else if (data.selected && !this.is_multiple) {
- this.selected_item.down("span").update(data.html);
+ this.selected_item.removeClassName("chzn-default").down("span").update(data.html);
if (this.allow_single_deselect) this.single_deselect_control_build();
}
}
@@ -659,6 +660,7 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.results_reset = function(evt) {
this.form_field.options[0].selected = true;
this.selected_item.down("span").update(this.default_text);
+ if (!this.is_multiple) this.selected_item.addClassName("chzn-default");
this.show_search_field_default();
evt.target.remove();
if (typeof Event.simulate === 'function') this.form_field.simulate("change");
@@ -674,6 +676,7 @@ Copyright (c) 2011 by Harvest
this.result_deactivate(high);
} else {
this.search_results.descendants(".result-selected").invoke("removeClassName", "result-selected");
+ this.selected_item.removeClassName("chzn-default");
this.result_single_selected = high;
}
high.addClassName("result-selected");
@@ -726,11 +729,12 @@ Copyright (c) 2011 by Harvest
};
Chosen.prototype.winnow_results = function() {
- var found, option, part, parts, regex, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
+ var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
this.no_results_clear();
results = 0;
searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML();
- regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
+ regexAnchor = this.search_contains ? "" : "^";
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
Oops, something went wrong.
@@ -40,7 +40,7 @@ class Chosen extends AbstractChosen
if @is_multiple
container_div.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'
else
- container_div.html '<a href="javascript:void(0)" class="chzn-single"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
+ container_div.html '<a href="javascript:void(0)" class="chzn-single chzn-default"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
@form_field_jq.hide().after container_div
@container = ($ '#' + @container_id)
@@ -108,7 +108,7 @@ class Chosen extends AbstractChosen
container_mousedown: (evt) ->
if !@is_disabled
target_closelink = if evt? then ($ evt.target).hasClass "search-choice-close" else false
- if evt and evt.type is "mousedown"
+ if evt and evt.type is "mousedown" and not @results_showing
evt.stopPropagation()
if not @pending_destroy_click and not target_closelink
if not @active_field
@@ -187,7 +187,7 @@ class Chosen extends AbstractChosen
if data.selected and @is_multiple
this.choice_build data
else if data.selected and not @is_multiple
- @selected_item.find("span").text data.text
+ @selected_item.removeClass("chzn-default").find("span").text data.text
this.single_deselect_control_build() if @allow_single_deselect
this.search_field_disabled()
@@ -315,6 +315,7 @@ class Chosen extends AbstractChosen
results_reset: (evt) ->
@form_field.options[0].selected = true
@selected_item.find("span").text @default_text
+ @selected_item.addClass("chzn-default") if not @is_multiple
this.show_search_field_default()
$(evt.target).remove();
@form_field_jq.trigger "change"
@@ -332,6 +333,7 @@ class Chosen extends AbstractChosen
else
@search_results.find(".result-selected").removeClass "result-selected"
@result_single_selected = high
+ @selected_item.removeClass("chzn-default")
high.addClass "result-selected"
@@ -383,7 +385,8 @@ class Chosen extends AbstractChosen
results = 0
searchText = if @search_field.val() is @default_text then "" else $('<div/>').text($.trim(@search_field.val())).html()
- regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
+ regexAnchor = if @search_contains then "" else "^"
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
for option in @results_data
@@ -16,7 +16,7 @@ class Chosen extends AbstractChosen
super()
# HTML Templates
- @single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
+ @single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>')
@choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
@no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
@@ -101,7 +101,7 @@ class Chosen extends AbstractChosen
container_mousedown: (evt) ->
if !@is_disabled
target_closelink = if evt? then evt.target.hasClassName "search-choice-close" else false
- if evt and evt.type is "mousedown"
+ if evt and evt.type is "mousedown" and not @results_showing
evt.stop()
if not @pending_destroy_click and not target_closelink
if not @active_field
@@ -179,7 +179,7 @@ class Chosen extends AbstractChosen
if data.selected and @is_multiple
this.choice_build data
else if data.selected and not @is_multiple
- @selected_item.down("span").update( data.html )
+ @selected_item.removeClassName("chzn-default").down("span").update( data.html )
this.single_deselect_control_build() if @allow_single_deselect
this.search_field_disabled()
@@ -308,6 +308,7 @@ class Chosen extends AbstractChosen
results_reset: (evt) ->
@form_field.options[0].selected = true
@selected_item.down("span").update(@default_text)
+ @selected_item.addClassName("chzn-default") if not @is_multiple
this.show_search_field_default()
evt.target.remove()
@form_field.simulate("change") if typeof Event.simulate is 'function'
@@ -322,6 +323,7 @@ class Chosen extends AbstractChosen
this.result_deactivate high
else
@search_results.descendants(".result-selected").invoke "removeClassName", "result-selected"
+ @selected_item.removeClassName("chzn-default")
@result_single_selected = high
high.addClassName("result-selected")
@@ -374,7 +376,8 @@ class Chosen extends AbstractChosen
results = 0
searchText = if @search_field.value is @default_text then "" else @search_field.value.strip().escapeHTML()
- regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
+ regexAnchor = if @search_contains then "" else "^"
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
for option in @results_data
@@ -29,6 +29,7 @@ class AbstractChosen
@result_single_selected = null
@allow_single_deselect = if @options.allow_single_deselect? and @form_field.options[0]? and @form_field.options[0].text is "" then @options.allow_single_deselect else false
@disable_search_threshold = @options.disable_search_threshold || 0
+ @search_contains = @options.search_contains || false
@choices = 0
@results_none_found = @options.no_results_text or "No results match"
@@ -1343,7 +1343,7 @@
<p>Using Chosen is easy as can be.</p>
<ol>
<li>Download the plugin and copy the chosen files to your app.</li>
- <li>Activate the plugin by creating a new instance of Chosen: New Chosen(<em>some_form_field</em>);</li>
+ <li>Activate the plugin by creating a new instance of Chosen: new Chosen(<em>some_form_field</em>);</li>
<li><a href="http://youtu.be/pS-RsIzb78U?t=57s">Disco</a>.</li>
</ol>
@@ -1,7 +1,7 @@
{
"author": "harvest",
"name": "chosen",
- "version": "0.9.7",
+ "version": "0.9.8",
"description": "Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly. It is currently available in both jQuery and Prototype flavors.",
"repository": {
"type": "git",

0 comments on commit a95b11d

Please sign in to comment.