public void encodeBegin(
FacesContext facesContext, UIComponent uiComponent) throws IOException {
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
UIPopup component = (UIPopup) uiComponent;
final String clientId = component.getClientId(facesContext);
final String contentDivId = clientId + CONTENT_ID_POSTFIX;
//final String left = component.getLeft();
//final String top = component.getTop();
Integer zIndex = (Integer) component.getAttributes().get(TobagoConstants.ATTR_ZINDEX);
if (zIndex == null) {
zIndex = 0;
}
final StringBuilder contentStyle = new StringBuilder();
if (component.getWidth() != null) {
contentStyle.append("width: ");
contentStyle.append(component.getWidth());
contentStyle.append("; ");
}
if (component.getHeight() != null) {
contentStyle.append("height: ");
contentStyle.append(component.getHeight());
contentStyle.append("; ");
}
contentStyle.append("z-index: ");
contentStyle.append(zIndex + 3);
contentStyle.append("; ");
//contentStyle.append("left: ");
//contentStyle.append(left);
//contentStyle.append("; ");
//contentStyle.append("top: ");
//contentStyle.append(top);
//contentStyle.append("; ");
if (component.isModal()) {
writer.startElement(HtmlConstants.DIV, component);
writer.writeIdAttribute(clientId);
writer.writeStyleAttribute("z-index: " + (zIndex + 1) + ";");
writer.writeClassAttribute();
writer.writeAttribute(HtmlAttributes.ONCLICK, "Tobago.popupBlink('" + clientId + "')", null);
if (ClientProperties.getInstance(facesContext).getUserAgent().isMsie()) {
String bgImage = ResourceManagerUtil.getImageWithPath(facesContext, "image/popupBg.png");
writer.writeAttribute(HtmlAttributes.STYLE, "background: none; "
+ "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
+ bgImage + "', sizingMethod='scale');", false);
}
writer.endElement(HtmlConstants.DIV);
}
if (ClientProperties.getInstance(facesContext).getUserAgent().isMsie()) {
writer.startElement(HtmlConstants.IFRAME, component);
writer.writeIdAttribute(clientId + SUBCOMPONENT_SEP + HtmlConstants.IFRAME);
writer.writeClassAttribute("tobago-popup-iframe tobago-popup-none");
writer.writeStyleAttribute("z-index: " + (zIndex + 2) + ";");
UIPage page = ComponentUtil.findPage(facesContext);
final StringBuilder frameSize = new StringBuilder();
if (component.isModal()) {
// full client area
frameSize.append("width: ");
frameSize.append(page.getWidth());
frameSize.append("; ");
frameSize.append("height: ");
frameSize.append(page.getHeight());
frameSize.append("; ");
} else {
frameSize.append(contentStyle); // size of the popup
}
writer.writeAttribute(HtmlAttributes.STYLE, frameSize.toString(), false);
writer.writeAttribute(HtmlAttributes.SRC, ResourceManagerUtil.getBlankPage(facesContext), false);
writer.writeAttribute(HtmlAttributes.FRAMEBORDER, "0", false);
writer.endElement(HtmlConstants.IFRAME);
}
writer.startElement(HtmlConstants.DIV, component);
writer.writeIdAttribute(contentDivId);
StyleClasses styleClasses = new StyleClasses();
styleClasses.addClass("popup", "content");
styleClasses.addClass("popup", "none");
if (component.isModal()) {
styleClasses.addClass("popup", "modal");
}
writer.writeClassAttribute(styleClasses);
writer.writeAttribute(HtmlAttributes.STYLE, contentStyle.toString(), false);