portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r915190 - in /portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp: WEB-INF/jetui/yui/jetui-portlet.jsp WEB-INF/jetui/yui/jetui.jsp javascript/jetspeed/jetui/jetui-portal.js jetui/css/portal.css jetui/engine/portal.js
Date Tue, 23 Feb 2010 05:27:57 GMT
Author: taylor
Date: Tue Feb 23 05:27:57 2010
New Revision: 915190

URL: http://svn.apache.org/viewvc?rev=915190&view=rev
Log:
refactoring resize
persist width and height
handle maximize and minimize window states 

Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
    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/css/portal.css
    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-portlet.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp?rev=915190&r1=915189&r2=915190&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
Tue Feb 23 05:27:57 2010
@@ -29,7 +29,10 @@
 <%@ page import="org.apache.jetspeed.decoration.Decoration" %>
 <%@ page import="org.apache.jetspeed.decoration.DecoratorAction" %>
 <%@ page import="org.apache.jetspeed.PortalReservedParameters" %>
+<%@ page import="org.apache.jetspeed.container.PortletWindow" %>
+<%@ page import="javax.portlet.WindowState" %>
 <%
+	RequestContext rc = (RequestContext)request.getAttribute(RequestContext.REQUEST_PORTALENV);
     String content = (String)request.getAttribute("content");
     String decorator = (String)request.getAttribute("decorator");
     Boolean detached = (Boolean)request.getAttribute("detached");    
@@ -83,7 +86,32 @@
                 </div>
               </div>
                <div class="PContentBorder">
-                 <div class="PContent"><%=content%></div>
+<% if (request.getUserPrincipal() != null && detached != null) 
+{
+	PortletWindow win = rc.getPortletWindow(fragment.getId());
+	if (win.getWindowState().equals(WindowState.MINIMIZED))
+	{
+%>		
+        <div class="PContent"></div>                
+<%	
+	}
+	else
+	{
+		String x = fragment.getProperty(ContentFragment.X_PROPERTY_NAME);
+		String y = fragment.getProperty(ContentFragment.Y_PROPERTY_NAME);	
+		String h = fragment.getProperty(ContentFragment.HEIGHT_PROPERTY_NAME);
+		String w = fragment.getProperty(ContentFragment.WIDTH_PROPERTY_NAME);
+		if (x == null) x = "0"; if (y == null) y = "0";
+		if (h == null) h = "100"; if (w == null) w = "150";
+		int top = new Double(Double.parseDouble(h)).intValue() + 17; // FIXME: hardcoded 
+		double left = new Double(Double.parseDouble(w)).intValue();
+%>                 
+                 <div class="PContent" style='height: <%=h%>px; width: <%=w%>px;'><%=content%>
               
+                    <div class="resizeHandle" style='position: absolute; top: <%=top%>px;
left: <%=left%>px;'></div>
+<% } } else { %>
+                 <div class="PContent"><%=content%>                
+<% } %>                    
+                 </div>
                </div>
             </div>
           </div>

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=915190&r1=915189&r2=915190&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
Tue Feb 23 05:27:57 2010
@@ -104,7 +104,7 @@
 	portalContextPath: "<%=portalContextPath%>",
 	portalServletPath: "<%=portalServletPath%>",
 	portalPagePath: "<%=portalPagePath%>",
-	margins: [7, 4, 0]	
+	margins: [7, 4, 0, 17]	
 };
 var JETUI_YUI = {
   base: "<%=request.getContextPath()%>/javascript/yui/build/",
@@ -298,6 +298,8 @@
 {
 	String x = fragment.getProperty(ContentFragment.X_PROPERTY_NAME);
 	String y = fragment.getProperty(ContentFragment.Y_PROPERTY_NAME);
+	String h = fragment.getProperty(ContentFragment.HEIGHT_PROPERTY_NAME);
+	String w = fragment.getProperty(ContentFragment.WIDTH_PROPERTY_NAME);
 	int row = fragment.getLayoutRow();
     int col = fragment.getLayoutColumn();	
     String content = jetui.getRenderedContent((ContentFragment)fragment, rc);
@@ -305,7 +307,7 @@
     if (option == Decoration.ActionsOption.HIDE) // TODO: HOVER, DROP DOWN not yet implemented
     {
 %>
-   <div id='<%=fragment.getId()%>' detached='true' locked='<%=fragment.isLocked()%>'
name='<%=fragment.getName()%>' column='<%=col%>' row='<%=row%>' x='<%=x%>'
y='<%=y%>' style='position: absolute; top: <%=x%>px; left: <%=y%>px;'>
+   <div id='<%=fragment.getId()%>' detached='true' locked='<%=fragment.isLocked()%>'
name='<%=fragment.getName()%>' column='<%=col%>' row='<%=row%>' x='<%=x%>'
y='<%=y%>' style='position: absolute; top: <%=x%>px; left: <%=y%>px; height:
<%=h%>px; width: <%=w%>px;'>
 <%=content%>
    </div>			    
 <% } else {   

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=915190&r1=915189&r2=915190&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
Tue Feb 23 05:27:57 2010
@@ -148,7 +148,7 @@
         /**
          * Margins (resizeHandler, PContent left margin, PContent top margin
          */
-        margins: [7, 4, 0],
+        margins: [7, 4, 0, 17],
         
         /**
          * Construction logic executed during instantiation.
@@ -400,9 +400,11 @@
 			        	}
 		        	}
 	            }
-	            portal.addResizeHandle(window);
+	            portal.addResizeHandle(window, true);
 		        var uri = portal.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
 		        uri += "&x=" + x + "&y=" + y + "&layout=detach";
+		        var region = window.get('region');		        
+		        uri += "&w=" + (region.right - region.left) + "&h=" + (region.bottom -
region.top);
 		        var config = {
                       on: { complete: portal.onMoveComplete },
                       method: "PUT",
@@ -475,8 +477,9 @@
 	                i++;
 	            }
 	            layout.appendChild(window);
-	            portal.removeResizeHandle(window);
-	            portal.removeWidthHeight(window);
+	            var pcontent =  portal.findChildByClass(window, ['portlet', 'PContentBorder',
'PContent'], 0);
+	            portal.removeResizeHandle(pcontent);
+	            portal.removeWidthHeight(pcontent);
 	            var uri = portal.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
 	            uri += "&row=" + row + "&col=" + col + "&layout=attach";
 	            var config = {
@@ -542,7 +545,24 @@
             }        	
             // TODO: handle toolbar moves
         },
-                
+
+        /**
+         * @method resizePortlet persist the resize operation to the persistent store over
restful put request
+         */
+        resizePortlet : function(node, height, width) {
+            var portal = JETUI_YUI.getPortalInstance();
+            var windowId =  node.getAttribute('id');            
+            var uri = portal.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
+            uri += "&w=" + width + "&h=" + height;
+            var config = {
+                    on: { complete: portal.onMoveComplete },
+                    method: "PUT",
+                    headers: { "X-Portal-Path" : portal.portalPagePath },
+                    arguments: { complete: [ windowId ] }
+                };
+            var request = Y.io(uri, config);
+        },
+        
         reallocateColumn : function(column) {
     	    var columns = Y.Node.all(JetuiConfiguration.layoutStyle); 
     	    columns.each(function(v, k) {
@@ -759,16 +779,24 @@
         /**
          * @method addResizeHandle
          */        
-        addResizeHandle : function(v) {
+        addResizeHandle : function(v, alwaysAdd) {
             var portal = JETUI_YUI.getPortalInstance();        	
-        	var region = v.get('region');        	
-	        var mt = portal.calculateResizeMargin(v);
-	        var rh = Y.Node.create("<div class='resizeHandle'/>");
-        	rh.setStyle('position', 'absolute');
-			rh.setStyle('top', (region.bottom - region.top - mt) + "px");
-			rh.setStyle('left', (region.right - region.left - mt) + "px");        				        
-	        v.appendChild(rh);		        
-	        rh.data = 'resize';
+        	var pcontent = portal.findChildByClass(v, ['portlet', 'PContentBorder', 'PContent'],
0);
+        	var region = pcontent.get('region');
+        	var rh = portal.findChildByClass(pcontent, ['resizeHandle'], 0);
+	    	if (Y.Lang.isNull(rh)) {
+	    		if (alwaysAdd == false) {
+	    			return;
+	    		}
+		        var rh = Y.Node.create("<div class='resizeHandle'/>");
+	        	rh.setStyle('position', 'absolute');
+	        	pcontent.setStyle('height', (region.bottom - region.top) + "px")
+				pcontent.setStyle('width', (region.right - region.left) + "px");        				        
+	        	rh.setStyle('top', (region.bottom - region.top + portal.margins[3]) + "px");
+				rh.setStyle('left', (region.right - region.left) + "px");        				        
+		        pcontent.appendChild(rh);	    		
+	    	}
+	        rh.data = { kind: 'resize', window: v, parent: pcontent };
 	        var rhDrag = new Y.DD.Drag({
 	            node: rh,
 	            groups: [],
@@ -793,25 +821,8 @@
         },
 
         removeWidthHeight : function(v) {
-	 		v.get('children').each(function(v2,k2) {
-	 			var cl = v2.getAttribute('class');
-			    if (cl.indexOf('portlet') == 0) {
-			 		v2.get('children').each(function(v3,k3) {
-			 			var cl = v3.getAttribute('class');
-					    if (cl.indexOf('PContentBorder') == 0) {
-					    	v3.setStyle('width', '');
-					    	v3.setStyle('height', '');
-					 		v3.get('children').each(function(v4,k4) {
-					 			var cl = v4.getAttribute('class');
-							    if (cl.indexOf('PContent') == 0) {
-							    	v4.setStyle('width', '');
-							    	v4.setStyle('height', '');
-							    }
-					 		});
-					    }
-			 		});
-			    }
-	 		});        	        	
+	    	v.setStyle('width', '');
+	    	v.setStyle('height', '');
         },
         
         /**
@@ -845,7 +856,7 @@
 			     if (cl.indexOf(styles[index]) == 0) {
 			    	 if (index + 1 < styles.length) {
 			    		 index = index + 1;
-			    		 var res = portal.findChildByClass(v, styles, 1);
+			    		 var res = portal.findChildByClass(v, styles, index);
           	             if (!Y.Lang.isNull(res)) {
           	            	 result =  res;
           	            	 return result;

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/css/portal.css
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/css/portal.css?rev=915190&r1=915189&r2=915190&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/css/portal.css
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/css/portal.css
Tue Feb 23 05:27:57 2010
@@ -38,8 +38,8 @@
 }
 .resizeHandle {
     background:transparent url("layout_sprite.png") no-repeat -20px -60px;
-	height:14px;
-    width: 14px;
-    cursor: move;    
+	height:10px;
+    width: 9px;
+    cursor: move;
 }
 

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=915190&r1=915189&r2=915190&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
Tue Feb 23 05:27:57 2010
@@ -80,7 +80,7 @@
 		        dragGroups = ['detached'],	        
 		        dragMode = 'point';
 		        dropGroups = [];
-		        portal.addResizeHandle(v);
+		        portal.addResizeHandle(v, false);
 	        }
 	        if (portlet.get("tool") == false)
 	        {
@@ -167,18 +167,24 @@
     });
 	
     Y.DD.DDM.on('drag:end', function(e) {
-        var drag = e.target;
+    	var drag = e.target;
         if (drag.target) {
             drag.target.set('locked', false);
         }
+        var portal = JETUI_YUI.getPortalInstance();
         var srcNode = drag.get('node');
-        if (srcNode.data == 'resize') {
-	        var dragParent = srcNode.get('parentNode');
+        if (srcNode.data.kind == 'resize') {
+	        var dragParent = srcNode.data.parent; // DST: srcNode.get('parentNode');
 	        var region = dragParent.get('region');
-	        var mt = portal.calculateResizeMargin(dragParent);
-        	srcNode.setStyle('top', (region.bottom - region.top - mt) + "px");
-			srcNode.setStyle('left', (region.right - region.left - mt) + "px");        				      
 
-        	srcNode.setStyle('visibility', '');        	
+	    	var height = parseInt(dragParent.getStyle('height'));
+	    	var width = parseInt(dragParent.getStyle('width'));
+	        var top = height + portal.margins[3];
+	        var left = width;
+	        srcNode.setStyle('top', top + "px");
+	        srcNode.setStyle('left', left + "px");
+	        srcNode.set('innerHTML', '');
+        	srcNode.setStyle('visibility', '');   
+        	portal.resizePortlet(srcNode.data.window, height, width);
         	return;
         }
         if (drag.get('node').data.get("detached"))
@@ -201,11 +207,11 @@
     	var drag = e.target;
         var dragNode = drag.get('dragNode');
         var srcNode = drag.get('node');
-        if (srcNode.data == 'resize') {
-        	dragNode.set('innerHTML', srcNode.get('innerHTML'));
+        if (srcNode.data.kind == 'resize') {
+        	dragNode.set('innerHTML', '<b>...Move</b>'); //srcNode.get('innerHTML'));
         	srcNode.setStyle('visibility', 'hidden');
-            var dragParent = srcNode.get('parentNode');        	
-            portal.activateWindow(dragParent);                	                	
+            var dragWindow = srcNode.data.window; //srcNode.get('parentNode');        	
+            portal.activateWindow(dragWindow);                	                	
         	return;
     	}
         portal.activateWindow(srcNode);                	                	
@@ -230,23 +236,30 @@
     Y.DD.DDM.on('drag:drag', function(e) {
     	var drag = e.target;
         var srcNode = drag.get('node');    	
-        if (srcNode.data == 'resize') {
-	        var dragParent = drag.get('node').get('parentNode');
-	        var box = portal.findChildByClass(dragParent, ['portlet ', 'PContentBorder'], 0);
-	        var content = portal.findChildByClass(box, ['PContent'], 0);	        
-	    	var left = parseInt(dragParent.getStyle('left'));
-	    	var top =  parseInt(dragParent.getStyle('top'));
+        if (srcNode.data.kind == 'resize') {
+	        var dragWindow = srcNode.data.window; // DST: drag.get('node').get('parentNode');
+	        var box = srcNode.data.parent.get('parentNode');
+	        var content = srcNode.data.parent;
+//	        var box = portal.findChildByClass(dragParent, ['portlet ', 'PContentBorder'],
0);
+//	        var content = portal.findChildByClass(box, ['PContent'], 0);	        
+	    	var left = parseInt(dragWindow.getStyle('left'));
+	    	var top =  parseInt(dragWindow.getStyle('top'));
 	    	var width = (drag.mouseXY[0] - left) + "px";
 	    	var height = (drag.mouseXY[1] - top) + "px";
-	    	if (!Y.Lang.isNull(box)) {
-		    	box.setStyle('width', width);
-		    	box.setStyle('height', height);
-	    	}	    	
+//	    	dragWindow.setStyle('width', width);
+//	    	dragWindow.setStyle('height', height);
+	    	
+//	    	if (!Y.Lang.isNull(box)) {
+//		    	box.setStyle('width', width);
+//		    	box.setStyle('height', height);
+//	    	}	    	
 	    	if (!Y.Lang.isNull(content)) {
-		    	content.setStyle('width', (drag.mouseXY[0] - left - portal.margins[1]) + "px"); 
-		    	content.setStyle('height', (drag.mouseXY[1] - top - portal.margins[2]) + "px");
+//		    	content.setStyle('width', (drag.mouseXY[0] - left - portal.margins[1]) + "px");

+//		    	content.setStyle('height', (drag.mouseXY[1] - top - portal.margins[2]) + "px");
+		    	content.setStyle('width', width);
+		    	content.setStyle('height', height);
 	    	}	    	
-	    	var region = dragParent.get('region');
+//	    	var region = dragParent.get('region');
         }
     });
     



---------------------------------------------------------------------
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