Permalink
Browse files

fixes #7, select without options will now show input on click

  • Loading branch information...
1 parent e44b46f commit 80f3985a0ea3b8b56898b26305d921bc599c9e3e @koenpunt committed Nov 1, 2012
View
@@ -536,10 +536,10 @@ Copyright (c) 2011 by Harvest
this.choices = 0;
} else if (!this.is_multiple) {
this.selected_item.addClass("chzn-default").find("span").text(this.default_text);
- if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
- this.container.addClass("chzn-container-single-nosearch");
- } else {
+ if (this.create_option && !this.disable_search) {
this.container.removeClass("chzn-container-single-nosearch");
+ } else if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
+ this.container.addClass("chzn-container-single-nosearch");
}
}
content = '';

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -324,9 +324,9 @@ Copyright (c) 2011 by Harvest
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>');
this.choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>');
- this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
+ this.no_results_temp = new Template('<li class="no-results">#{text} "<span>#{terms}</span>"</li>');
this.new_option_temp = new Template('<option value="#{value}">#{text}</option>');
- return this.create_option_temp = new Template('<li class="create-option active-result"><a href="javascript:void(0);">#{text}</a>: #{terms}</li>');
+ return this.create_option_temp = new Template('<li class="create-option active-result"><a href="javascript:void(0);">#{text}</a>: "#{terms}"</li>');
};
Chosen.prototype.set_up_html = function() {
@@ -529,10 +529,10 @@ Copyright (c) 2011 by Harvest
this.choices = 0;
} else if (!this.is_multiple) {
this.selected_item.addClassName("chzn-default").down("span").update(this.default_text);
- if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
- this.container.addClassName("chzn-container-single-nosearch");
- } else {
+ if (this.create_option && !this.disable_search) {
this.container.removeClassName("chzn-container-single-nosearch");
+ } else if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
+ this.container.addClassName("chzn-container-single-nosearch");
}
}
content = '';

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -176,10 +176,10 @@ class Chosen extends AbstractChosen
@choices = 0
else if not @is_multiple
@selected_item.addClass("chzn-default").find("span").text(@default_text)
- if @disable_search or @form_field.options.length <= @disable_search_threshold
- @container.addClass "chzn-container-single-nosearch"
- else
+ if @create_option and not @disable_search
@container.removeClass "chzn-container-single-nosearch"
+ else if @disable_search or @form_field.options.length <= @disable_search_threshold
+ @container.addClass "chzn-container-single-nosearch"
content = ''
for data in @results_data
View
@@ -21,9 +21,9 @@ class Chosen extends AbstractChosen
@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>')
@choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>')
- @no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
+ @no_results_temp = new Template('<li class="no-results">#{text} "<span>#{terms}</span>"</li>')
@new_option_temp = new Template('<option value="#{value}">#{text}</option>')
- @create_option_temp = new Template('<li class="create-option active-result"><a href="javascript:void(0);">#{text}</a>: #{terms}</li>')
+ @create_option_temp = new Template('<li class="create-option active-result"><a href="javascript:void(0);">#{text}</a>: "#{terms}"</li>')
set_up_html: ->
@container_id = @form_field.identify().replace(/[^\w]/g, '_') + "_chzn"
@@ -169,10 +169,10 @@ class Chosen extends AbstractChosen
@choices = 0
else if not @is_multiple
@selected_item.addClassName("chzn-default").down("span").update(@default_text)
- if @disable_search or @form_field.options.length <= @disable_search_threshold
- @container.addClassName "chzn-container-single-nosearch"
- else
+ if @create_option and not @disable_search
@container.removeClassName "chzn-container-single-nosearch"
+ else if @disable_search or @form_field.options.length <= @disable_search_threshold
+ @container.addClassName "chzn-container-single-nosearch"
content = ''
for data in @results_data

0 comments on commit 80f3985

Please sign in to comment.