Rendering.renderHiddenField(writer, clientId + LEFT_HIDDEN_FIELD_SUFFIX, popup.getLeft());
Rendering.renderHiddenField(writer, clientId + TOP_HIDDEN_FIELD_SUFFIX, popup.getTop());
// Rendering.renderHiddenField(writer, clientId + ANCHOR_HIDDEN_FIELD_SUFFIX, popupInvokerId);
if (popup.getHideOnOuterClick()) {
ScriptBuilder buf = new ScriptBuilder();
buf.functionCall("O$.Popup._init", clientId).semicolon();
Rendering.renderInitScript(context, buf,
Resources.utilJsURL(context),
Resources.internalURL(context, "popup.js"));
}
ScriptBuilder sb = new ScriptBuilder();
String width = popup.getWidth();
if (width == null && popup.getAutosizing() != Autosizing.ON)
width = getDefaultWidth();
String height = popup.getHeight();
if (height == null && popup.getAutosizing() != Autosizing.ON)
height = getDefaultHeight();
String modalLayerClass = popup.isModal() ? Styles.getCSSClass(context,
popup, popup.getModalLayerStyle(),
getDefaultModalLayerClass(),
popup.getModalLayerClass()) : null;
sb.initScript(context, popup, "O$.PopupLayer._init",
popup.getLeft(),
popup.getTop(),
width,
height,
Rendering.getRolloverClass(context, popup),
popup.getHidingTimeout(),
popup.getDraggable(),
popup.getAutosizing(),
modalLayerClass,
popup.getHideOnEsc(),
Environment.isAjax4jsfRequest(),
popup.getContainment(),
popup.getContainmentRole());
String onShow = popup.getOnshow();
if (onShow != null) {
sb.append("\nO$('").append(clientId).append("').onshow = function (event) {"); // todo: refactor passing events into passing them as a single JSON param to the initialization function
sb.append(onShow);
sb.append("};");
}
String onHide = popup.getOnhide();
if (onHide != null) {
sb.append("\nO$('").append(clientId).append("').onhide = function (event) {");
sb.append(onHide);
sb.append("};");
}
String ondragstart = popup.getOndragstart();
if (ondragstart != null) {
sb.append("\nO$('").append(clientId).append("').ondragstart = function (event) {");
sb.append(ondragstart);
sb.append("};");
}
String ondragend = popup.getOndragend();
if (ondragend != null) {
sb.append("\nO$('").append(clientId).append("').ondragend = function (event) {");
sb.append(ondragend);
sb.append("};");
}
if (popupInvokerId != null) {
sb.append("\nO$('");
sb.append(clientId);
sb.append("').attachToElement(O$('").append(popupInvokerId).append("'), ");
sb.append(nullOrJsString(popup.getAnchorX()));
sb.append(", ");
sb.append(nullOrJsString(popup.getAnchorY()));
sb.append(");");
}
Rendering.renderInitScript(context, sb,
Resources.utilJsURL(context),
Resources.internalURL(context, "window/popupLayer.js"));