Skip to content

Commit

Permalink
Merge pull request #1172 from harvesthq/firefox-width-disparity
Browse files Browse the repository at this point in the history
Use the better supported offsetWidth property to get a fields width
  • Loading branch information
pfiller committed May 14, 2013
2 parents c306562 + 5dc8419 commit 0058167
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
5 changes: 2 additions & 3 deletions chosen/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,11 @@ Copyright (c) 2011 by Harvest
};

AbstractChosen.prototype.container_width = function() {
var width;
if (this.options.width != null) {
return this.options.width;
} else {
return "" + this.form_field.offsetWidth + "px";
}
width = window.getComputedStyle != null ? parseFloat(window.getComputedStyle(this.form_field).getPropertyValue('width')) : (typeof jQuery !== "undefined" && jQuery !== null) && (this.form_field_jq != null) ? this.form_field_jq.outerWidth() : this.form_field.getWidth();
return width + "px";
};

AbstractChosen.browser_is_supported = function() {
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions chosen/chosen.proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,11 @@ Copyright (c) 2011 by Harvest
};

AbstractChosen.prototype.container_width = function() {
var width;
if (this.options.width != null) {
return this.options.width;
} else {
return "" + this.form_field.offsetWidth + "px";
}
width = window.getComputedStyle != null ? parseFloat(window.getComputedStyle(this.form_field).getPropertyValue('width')) : (typeof jQuery !== "undefined" && jQuery !== null) && (this.form_field_jq != null) ? this.form_field_jq.outerWidth() : this.form_field.getWidth();
return width + "px";
};

AbstractChosen.browser_is_supported = function() {
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.proto.min.js

Large diffs are not rendered by default.

11 changes: 1 addition & 10 deletions coffee/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,7 @@ class AbstractChosen
newchar = chars.substring rand, rand+1

container_width: ->
return @options.width if @options.width?

width = if window.getComputedStyle?
parseFloat window.getComputedStyle(@form_field).getPropertyValue('width')
else if jQuery? and @form_field_jq?
@form_field_jq.outerWidth()
else
@form_field.getWidth()

width + "px"
return if @options.width? then @options.width else "#{@form_field.offsetWidth}px"

# class methods and variables ============================================================

Expand Down

0 comments on commit 0058167

Please sign in to comment.