This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
/
UIContainer.gtmpl
89 lines (82 loc) · 3.78 KB
/
UIContainer.gtmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<%
import org.exoplatform.commons.utils.ExpressionUtil;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.commons.utils.HTMLEntityEncoder;
import org.exoplatform.portal.webui.workspace.UIPortalApplication.EditMode;
def rcontext = _ctx.getRequestContext();
ResourceBundle res = rcontext.getApplicationResourceBundle();
UIPortalApplication uiPortalApp = rcontext.getUIApplication();
boolean hasAccessPermission = uicomponent.hasAccessPermission();
if(!uiPortalApp.isEditing() && !hasAccessPermission) return;
EditMode editMode = uiPortalApp.getEditMode();
String cssStyle = "";
String uiComponentWidth = uicomponent.getWidth();
String uiComponentHeight = uicomponent.getHeight();
if(uiComponentWidth != null || uiComponentHeight != null) cssStyle = "style=\"";
if(uiComponentWidth != null) cssStyle += "width: "+uiComponentWidth+";"
if(uiComponentHeight != null) cssStyle += "height: "+uiComponentHeight+";"
if(cssStyle.length() > 0) cssStyle += "\"";
/** Trim the prefix UIContainer- if any, this hardcoded part is needed to update nested container via Ajax */
String componentId = uicomponent.getId();
if(componentId.startsWith("UIContainer-")){
uicomponent.setId(componentId.substring("UIContainer-".length()));
}
if (uiPortalApp.isEditing())
{
def reqJS = rcontext.getJavascriptManager().require("SHARED/portal", "portal");
reqJS.addScripts("portal.UIPortal.initMouseHover('" + uicomponent.id + "');");
%>
<div class="UIContainer EdittingContainer<%=uicomponent.getPermissionClasses()%>"
id="${uicomponent.id}" ${cssStyle}>
<%
}
else
{
%>
<div class="UIContainer <%=hasAccessPermission?"": "ProtectedContainer"%>" id="${uicomponent.id}" ${cssStyle}>
<%
}
%>
<div class="NormalContainerBlock UIComponentBlock">
<%
if (editMode == EditMode.BLOCK) {
%>
<div class="LAYOUT-CONTAINER LAYOUT-BLOCK">
<%} else {%>
<div class="VIEW-CONTAINER VIEW-BLOCK">
<%} %>
<%if(hasAccessPermission) {%>
<div>
<div class="UIRowContainer <%=(editMode != EditMode.NO_EDIT && uicomponent.getChildren().size() == 0) ? "EmptyContainer" : ""%>">
<%uicomponent.renderChildren();%>
</div>
</div>
<%} else out.print("<div class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>");%>
</div>
<%if (editMode != EditMode.NO_EDIT) {%>
<div class="EDITION-BLOCK EDITION-CONTAINER" style="display: none;position: relative;">
<div style="position: absolute; top: -86px;">
<div class="NewLayer" style="display: none; visibility: hidden;"><span></span></div>
<div class="CONTROL-CONTAINER CONTROL-BLOCK UIInfoBar">
<%/*Begin InfoBar*/%>
<div class="BlueRoundedStyle ClearFix">
<div class="DragControlArea" title="<%=_ctx.appRes("UIContainer.title.DragControlArea")%>"><span></span></div>
<%
String strTitle = uicomponent.getTitle() != null ?
ExpressionUtil.getExpressionValue(res, uicomponent.getTitle()) :
_ctx.appRes("UIContainer.title.Container");
strTitle = hasAccessPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent");
%>
<div class="ContainerIcon"><%=HTMLEntityEncoder.getInstance().encode(strTitle)%></div>
<%if(hasAccessPermission) {%>
<a href="javascript:void(0);" onclick="<%=uicomponent.event("EditContainer")%>" class="EditIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"></a>
<a href="javascript:void(0);" onclick="<%=uicomponent.event("DeleteComponent")%>" class="DeleteIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
<%/*End InfoBar*/ %>
</div>
</div>
</div>
<%} %>
</div>
</div>