Skip to content

Commit

Permalink
Always include title (no need to check for presenece).
Browse files Browse the repository at this point in the history
Also: use a container_props object to mirror prototype version.
  • Loading branch information
pfiller committed Nov 28, 2012
1 parent aa7b4c4 commit f72f757
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
13 changes: 6 additions & 7 deletions chosen/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,17 @@ Copyright (c) 2011 by Harvest
};

Chosen.prototype.set_up_html = function() {
var container_div, dd_top, dd_width, sf_width;
var 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";
this.f_width = this.form_field_jq.outerWidth();
container_div = $("<div />", {
container_props = {
id: this.container_id,
"class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
style: 'width: ' + this.f_width + 'px;'
});
if (this.form_field.title) {
container_div.attr('title', this.form_field.title);
}
style: 'width: ' + this.f_width + 'px;',
title: this.form_field.title
};
container_div = $("<div />", container_props);
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 {
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chosen/chosen.proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ Copyright (c) 2011 by Harvest
container_props = {
'id': this.container_id,
'class': "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
'style': 'width: ' + this.f_width + 'px'
'style': 'width: ' + this.f_width + 'px',
'title': this.form_field.title
};
if (this.form_field.title) container_props.title = this.form_field.title;
base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({
"default": this.default_text
})) : new Element('div', container_props).update(this.single_temp.evaluate({
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.proto.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class Chosen extends AbstractChosen

@f_width = @form_field_jq.outerWidth()

container_div = ($ "<div />", {
container_props =
id: @container_id
class: "chzn-container#{ if @is_rtl then ' chzn-rtl' else '' }"
style: 'width: ' + (@f_width) + 'px;' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
})
title: @form_field.title

container_div.attr('title', @form_field.title) if @form_field.title
container_div = ($ "<div />", container_props)

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>'
Expand Down
3 changes: 1 addition & 2 deletions coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class Chosen extends AbstractChosen
'id': @container_id
'class': "chzn-container#{ if @is_rtl then ' chzn-rtl' else '' }"
'style': 'width: ' + (@f_width) + 'px' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter

container_props.title = @form_field.title if @form_field.title
'title': @form_field.title

base_template = if @is_multiple then new Element('div', container_props).update( @multi_temp.evaluate({ "default": @default_text}) ) else new Element('div', container_props).update( @single_temp.evaluate({ "default":@default_text }) )

Expand Down

0 comments on commit f72f757

Please sign in to comment.