Author: woonsan
Date: Mon Dec 14 16:12:20 2009
New Revision: 890391
URL: http://svn.apache.org/viewvc?rev=890391&view=rev
Log:
JS2-1084: portlet window addition from the client-side script without page
refresh.
Modified:
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/javascript/jetspeed/jetui/jetui-portal.js
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
Modified:
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp?rev=890391&r1=890390&r2=890391&view=diff
==============================================================================
---
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
(original)
+++
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
Mon Dec 14 16:12:20 2009
@@ -46,7 +46,14 @@
encoding += "; charset=" + response.getCharacterEncoding();
}
String baseUrl = jetui.getBaseURL(rc);
- String pageDec = jetui.getTheme(rc).getPageLayoutDecoration().getName();
+ String pageDec = jetui.getTheme(rc).getPageLayoutDecoration().getName();
+
+ String portalContextPath = request.getContextPath();
+ String portalServletPath = request.getServletPath();
+ String portalPagePath = rc.getPortalURL().getPath();
+ if (portalPagePath == null || "".equals(portalPagePath)) {
+ portalPagePath = "/";
+ }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
@@ -62,7 +69,10 @@
dragMode:
"<%=pc.getString(PortalConfigurationConstants.JETUI_DRAG_MODE)%>",
portletStyle:
"<%=pc.getString(PortalConfigurationConstants.JETUI_STYLE_PORTLET)%>",
layoutStyle:
"<%=pc.getString(PortalConfigurationConstants.JETUI_STYLE_LAYOUT)%>",
- dragHandleStyle:
"<%=pc.getString(PortalConfigurationConstants.JETUI_STYLE_DRAG_HANDLE)%>"
+ dragHandleStyle:
"<%=pc.getString(PortalConfigurationConstants.JETUI_STYLE_DRAG_HANDLE)%>",
+ portalContextPath: "<%=portalContextPath%>",
+ portalServletPath: "<%=portalServletPath%>",
+ portalPagePath: "<%=portalPagePath%>"
};
var JETUI_YUI = {
base: "<%=request.getContextPath()%>/javascript/yui/build/",
@@ -206,7 +216,7 @@
</div> <!-- end layout -->
</div>
-</body>
+
<%
for (ContentFragment fragment : columnLayout.getDetachedPortlets())
{
@@ -220,5 +230,18 @@
<% } %>
<script src="<%=request.getContextPath()%>/jetui/engine/portal.js"></script>
-
+
+<div id="jsPortletTemplate" class="portal-layout-cell yui-dd-draggable
yui-dd-drop" style="display: none">
+ <div class="portlet <%=pageDec%>">
+ <div class="PTitle">
+ <div class="PTitleContent">Loading..L</div>
+ <div class="PActionBar"></div>
+ </div>
+ <div class="PContentBorder">
+ <div class="PContent"></div>
+ </div>
+ </div>
+</div>
+
+</body>
</html>
Modified:
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/javascript/jetspeed/jetui/jetui-portal.js
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/javascript/jetspeed/jetui/jetui-portal.js?rev=890391&r1=890390&r2=890391&view=diff
==============================================================================
---
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/javascript/jetspeed/jetui/jetui-portal.js
(original)
+++
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/javascript/jetspeed/jetui/jetui-portal.js
Mon Dec 14 16:12:20 2009
@@ -55,6 +55,24 @@
Y.extend(Y.JetUI.Portal, Y.Base, {
/**
+ * @property portal context path
+ * @type String
+ */
+ portalContextPath : "",
+
+ /**
+ * @property portal base path
+ * @type String
+ */
+ portalServletPath : "",
+
+ /**
+ * @property portal page path
+ * @type String
+ */
+ portalPagePath : "/",
+
+ /**
* @property desktopMode
* @type Boolean
*/
@@ -215,6 +233,64 @@
groups: ['portlets']
});
}
+ },
+
+ /**
+ * @method onPortletRenderComplete
+ */
+ onPortletRenderComplete : function(id, o, args) {
+ var id = id;
+ var v = args.complete;
+ var data = o.responseText;
+ var title = o.getResponseHeader("JS_PORTLET_TITLE");
+ var children = v.getElementsByTagName("DIV");
+ children.each(function(v, k) {
+ if (v.hasClass("PTitleContent")) {
+ v.setContent(title);
+ } else if (v.hasClass("PContent")) {
+ v.setContent(data);
+ }
+ });
+ },
+
+ /**
+ * @method addPortlet
+ */
+ addPortlet : function(fragment) {
+ if (!JETUI_YUI || !JETUI_YUI.portalInstance)
+ return;
+
+ var portal = JETUI_YUI.portalInstance;
+ var templatePanel = Y.Node.one("#jsPortletTemplate");
+ var v = templatePanel.cloneNode(true);
+ v.setStyle('display', '');
+ v.set("id", fragment.id);
+ v.setAttribute("name", fragment.name);
+ v.setAttribute("row", fragment.properties.row);
+ v.setAttribute("column", fragment.properties.column);
+ var portlet = Y.JetUI.Portlet.attach(v);
+ var dragGroups = ['portlets'];
+ var dragMode = 'intersect';
+ var dropGroups = ['portlets', 'toolbars'];
+ if (portlet.get("toolbar") == false) {
+ var ddNav = new Y.DD.Drag({
+ node: v,
+ groups: dragGroups,
+ dragMode: dragMode
+ }).plug(Y.Plugin.DDProxy, {
+ moveOnEnd: false
+ });
+ ddNav.addHandle(JetuiConfiguration.dragHandleStyle);
+ var drop = new Y.DD.Drop({
+ node: v,
+ groups: dropGroups
+ });
+ }
+ var columns = Y.Node.all('.portal-layout-column');
+ columns.item(parseInt(fragment.properties.column)).appendChild(v);
+
+ var uri = portal.portalContextPath + "/portlet" +
portal.portalPagePath + "?entity=" + fragment.id;
+ var request = Y.io(uri, { on: { complete:
this.onPortletRenderComplete }, arguments: { complete: v } } );
}
});
@@ -292,7 +368,23 @@
Y.log("---------");
}
});
-
+
+ /**
+ * Create a portlet window and attach the portlet window to the sepcified
node.
+ * @method attach
+ */
+ Y.JetUI.Portlet.attach = function(node) {
+ var portlet = new Y.JetUI.Portlet();
+ portlet.set("name", node.getAttribute("name"));
+ portlet.set("id", node.getAttribute("id"));
+ portlet.set("toolbar",
Boolean(node.getAttribute("locked").toLowerCase() === 'true'));
+ portlet.set("detached", false);
+ portlet.set("column", node.getAttribute("column"));
+ portlet.set("row", node.getAttribute("row"));
+ node.data = portlet;
+ return portlet;
+ };
+
/**
* Create a layout window to represent a layout window.
*
@@ -368,4 +460,22 @@
}
});
+ /**
+ * Create a layout and attach the layout to the sepcified node.
+ * @method attach
+ */
+ Y.JetUI.Layout.attach = function(node) {
+ var layout = new Y.JetUI.Layout();
+ layout.set("name", node.getAttribute("name"));
+ layout.set("id", node.getAttribute("id"));
+ layout.set("nested", false);
+ var locked = node.getAttribute("locked");
+ locked = (locked == null || locked == "false") ? false : true;
+ layout.set("locked", locked);
+ layout.set("column", node.getAttribute("column"));
+ layout.set("row", 0);
+ node.data = layout;
+ return layout;
+ };
+
}, '3.0.0', {requires:['dd', 'io', 'dataschema-json', 'node-base',
'node-menunav']});
Modified:
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js?rev=890391&r1=890390&r2=890391&view=diff
==============================================================================
---
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
(original)
+++
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
Mon Dec 14 16:12:20 2009
@@ -9,6 +9,9 @@
JETUI_YUI.portalInstance = new Y.JetUI.Portal();
}
var portal = JETUI_YUI.portalInstance;
+ portal.portalContextPath = config.portalContextPath;
+ portal.portalServletPath = config.portalServletPath;
+ portal.portalPagePath = config.portalPagePath;
////////////////////////////////////////////////////
// Create Navigator Portlet
@@ -133,15 +136,8 @@
}
var draggablePortlets = Y.Node.all(config.portletStyle);
draggablePortlets.each(function(v, k) {
- var portlet = new Y.JetUI.Portlet();
+ var portlet = Y.JetUI.Portlet.attach(v);
//Y.log("portlet = " + v.getAttribute("name") + v.getAttribute("id") +
"locked = " + v.getAttribute("locked"));
- portlet.set("name", v.getAttribute("name"));
- portlet.set("id", v.getAttribute("id"));
- portlet.set("toolbar", Boolean(v.getAttribute("locked").toLowerCase()
=== 'true'));
- portlet.set("detached", false);
- portlet.set("column", v.getAttribute("column"));
- portlet.set("row", v.getAttribute("row"));
- v.data = portlet;
var dragGroups = ['portlets'];
var dragMode = 'intersect';
var dropGroups = ['portlets', 'toolbars'];
@@ -169,16 +165,7 @@
var dropLayouts = Y.Node.all(config.layoutStyle);
dropLayouts.each(function(v, k) {
//Y.log("layout = " + v.getAttribute("name") + v.getAttribute("id"));
- var layout = new Y.JetUI.Layout();
- layout.set("name", v.getAttribute("name"));
- layout.set("id", v.getAttribute("id"));
- layout.set("nested", false);
- var locked = v.getAttribute("locked");
- locked = (locked == null || locked == "false") ? false : true;
- layout.set("locked", locked);
- layout.set("column", v.getAttribute("column"));
- layout.set("row", 0);
- v.data = layout;
+ var layout = Y.JetUI.Layout.attach(v);
//layout.info();
if (v.get('children').size() == 0)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]