Search in sources :

Example 1 with Dialog

use of com.liferay.faces.alloy.component.dialog.Dialog in project liferay-faces-alloy by liferay.

the class DialogRenderer method encodeJavaScriptCustom.

@Override
public void encodeJavaScriptCustom(FacesContext facesContext, UIComponent uiComponent) throws IOException {
    ResponseWriter responseWriter = facesContext.getResponseWriter();
    Dialog dialog = (Dialog) uiComponent;
    ClientComponent clientComponent = (ClientComponent) uiComponent;
    String clientVarName = getClientVarName(facesContext, clientComponent);
    String clientKey = clientComponent.getClientKey();
    if (clientKey == null) {
        clientKey = clientVarName;
    }
    encodeLiferayComponentVar(responseWriter, "dialog", clientKey);
    // Prevent scrolling when the show() JavaScript function is called.
    responseWriter.write("var ");
    responseWriter.write(clientKey);
    responseWriter.write("_scrollx=window.scrollX;");
    responseWriter.write("var ");
    responseWriter.write(clientKey);
    responseWriter.write("_scrolly=window.scrollY;");
    responseWriter.write("A.Do.before(function(stuff) { ");
    responseWriter.write(clientKey);
    responseWriter.write("_scrollx=window.scrollX; ");
    responseWriter.write(clientKey);
    responseWriter.write("_scrolly=window.scrollY;},Liferay.component('");
    responseWriter.write(clientKey);
    responseWriter.write("'),'show');");
    responseWriter.write("A.Do.after(function(stuff){window.scrollTo(");
    responseWriter.write(clientKey);
    responseWriter.write("_scrollx,");
    responseWriter.write(clientKey);
    responseWriter.write("_scrolly);},Liferay.component('");
    responseWriter.write(clientKey);
    responseWriter.write("'),'show');");
    // FACES-2209 remove class="hide" from the "mask" div that is used for modal dialogs
    // the mask div is placed as the first child of the parent of the dialog
    // removing this class allows a modal dialog to be fully rendered upon a partial request.
    responseWriter.write("var " + clientKey + "_mask=A.one('#");
    String clientId = dialog.getClientId(facesContext);
    String escapedBoundingBoxClientId = ComponentUtil.escapeClientId(clientId);
    responseWriter.write(escapedBoundingBoxClientId);
    responseWriter.write("').ancestor().one('.hide');");
    responseWriter.write("if (");
    responseWriter.write(clientKey);
    responseWriter.write("_mask) { ");
    responseWriter.write(clientKey);
    responseWriter.write("_mask.removeClass('hide') }; ");
    if (!dialog.isHideIconRendered()) {
        responseWriter.write("dialog.removeToolbar('header');");
    }
    // move the overlayBody div into the modal-body div
    String overlayBodyClientId = clientId.concat(OVERLAY_BODY_SUFFIX);
    String escapedOverlayBodyClientId = ComponentUtil.escapeClientId(overlayBodyClientId);
    String contentBoxClientId = clientId.concat(CONTENT_BOX_SUFFIX);
    String escapedContentBoxClientId = ComponentUtil.escapeClientId(contentBoxClientId);
    responseWriter.write("A.one('#");
    responseWriter.write(escapedOverlayBodyClientId);
    responseWriter.write("').appendTo(A.one('div#");
    responseWriter.write(escapedContentBoxClientId);
    responseWriter.write(">div.modal-body'));");
    if (!dialog.isModal() && dialog.isDismissible()) {
        encodeOverlayDismissible(responseWriter, dialog, clientKey);
    }
    JavaScriptFragment dialogJavaScriptFragment = new JavaScriptFragment("dialog");
    encodeFunctionCall(responseWriter, "LFAI.initDialog", dialogJavaScriptFragment);
    encodeOverlayJavaScriptCustom(responseWriter, facesContext, dialog, clientKey);
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) Dialog(com.liferay.faces.alloy.component.dialog.Dialog) JavaScriptFragment(com.liferay.faces.util.render.JavaScriptFragment) ClientComponent(com.liferay.faces.util.component.ClientComponent)

Example 2 with Dialog

use of com.liferay.faces.alloy.component.dialog.Dialog in project liferay-faces-alloy by liferay.

the class DialogRenderer method getModules.

@Override
public String[] getModules(FacesContext facesContext, UIComponent uiComponent) {
    String[] modules = MODULES;
    Dialog dialog = (Dialog) uiComponent;
    if (!dialog.isModal() && dialog.isDismissible()) {
        modules = StringHelper.append(modules, "event-move");
    }
    return modules;
}
Also used : Dialog(com.liferay.faces.alloy.component.dialog.Dialog)

Example 3 with Dialog

use of com.liferay.faces.alloy.component.dialog.Dialog in project liferay-faces-alloy by liferay.

the class DialogRendererBase method encodeAlloyAttributes.

@Override
public void encodeAlloyAttributes(FacesContext facesContext, ResponseWriter responseWriter, UIComponent uiComponent) throws IOException {
    Dialog dialog = (Dialog) uiComponent;
    boolean first = true;
    String height = dialog.getHeight();
    if (height != null) {
        encodeHeight(responseWriter, dialog, height, first);
        first = false;
    }
    Boolean modal = dialog.isModal();
    if (modal != null) {
        encodeModal(responseWriter, dialog, modal, first);
        first = false;
    }
    String width = dialog.getWidth();
    if (width != null) {
        encodeWidth(responseWriter, dialog, width, first);
        first = false;
    }
    Integer zIndex = dialog.getzIndex();
    if (zIndex != null) {
        encodeZIndex(responseWriter, dialog, zIndex, first);
        first = false;
    }
    encodeHiddenAttributes(facesContext, responseWriter, dialog, first);
}
Also used : Dialog(com.liferay.faces.alloy.component.dialog.Dialog)

Aggregations

Dialog (com.liferay.faces.alloy.component.dialog.Dialog)3 ClientComponent (com.liferay.faces.util.component.ClientComponent)1 JavaScriptFragment (com.liferay.faces.util.render.JavaScriptFragment)1 ResponseWriter (javax.faces.context.ResponseWriter)1