portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r891959 - in /portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp: WEB-INF/jetui/yui/jetui-portlet.jsp decorations/images/detach.gif javascript/jetspeed/jetui/jetui-portal.js jetui/engine/portal.js
Date Thu, 17 Dec 2009 22:42:09 GMT
Author: taylor
Date: Thu Dec 17 22:42:08 2009
New Revision: 891959

URL: http://svn.apache.org/viewvc?rev=891959&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-1084
refactoring of movePortlet logic, moving down persistMove to portal.movePortlet with handlers,
renaming portal.movePortlet to portal.moveToGrid
start hooking in detach 

Added:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/images/detach.gif
  (with props)
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/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-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=891959&r1=891958&r2=891959&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
Thu Dec 17 22:42:08 2009
@@ -60,7 +60,9 @@
 if (request.getUserPrincipal() != null && fragment.getDecoration().getActions().size()
> 0)
 {
 %>
-                 <span style='cursor: pointer; z-index: 1000;' id='jetspeed-close-<%=fragment.getId()%>'
title="close" class="portlet-action-close"><img src="<%=request.getContextPath()%>/decorations/portlet/jetspeed/images/close.gif"
alt="Close" border="0" /></span>              
+                 <span style='cursor: pointer; z-index: 1000;' id='jetspeed-close-<%=fragment.getId()%>'
title="close" class="portlet-action-close"><img src="<%=request.getContextPath()%>/decorations/images/close.gif"
alt="Close" border="0" /></span>              
+                 <span style='cursor: pointer; z-index: 1000;' id='jetspeed-detach-<%=fragment.getId()%>'
title="detach" class="portlet-action-detach"><img src="<%=request.getContextPath()%>/decorations/images/detach.gif"
alt="Detach" border="0" /></span>              
+
 <% }  } %>
                 </div>
               </div>

Added: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/images/detach.gif
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/images/detach.gif?rev=891959&view=auto
==============================================================================
Binary file - no diff available.

Propchange: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/images/detach.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

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=891959&r1=891958&r2=891959&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
Thu Dec 17 22:42:08 2009
@@ -179,7 +179,8 @@
         },
         
         /**
-         * @method moveToLayout
+         * @method moveToLayout moves a portlet window to layout column grid position in
the browser
+         * this is a client side only operation. Operates in grid (non-detached) mode.
          */
         moveToLayout : function(e) {
             var drop = e.drop.get('node'),
@@ -206,11 +207,12 @@
             // I don't think this is working
             e.drop.unplug(Y.Plugin.Drop);
         },
-        
+ 
         /**
-         * @method movePortlet
+         * @method moveToGrid moves a portlet window to another grid position in the browser
+         * this is a client side only operation. Operates in grid (non-detached) mode.
          */
-        movePortlet : function(e) {
+        moveToGrid : function(e) {
             var portal = JETUI_YUI.getPortalInstance();
             var drop = e.drop.get('node'),
                 drag = e.drag.get('node');
@@ -250,10 +252,93 @@
                     node: dragParent,
                     groups: ['portlets']            
                 });
-            }        
+            }                           
         },
+
+        /**
+         * @method detachPortlet detaches a portlet from a grid position and moves it to
a z-order top detached window
+         */
+        detachPortlet : function(e) {
+            var portal = JETUI_YUI.getPortalInstance();
+            var windowId = null;
+            if (e instanceof String) {
+                windowId = e;
+            } else {
+                var windowId = e.currentTarget.getAttribute("id");
+                windowId = windowId.replace(/^jetspeed-detach-/, "");
+            }
+            var window = Y.one("[id='" + windowId + "']");
+            if (window) {
+                Y.log("data = " + window.data.get("name"));            	
+            }
+            // TODO: left off here
+        },
+        
+        onMoveComplete : function(id, o, args) { 
+            var id = id; // Transaction ID. 
+            var data = o.responseText; // Response data.
+            Y.log("move result = " + data);
+            var windowId = args.complete[0];
+        },             
         
         /**
+         * @method movePortlet persist the move operation to the persistent store over restful
put request
+         */
+        movePortlet : function(drag, e) {
+            var windowId =  drag.getAttribute('id');
+            if (drag.data.get("toolbar") == false) {
+            	var oldColumn = drag.data.get('column');
+            	var oldRow = drag.data.get('row');        	
+        		var dragParent = drag.get('parentNode');
+            	var parentColumn = dragParent.data.get('column');
+            	if (parentColumn != oldColumn)
+            	{
+            		this.reallocateColumn(oldColumn); // moved from different column
+            		drag.data.set('column', parentColumn);
+            	}
+            	this.reallocateColumn(parentColumn);
+                var uri = this.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
+                uri += "&col=" + drag.data.get('column') + "&row=" + drag.data.get('row');
+                var config = {
+                        on: { complete: this.onMoveComplete },
+                        method: "PUT",
+                        headers: { "X-Portal-Path" : this.portalPagePath },
+                        arguments: { complete: [ windowId ] }
+                    };
+                var request = Y.io(uri, config);
+            }    	
+            else
+            {
+                var uri = this.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
+                uri += "&x=" + e.target.region.top + "&y=" + e.target.region.left;
+                var config = {
+                        on: { complete: this.onMoveComplete },
+                        method: "PUT",
+                        headers: { "X-Portal-Path" : this.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) {
+    	    	if (v.data.get('locked') == false)
+    	    	{
+    		    	if (v.data.get('column') == column)
+    		    	{
+    		    		var row = 0;
+    	    			v.get('children').each(function(v,k) {
+    		    			v.data.set('row', row);
+    		    			row++;
+    		    		}, row);
+    		    	}
+    	    	}
+    	    });
+    	},
+    	
+        /**
          * @method onPortletRemoveComplete
          */
         onPortletRemoveComplete : function(id, o, args) {
@@ -275,7 +360,7 @@
         },
         
         /**
-         * @method removePortlet
+         * @method removePortlet removes a portlet from the persistent store over restful
delete request
          */
         removePortlet : function(e) {
             var portal = JETUI_YUI.getPortalInstance();

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=891959&r1=891958&r2=891959&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
Thu Dec 17 22:42:08 2009
@@ -138,21 +138,19 @@
 	        dragGroups = ['toolbars'],	        
 	        dragMode = 'point';
 	        dropGroups = [];
-        }
-        
-	        var ddNav = new Y.DD.Drag({
-	            node: v,
-	            groups: dragGroups,
-	            dragMode: dragMode                    
-	        }).plug(Y.Plugin.DDProxy, { 
-	          	 moveOnEnd: false         	    	
-	        });    
-	        ddNav.addHandle(config.dragHandleStyle);
-	    	var drop = new Y.DD.Drop({
-	            node: v,
-	            groups: dropGroups            
-	        });
-        
+        }        
+        var ddNav = new Y.DD.Drag({
+            node: v,
+            groups: dragGroups,
+            dragMode: dragMode                    
+        }).plug(Y.Plugin.DDProxy, { 
+          	 moveOnEnd: false         	    	
+        });    
+        ddNav.addHandle(config.dragHandleStyle);
+    	var drop = new Y.DD.Drop({
+            node: v,
+            groups: dropGroups            
+        });
     	//portlet.info();
     });
     
@@ -174,7 +172,12 @@
     closeWindows.each(function(v, k) {
         v.on('click', portal.removePortlet);
     });
-        
+
+    var detachWindows = Y.Node.all('.portlet-action-detach');
+    detachWindows.each(function(v, k) {
+        v.on('click', portal.detachPortlet);
+    });
+    
 	Y.DD.DDM.on('drag:drophit', function(e) {
 	    var portal = JETUI_YUI.getPortalInstance();
 		var drop = e.drop.get('node'),
@@ -228,70 +231,8 @@
         drag.get('node').removeClass('moving');
         drag.get('dragNode').set('innerHTML', '');
 
-        persistMove(drag.get('node'), e);
-    });
-    
-    var onMoveComplete = function(id, o, args) { 
-        var id = id; // Transaction ID. 
-        var data = o.responseText; // Response data.
-        Y.log("move result = " + data);
-        var windowId = args.complete[0];
-    };     
-    
-    var persistMove = function(drag, e) {
-        var portal = JETUI_YUI.getPortalInstance();
-        var windowId =  drag.getAttribute('id');
-        if (drag.data.get("toolbar") == false) {
-        	var oldColumn = drag.data.get('column');
-        	var oldRow = drag.data.get('row');        	
-    		var dragParent = drag.get('parentNode');
-        	var parentColumn = dragParent.data.get('column');
-        	if (parentColumn != oldColumn)
-        	{
-        		reallocateColumn(oldColumn); // moved from different column
-        		drag.data.set('column', parentColumn);
-        	}
-        	reallocateColumn(parentColumn);
-            var uri = portal.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
-            uri += "&col=" + drag.data.get('column') + "&row=" + drag.data.get('row');
-            var config = {
-                    on: { complete: onMoveComplete },
-                    method: "PUT",
-                    headers: { "X-Portal-Path" : portal.portalPagePath },
-                    arguments: { complete: [ windowId ] }
-                };
-            var request = Y.io(uri, config);
-        }    	
-        else
-        {
-            var uri = portal.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
-            uri += "&x=" + e.target.region.top + "&y=" + e.target.region.left;
-            var config = {
-                    on: { complete: onMoveComplete },
-                    method: "PUT",
-                    headers: { "X-Portal-Path" : portal.portalPagePath },
-                    arguments: { complete: [ windowId ] }
-                };
-            var request = Y.io(uri, config);
-        }
-    };
-
-	var reallocateColumn = function(column) {
-	    var columns = Y.Node.all(config.layoutStyle); 
-	    columns.each(function(v, k) {
-	    	if (v.data.get('locked') == false)
-	    	{
-		    	if (v.data.get('column') == column)
-		    	{
-		    		var row = 0;
-	    			v.get('children').each(function(v,k) {
-		    			v.data.set('row', row);
-		    			row++;
-		    		}, row);
-		    	}
-	    	}
-	    });
-	};    
+        portal.movePortlet(drag.get('node'), e);
+    });        	
     
     Y.DD.DDM.on('drag:start', function(e) {
         var drag = e.target;
@@ -379,7 +320,7 @@
 		    	{
 		    		// Y.log("**** HIT");
 		    		portal.isMoving = true;
-		    		portal.movePortlet(e); 
+		    		portal.moveToGrid(e); 
 		    		portal.isMoving = false;
 		    	}
 	    	}



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