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

This commit is contained in:
Normann Lou 2012-03-12 09:50:19 +01:00 committed by Ingo Schommer
parent 97386413d6
commit a73c8bcbf0

View File

@ -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
//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.
// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
// This file is generated by `cake build`, do not edit it by hand.
(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();