//Temporary fix. IIf the select element is inside a hidden container
//GQuery cannot get the size of the select element.
if (fWidth == 0) {
$("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;" + (isRTL ?
"right" : "left") + ":-9000px; visibility:hidden'> </div>");
GQuery tempDiv = $("#gwt_chosen_temp_div");
tempDiv.append($selectElement.clone());
fWidth = tempDiv.children("select").outerWidth();
tempDiv.remove();
isHidden = fWidth > 0;
}
isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl");
String cssClasses = isRTL ? css.chznContainer() + " " + css.chznRtl() : css.chznContainer();
// recopy classes present on the select element
cssClasses += " " + selectElement.getClassName();
GQuery containerTemp =
$(ChozenTemplate.templates.container(containerId, cssClasses).asString()).width(fWidth);
final SafeStylesBuilder ssb = new SafeStylesBuilder();
if (isRTL) {
ssb.right(HORIZONTAL_OFFSET, Style.Unit.PX);
} else {
ssb.left(HORIZONTAL_OFFSET, Style.Unit.PX);
}
ssb.top(VERTICAL_OFFSET, Style.Unit.PX);
if (isMultiple) {
containerTemp.html(ChozenTemplate.templates.contentMultiple(css.chznChoices(),
css.searchField(), defaultText, css.defaultClass(), css.chznDrop(), css.chznResults(),
ssb.toSafeStyles())
.asString());
} else {
containerTemp.html(ChozenTemplate.templates.contentSingle(css.chznSingle(),
css.chznDefault(), defaultText, css.chznDrop(), css.chznSearch(), css.chznResults(),
ssb.toSafeStyles())
.asString());
}