Permalink
Browse files

BUGFIX SSF-53 : apply a patch with fix chosen.js messed the width up …

…if the select element is single select and having initial width as percentage
  • Loading branch information...
1 parent 9738641 commit a73c8bcbf01f10e1f6a9d8a2c9e6a927f978f51f @normann normann committed with chillu Mar 12, 2012
Showing with 13 additions and 12 deletions.
  1. +13 −12 admin/thirdparty/chosen/chosen/chosen.jquery.js
@@ -1,12 +1,6 @@
-// Chosen, a Select Box Enhancer for jQuery and Protoype
-// by Patrick Filler for Harvest, http://getharvest.com
-//
-// Version 0.9.7
-// 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 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.
+
(function() {
var SelectParser;
@@ -302,8 +296,10 @@ Copyright (c) 2011 by Harvest
container_div = $("<div />", {
id: this.container_id,
"class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
- style: 'width: ' + this.f_width + 'px;'
+ //patch applied: https://github.com/harvesthq/chosen/issues/300
+ style: 'width: ' + (this.options.width || this.f_width + 'px;')
});
+
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 {
@@ -314,10 +310,13 @@ Copyright (c) 2011 by Harvest
this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
this.dropdown = this.container.find('div.chzn-drop').first();
dd_top = this.container.height();
- dd_width = this.f_width - get_side_border_padding(this.dropdown);
+ //patch applied: https://github.com/harvesthq/chosen/issues/300
+ dd_width = this.container.width() - get_side_border_padding(this.dropdown);
this.dropdown.css({
"width": dd_width + "px",
- "top": dd_top + "px"
+ "top": dd_top + "px",
+ //patch applied: https://github.com/harvesthq/chosen/issues/300
+ "width": dd_width
});
this.search_field = this.container.find('input').first();
this.search_results = this.container.find('ul.chzn-results').first();
@@ -558,6 +557,8 @@ Copyright (c) 2011 by Harvest
"left": 0
});
this.results_showing = true;
+ //patch applied: https://github.com/harvesthq/chosen/issues/300
+ this.search_field.css('width', (dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field)) + 'px');
this.search_field.focus();
this.search_field.val(this.search_field.val());
return this.winnow_results();

0 comments on commit a73c8bc

Please sign in to comment.