Skip to content

Commit

Permalink
chzn-default class for styling placeholder text
Browse files Browse the repository at this point in the history
  • Loading branch information
parshap committed Jan 29, 2012
1 parent dc2eb01 commit 15cdf5e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions chosen/chosen.css
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion chosen/chosen.jquery.js
Expand Up @@ -307,7 +307,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);
Expand Down Expand Up @@ -661,6 +661,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);
this.container.find(".chzn-single").addClass("chzn-default");
this.show_search_field_default();
$(evt.target).remove();
this.form_field_jq.trigger("change");
Expand All @@ -680,6 +681,7 @@ Copyright (c) 2011 by Harvest
this.result_single_selected = high;
}
high.addClass("result-selected");
this.container.find(".chzn-single").removeClass("chzn-default");
position = high_id.substr(high_id.lastIndexOf("_") + 1);
item = this.results_data[position];
item.selected = true;
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion chosen/chosen.proto.js
Expand Up @@ -281,7 +281,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>');
Expand Down Expand Up @@ -659,6 +659,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);
this.container.down(".chzn-single").addClassName("chzn-default");
this.show_search_field_default();
evt.target.remove();
if (typeof Event.simulate === 'function') this.form_field.simulate("change");
Expand All @@ -677,6 +678,7 @@ Copyright (c) 2011 by Harvest
this.result_single_selected = high;
}
high.addClassName("result-selected");
this.container.down(".chzn-single").removeClassName("chzn-default");
position = high.id.substr(high.id.lastIndexOf("_") + 1);
item = this.results_data[position];
item.selected = true;
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.proto.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion coffee/chosen.jquery.coffee
Expand Up @@ -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)
Expand Down Expand Up @@ -315,6 +315,7 @@ class Chosen extends AbstractChosen
results_reset: (evt) ->
@form_field.options[0].selected = true
@selected_item.find("span").text @default_text
@container.find(".chzn-single").addClass("chzn-default")
this.show_search_field_default()
$(evt.target).remove();
@form_field_jq.trigger "change"
Expand All @@ -334,6 +335,7 @@ class Chosen extends AbstractChosen
@result_single_selected = high

high.addClass "result-selected"
@container.find(".chzn-single").removeClass("chzn-default")

position = high_id.substr(high_id.lastIndexOf("_") + 1 )
item = @results_data[position]
Expand Down
4 changes: 3 additions & 1 deletion coffee/chosen.proto.coffee
Expand Up @@ -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>')
Expand Down Expand Up @@ -308,6 +308,7 @@ class Chosen extends AbstractChosen
results_reset: (evt) ->
@form_field.options[0].selected = true
@selected_item.down("span").update(@default_text)
@container.down(".chzn-single").addClassName("chzn-default")
this.show_search_field_default()
evt.target.remove()
@form_field.simulate("change") if typeof Event.simulate is 'function'
Expand All @@ -325,6 +326,7 @@ class Chosen extends AbstractChosen
@result_single_selected = high

high.addClassName("result-selected")
@container.down(".chzn-single").removeClassName("chzn-default")

position = high.id.substr(high.id.lastIndexOf("_") + 1 )
item = @results_data[position]
Expand Down

0 comments on commit 15cdf5e

Please sign in to comment.