portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r891812 - /portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Date Thu, 17 Dec 2009 17:44:40 GMT
Author: woonsan
Date: Thu Dec 17 17:44:40 2009
New Revision: 891812

URL: http://svn.apache.org/viewvc?rev=891812&view=rev
Log:
JS2-1057: Adding preview for portlets

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp?rev=891812&r1=891811&r2=891812&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Thu Dec 17 17:44:40 2009
@@ -115,8 +115,8 @@
 	    </tr>       
 	    <tr>
 	       <td class="portlet-section-body">
-	           <a href="#">Preview</a>  
-	           <a href="#">Add</a>
+	           <a href="#" name="preview">Preview</a>  
+	           <a href="#" name="add">Add</a>
 	       </td>
 	    </tr>
     </table>
@@ -185,8 +185,13 @@
     </tr>
 </table>
 
+<div id="<portlet:namespace/>previewPanel" style="BACKGROUND: #eee; BORDER: lightgrey
solid 1px; POSITION: absolute; Z-INDEX: 1000; VISIBILITY: hidden">
+  <div></div>
+  <div align="right"><a href="#">Close</a></div>
+</div>
+
 <script language="javascript">
-YUI().use('jetui-portal', 'io', 'json', 'node-base', 'cookie', function(Y) {
+YUI().use('jetui-portal', 'io', 'json', 'node', 'cookie', function(Y) {
 
     var pagination = {
             portlet : { uri : null, totalSize : 0, pageSize : ${portletPageSize}, beginIndex
: 0 },
@@ -315,15 +320,18 @@
 
             <c:choose>
 	            <c:when test="${editAccess}">
-	                Y.Node.getDOMNode(clone.all("a").item(1)).setAttribute("portletUniqueName",
def.uniqueName);
-	                clone.all("a").item(1).on("click", addPortlet);
+	                var addLink = clone.one("[name='add']");
+	                Y.Node.getDOMNode(addLink).setAttribute("portletUniqueName", def.uniqueName);
+	                addLink.on("click", addPortlet);
 	            </c:when>
 	            <c:otherwise>
 	                clone.all("a").item(1).remove();
 	            </c:otherwise>
 	        </c:choose>
             
-            // TODO: add handlers for preview
+            var previewLink = clone.one("[name='preview']");
+            Y.Node.getDOMNode(previewLink).setAttribute("portletUniqueName", def.uniqueName);
+            previewLink.on("click", previewPortlet);
             
             clone.set("id", "<portlet:namespace/>portletItem-" + def.uniqueName);
             
@@ -456,6 +464,40 @@
         e.halt();
     };
     
+    var onPreviewPortletComplete = function(id, o, args) {
+        var point = args.complete;
+        var panel = Y.Node.one("#<portlet:namespace/>previewPanel");
+        var subPanels = panel.all("DIV");
+        subPanels.item(0).setContent(o.responseText);
+        var panelDOMNode = Y.Node.getDOMNode(panel);
+
+        var panelWidth = Math.max(panelDOMNode.offsetWidth, 200);
+        var panelHeight = Math.max(panelDOMNode.offsetHeight, 150);
+        var windowWidth = window.innerWidth;
+        var windowHeight = window.innerHeight;
+        if (point[0] > windowWidth - panelWidth) point[0] = windowWidth - panelWidth;
+        if (point[1] > windowHeight - panelHeight) point[1] = windowHeight - panelHeight;
+        
+        panel.setXY(point);
+        panelDOMNode.style.visibility = "visible";
+    };
+    
+    var previewPortlet = function(e) {
+        var a = Y.Node.getDOMNode(e.target);
+        var portletUniqueName = a.getAttribute("portletUniqueName");
+        if (portletUniqueName) {
+            var uri = "${portalContextPath}/portlet/?mode=preview&portlet=" + portletUniqueName
+ "&entity=" + portletUniqueName;
+            var request = Y.io(uri, { on: { complete: onPreviewPortletComplete }, arguments:
{ complete: [ e.pageX, e.pageY ] } });
+        }
+        
+        e.halt();
+    };
+
+    var closePreviewPanel = function(e) {
+        var panel = Y.Node.one("#<portlet:namespace/>previewPanel");
+        Y.Node.getDOMNode(panel).style.visibility = "hidden";
+    };
+    
     Y.on("click", switchTab, "#<portlet:namespace/>portletsTabAction");
     Y.on("click", switchTab, "#<portlet:namespace/>layoutTabAction");
     Y.on("click", switchTab, "#<portlet:namespace/>themeTabAction");
@@ -476,5 +518,7 @@
     }
     
     switchTab(tabId);
+
+    Y.Node.one("#<portlet:namespace/>previewPanel").one("A").on("click", closePreviewPanel);
 });
 </script>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message