Author: taylor
Date: Tue Jan  5 06:35:21 2010
New Revision: 895920

URL: http://svn.apache.org/viewvc?rev=895920&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-1084
implemented re-attach functionality (there are still a number of issues with 
re-attaching without refresh)

Added:
    
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/images/attach.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
    
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java

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=895920&r1=895919&r2=895920&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 Jan  5 06:35:21 2010
@@ -73,10 +73,12 @@
 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/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>
+<% if (detached != null) { %>                               
+                 <span style='cursor: pointer; z-index: 1000;' 
id='jetspeed-detach-<%=fragment.getId()%>' title="attach" 
class="portlet-action-attach"><img 
src="<%=request.getContextPath()%>/decorations/images/attach.gif" alt="Attach" 
border="0" /></span>              
+<% } else {  %>
                  <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>
                <div class="PContentBorder">

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

Propchange: 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/images/attach.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=895920&r1=895919&r2=895920&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 Jan  5 06:35:21 2010
@@ -289,59 +289,133 @@
             if (e instanceof String) {
                 windowId = e;
             } else {
-                var windowId = e.currentTarget.getAttribute("id");
+                windowId = e.currentTarget.getAttribute("id");
                 windowId = windowId.replace(/^jetspeed-detach-/, "");
             }
             var window = Y.one("[id='" + windowId + "']");
             var jetspeedZone = Y.one('#jetspeedZone');
             if (!Y.Lang.isNull(jetspeedZone)) {
-                       var dragParent = window.get('parentNode');
-               var parentColumn = dragParent.data.get('column');
-               portal.reallocateColumn(parentColumn);
-
-               var pos = window.get('region');
-               var x =  pos.top + 5;
-               var y =  pos.left + 5;
-               window.data.set("x", x);
-                window.data.set("y", y);
-                window.setStyle('position', 'absolute');
-                window.setStyle('top', x + 'px');
-                window.setStyle('left', y + 'px');
-               window.data.set('detached', true);
-               window.data.set("tool", false);
-               var drag = Y.DD.DDM.getDrag(window);
-               drag.removeFromGroup("grid");
-               drag.addToGroup("detached");
-               drag.set('dragMode', 'point');
-               var drop = Y.DD.DDM.getDrop(window);
-               var i = 0;
-                while (i < Y.DD.DDM.targets.length) {
-                    if (Y.DD.DDM.targets[i] == drop) {
-                        Y.DD.DDM.targets.splice(i, 1);
-                        break;
-                    }
-                    i++;
-                }
-                jetspeedZone.appendChild(window);
-                       if (dragParent.get("children").size() == 0)
-                       {
-                    var drop = new Y.DD.Drop({
-                        node: dragParent,
-                        groups: ['grid']            
-                    });
-                       }
-              var uri = portal.portalContextPath + 
"/services/pagelayout/fragment/" + windowId + "/pos/?_type=json";
-              uri += "&x=" + x + "&y=" + y + "&layout=detach";
-              var config = {
+                       var dragParent = window.get('parentNode');
+                       var parentColumn = dragParent.data.get('column');
+                       portal.reallocateColumn(parentColumn);
+       
+                       var pos = window.get('region');
+                       var x =  pos.top + 5;
+                       var y =  pos.left + 5;
+                       window.data.set("x", x);
+                   window.data.set("y", y);
+                   window.setStyle('position', 'absolute');
+                   window.setStyle('top', x + 'px');
+                   window.setStyle('left', y + 'px');
+                       window.data.set('detached', true);
+                       window.data.set("tool", false);
+                       var drag = Y.DD.DDM.getDrag(window);
+                       drag.removeFromGroup("grid");
+                       drag.addToGroup("detached");
+                       drag.set('dragMode', 'point');
+                       var drop = Y.DD.DDM.getDrop(window);
+                       var i = 0;
+                   while (i < Y.DD.DDM.targets.length) {
+                       if (Y.DD.DDM.targets[i] == drop) {
+                           Y.DD.DDM.targets.splice(i, 1);
+                           break;
+                       }
+                       i++;
+                   }
+                   jetspeedZone.appendChild(window);
+                               if (dragParent.get("children").size() == 0)
+                               {
+                       var drop = new Y.DD.Drop({
+                           node: dragParent,
+                           groups: ['grid']            
+                       });
+                               }
+                               e.currentTarget.on('click', 
portal.attachPortlet);
+                       e.currentTarget.setAttribute("title", "attach");
+                       e.currentTarget.setAttribute("class", 
"portlet-action-attach");
+                       var imgsrc = e.target.getAttribute("src");
+                       if (imgsrc != null) {
+                                       e.target.setAttribute("src", 
imgsrc.replace("/detach/", "attach"));
+                                       e.target.setAttribute("alt", "Attach");
+                       }
+                       var uri = portal.portalContextPath + 
"/services/pagelayout/fragment/" + windowId + "/pos/?_type=json";
+                       uri += "&x=" + x + "&y=" + y + "&layout=detach";
+                       var config = {
                       on: { complete: portal.onMoveComplete },
                       method: "PUT",
                       headers: { "X-Portal-Path" : portal.portalPagePath },
                       arguments: { complete: [ windowId ] }
                   };
-              var request = Y.io(uri, config);
-                       
+                       var request = Y.io(uri, config);                        
             }            
         },
+
+        /**
+         * @method attachPortlet attaches a portlet from a z-order top 
detached window to a grid position
+         */
+        attachPortlet : function(e) {
+            var portal = JETUI_YUI.getPortalInstance();
+            var windowId = null;
+            if (e instanceof String) {
+                windowId = e;
+            } else {
+                windowId = e.currentTarget.getAttribute("id");
+                windowId = windowId.replace(/^jetspeed-detach-/, "");
+            }
+            var window = Y.one("[id='" + windowId + "']");
+            var col = window.data.get("column");
+            var layout = null;
+            var count = 0;
+            Y.Node.all(JetuiConfiguration.layoutStyle).each(function(v, k) {
+               if (count == col) {
+                       layout = v;
+               }
+               count++;
+            });
+            if (layout != null)
+            {
+               var row = layout.get('children').size();
+                   window.setAttribute("row", row);
+                   window.setAttribute("detached", "false");
+                       window.data.set("row", row);
+                   window.data.set("col", col);
+                   window.setStyle('position', '');
+                   window.setStyle('top', '');
+                   window.setStyle('left', '');
+                       window.data.set('detached', false);
+                               e.currentTarget.on('click', 
portal.detachPortlet);
+                       e.currentTarget.setAttribute("title", "detach");
+                       e.currentTarget.setAttribute("class", 
"portlet-action-detach");
+                       var imgsrc = e.target.getAttribute("src");
+                       if (imgsrc != null) {
+                               e.target.setAttribute("src", 
imgsrc.replace("/attach/", "detach"));
+                               e.target.setAttribute("alt", "Detach");
+                       }                       
+                       var drag = Y.DD.DDM.getDrag(window);
+                       drag.removeFromGroup("detached");
+                       drag.addToGroup("grid");
+                       drag.set('dragMode', 'intersect');
+                       var drop = Y.DD.DDM.getDrop(window);
+                       var i = 0;
+                   while (i < Y.DD.DDM.targets.length) {
+                       if (Y.DD.DDM.targets[i] == drop) {
+                           Y.DD.DDM.targets.splice(i, 1);
+                           break;
+                       }
+                       i++;
+                   }
+                   layout.appendChild(window);
+                   var uri = portal.portalContextPath + 
"/services/pagelayout/fragment/" + windowId + "/pos/?_type=json";
+                   uri += "&row=" + row + "&col=" + col + "&layout=attach";
+                   var config = {
+                         on: { complete: portal.onMoveComplete },
+                         method: "PUT",
+                         headers: { "X-Portal-Path" : portal.portalPagePath },
+                         arguments: { complete: [ windowId ] }
+                     };
+                   var request = Y.io(uri, config);
+            }
+        },
         
         onMoveComplete : function(id, o, args) { 
             var id = id; // Transaction ID. 

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=895920&r1=895919&r2=895920&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 Jan  5 06:35:21 2010
@@ -119,6 +119,11 @@
     detachWindows.each(function(v, k) {
         v.on('click', portal.detachPortlet);
     });
+
+    var attachWindows = Y.Node.all('.portlet-action-attach');
+    attachWindows.each(function(v, k) {
+        v.on('click', portal.attachPortlet);
+    });
     
        Y.DD.DDM.on('drag:drophit', function(e) {
            var portal = JETUI_YUI.getPortalInstance();

Modified: 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java?rev=895920&r1=895919&r2=895920&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
 (original)
+++ 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
 Tue Jan  5 06:35:21 2010
@@ -333,7 +333,12 @@
                 try
                 {
                     ContentFragment layoutFragment = null;
-                    
+                    boolean attach = false;
+                    if (!StringUtils.isBlank(layoutFragmentId) && 
layoutFragmentId.equals("attach"))
+                    {
+                       layoutFragmentId = null;
+                       attach = true;
+                    }
                     if (!StringUtils.isBlank(layoutFragmentId))
                     {
                         layoutFragment = 
contentPage.getFragmentByFragmentId(layoutFragmentId);
@@ -364,12 +369,18 @@
                     
                     // synchronize back to the page layout root fragment
                     contentPage = 
ppc.syncPageFragments(PageLayoutComponent.USER_PROPERTY_SCOPE, null);
+                    if (attach)
+                       pageLayoutComponent.updateStateMode(contentFragment, 
JetspeedActions.NORMAL, null, PageLayoutComponent.USER_PROPERTY_SCOPE, null);   
                 
                 }
                 catch (Exception e)
                 {
                     throw new WebApplicationException(e);
                 }
             }
+            else if (!StringUtils.isBlank(layoutFragmentId) && 
layoutFragmentId.equals("attach"))
+            {
+               pageLayoutComponent.updateStateMode(contentFragment, 
JetspeedActions.NORMAL, null, PageLayoutComponent.USER_PROPERTY_SCOPE, null);   
                 
+            }            
         }
         else
         {
@@ -403,8 +414,7 @@
             {
                 throw new WebApplicationException(e);
             }
-        }
-        
+        }        
         return new ContentFragmentBean(contentFragment);
     }
 



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

Reply via email to