portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smi...@apache.org
Subject svn commit: r482987 - in /portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed: desktop/core.js widget/HtmlFloatingPane.css widget/PortletWindow.js
Date Wed, 06 Dec 2006 09:32:24 GMT
Author: smilek
Date: Wed Dec  6 01:32:23 2006
New Revision: 482987

URL: http://svn.apache.org/viewvc?view=rev&rev=482987
Log:
added support for deeply nested psml layout fragments

Modified:
    portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js
    portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/HtmlFloatingPane.css
    portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/PortletWindow.js

Modified: portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js?view=diff&rev=482987&r1=482986&r2=482987
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js (original)
+++ portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js Wed Dec  6 01:32:23
2006
@@ -30,7 +30,6 @@
 dojo.require("dojo.collections.Set");
 dojo.require("jetspeed.common");
 
-// ... testing
 
 // ... jetspeed base objects
 if ( ! window.jetspeed )
@@ -43,7 +42,6 @@
     jetspeed.ui.widget = {} ;
 
 
-
 // ... jetspeed.id
 jetspeed.id =
 {
@@ -759,7 +757,7 @@
     },
     notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl,
/* Portlet */ portlet )
     {
-        dojo.raise( "PortletSelectorContentListener notifyFailure url=" + requestUrl + "
type=" + type + " error=" + error ) ;
+        dojo.raise( "PortletSelectorContentListener notifyFailure url: " + requestUrl + "
type: " + type + jetspeed.url.formatBindError( error ) );
     }
 };
 
@@ -786,7 +784,7 @@
     },
     notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl,
/* Page */ page )
     {
-        dojo.raise( "PageContentListenerUpdate notifyFailure url=" + requestUrl + " type="
+ type + " error=" + error ) ;
+        dojo.raise( "PageContentListenerUpdate notifyFailure url: " + requestUrl + " type:
" + type + jetspeed.url.formatBindError( error ) );
     }
 };
 
@@ -928,14 +926,15 @@
         var parsedRootLayoutFragment = this._parsePSML( psml );
 
         // create layout model
-        var portletsByPageColumn = this._layoutCreateModel( parsedRootLayoutFragment );
+        var portletsByPageColumn = {};
+        this.columnsStructure = this._layoutCreateModel( parsedRootLayoutFragment, null,
portletsByPageColumn );
 
         this.rootFragmentId = parsedRootLayoutFragment.id ;
 
         // create columns
         if ( jetspeed.prefs.windowTiling )
         {
-            this._createColumns( document.getElementById( jetspeed.id.DESKTOP ) );
+            this._createColumnsStart( document.getElementById( jetspeed.id.DESKTOP ) );
         }
 
         // create portlet windows
@@ -1200,91 +1199,107 @@
         return ( rowA - rowB );
     },
 
-    _layoutCreateModel: function( parsedRootLayoutFragment )
-    {
-        var layoutFragment = parsedRootLayoutFragment;
-        var portletsByPageColumn = {};
-
-        // desktop layout handling rule:
-        //   in order to persist portlet positions, all layout fragments must span the entire
width of the page
+    _layoutCreateModel: function( layoutFragment, parentColumn, portletsByPageColumn )
+    {  // layoutFragmentParentColumnIndex, parentColumnsInLayout
+        var allColumnsStartIndex = this.columns.length;
+        var columnsInLayout = this._layoutRegisterAndCreateColumnsModel( layoutFragment,
parentColumn );
+        var columnsInLayoutLen = ( columnsInLayout == null ? 0 : columnsInLayout.length )
;
 
-        // does root fragment contain portlets only / layouts only / mix of layouts &
portlets
         if ( layoutFragment.layoutFragmentIndexes != null && layoutFragment.layoutFragmentIndexes.length
> 0 )
-        {
-            if ( layoutFragment.columnSizes.length > 1 )
-            {   // root fragments with multiple columns can contain portlets only
-                //    since a nested layout has to appear in a particular column (thus diving
one column in the outer fragment into n columns)
-                this.noMovePersist = true;
-            }
-
-            if ( layoutFragment.otherFragmentIndexes == null || layoutFragment.otherFragmentIndexes.length
== 0 )
-            {   // root fragment contains layout fragments only - ignore the root fragment
-                for ( var i = 0 ; i < layoutFragment.layoutFragmentIndexes.length ; i++
)
-                {
-                    var layoutChildFrag = layoutFragment.fragments[ layoutFragment.layoutFragmentIndexes[i]
];
-                    var hasNestedLayouts = this._layoutFragmentChildCollapse( layoutChildFrag
);
-                    if ( hasNestedLayouts )
-                        this.noMovePersist = true;
-                    var pageColumnStartIndex = this.columns.length;
-                    var columnsInLayout = this._layoutRegisterAndCreateColumnsModel( layoutChildFrag
);
-                    this._layoutCreatePortletsModel( layoutChildFrag, columnsInLayout, pageColumnStartIndex,
portletsByPageColumn );
+        {   // layout contains child layout fragments
+            var currentClonedLayoutFragByCol = null;
+            var clonedLayoutFragmentCount = 0;
+            if ( layoutFragment.otherFragmentIndexes != null && layoutFragment.otherFragmentIndexes.length
> 0 )
+                currentClonedLayoutFragByCol = new Array();
+
+            for ( var i = 0 ; i < columnsInLayoutLen ; i++ )
+            {
+                if ( currentClonedLayoutFragByCol != null )
+                    currentClonedLayoutFragByCol.push( null );
+                columnsInLayout[i].columnContainer = true;   // column cannot contain portlets
+            }
+            for ( var i = 0 ; i < layoutFragment.fragments.length ; i++ )
+            {
+                var childFrag = layoutFragment.fragments[ i ];
+                var childFragInColIndex = i;
+                if ( childFrag.properties && childFrag.properties[ jetspeed.id.PORTLET_PROP_COLUMN
] >= 0 )
+                {
+                    if ( childFrag.properties[ jetspeed.id.PORTLET_PROP_COLUMN ] != null
&& childFrag.properties[ jetspeed.id.PORTLET_PROP_COLUMN ] >= 0 )
+                        childFragInColIndex = childFrag.properties[ jetspeed.id.PORTLET_PROP_COLUMN
] ;
+                }
+                if ( childFragInColIndex >= columnsInLayoutLen )
+                {
+                    childFragInColIndex = ( columnsInLayoutLen > 0 ? ( columnsInLayoutLen
-1 ) : 0 );
+                }
+    
+                var currentClonedLayoutFragForCol = ( (currentClonedLayoutFragByCol == null)
? null : currentClonedLayoutFragByCol[ childFragInColIndex ] );
+                if ( childFrag.type == "layout" )
+                {
+                    if ( currentClonedLayoutFragForCol != null )
+                    {
+                        this._layoutCreateModel( currentClonedLayoutFragForCol, columnsInLayout[childFragInColIndex],
portletsByPageColumn ) ;
+                        currentClonedLayoutFragByCol[ childFragInColIndex ] = null;
+                    }
+                    this._layoutCreateModel( childFrag, columnsInLayout[childFragInColIndex],
portletsByPageColumn ) ;
+                }
+                else
+                {
+                    if ( currentClonedLayoutFragForCol == null )
+                    {
+                        clonedLayoutFragmentCount++;
+                        var clonedPortletLayout = {};
+                        dojo.lang.mixin( clonedPortletLayout, layoutFragment );
+                        clonedPortletLayout.fragments = new Array();
+                        clonedPortletLayout.layoutFragmentIndexes = new Array();
+                        clonedPortletLayout.otherFragmentIndexes = new Array();
+                        clonedPortletLayout.documentOrderIndex = layoutFragment.fragments[i].documentOrderIndex;
+                        clonedPortletLayout.clonedFromRootId = clonedPortletLayout.id;
+                        clonedPortletLayout.clonedLayoutFragmentIndex = clonedLayoutFragmentCount;
+                        clonedPortletLayout.columnSizes = [ "100" ];
+                        clonedPortletLayout.columnSizesSum = [ 100 ];
+                        clonedPortletLayout.id = clonedPortletLayout.id + "-jsclone_" + clonedLayoutFragmentCount;
+                        currentClonedLayoutFragByCol[ childFragInColIndex ] = clonedPortletLayout;
+                        currentClonedLayoutFragForCol = clonedPortletLayout;
+                    }
+                    currentClonedLayoutFragForCol.fragments.push( childFrag );
+                    currentClonedLayoutFragForCol.otherFragmentIndexes.push( currentClonedLayoutFragForCol.fragments.length
-1 );
                 }
             }
-            else
-            {   // mixed layout and portlet fragments - collapse portlet fragments in one
or more clones of the root layout
-                var currentClonedLayoutFragment = null;
-                var clonedLayoutFragmentCount = 0;
-                for ( var i = 0 ; i <= layoutFragment.fragments.length ; i++ )  // iterate
one past the last index - to catch end currentClonedLayoutFragment
-                {   // fragments array is sorted by row, so a contiguous set of portlet fragments
belong together in the same cloned layout fragment
-                    if ( currentClonedLayoutFragment != null && ( i == layoutFragment.fragments.length
|| layoutFragment.fragments[i].type == "layout" ) )
-                    {
-                        var pageColumnStartIndex = this.columns.length;
-                        var columnsInLayout = this._layoutRegisterAndCreateColumnsModel(
currentClonedLayoutFragment );
-                        this._layoutCreatePortletsModel( currentClonedLayoutFragment, columnsInLayout,
pageColumnStartIndex, portletsByPageColumn );
-                        currentClonedLayoutFragment = null;
+            if ( currentClonedLayoutFragByCol != null )
+            {
+                for ( var i = 0 ; i < columnsInLayoutLen ; i++ )
+                {
+                    var currentClonedLayoutFragForCol = currentClonedLayoutFragByCol[ i ];
+                    if ( currentClonedLayoutFragForCol != null )
+                    {
+                        this._layoutCreateModel( currentClonedLayoutFragForCol, columnsInLayout[i],
portletsByPageColumn ) ;
                     }
-                    if ( i < layoutFragment.fragments.length )
+                }
+            }
+            if ( layoutFragment.otherFragmentIndexes != null && layoutFragment.otherFragmentIndexes.length
> 0 )
+            {
+                var correctedFragments = new Array();
+                for ( var i = 0 ; i < layoutFragment.fragments.length ; i++ )
+                {
+                    var includeFrag = true;
+                    for ( var j = 0 ; j < layoutFragment.otherFragmentIndexes.length ;
j++ )
                     {
-                        if ( layoutFragment.fragments[i].type == "layout" )
-                        {
-                            var layoutChildFrag = layoutFragment.fragments[ i ];  // index
was: layoutFragment.layoutFragmentIndexes[i]
-                            var hasNestedLayouts = this._layoutFragmentChildCollapse( layoutChildFrag
);
-                            if ( hasNestedLayouts )
-                                this.noMovePersist = true;
-                            var pageColumnStartIndex = this.columns.length;
-                            var columnsInLayout = this._layoutRegisterAndCreateColumnsModel(
layoutChildFrag );
-                            this._layoutCreatePortletsModel( layoutChildFrag, columnsInLayout,
pageColumnStartIndex, portletsByPageColumn );
-                        }
-                        else
+                        if ( layoutFragment.otherFragmentIndexes[j] == i )
                         {
-                            if ( currentClonedLayoutFragment == null )
-                            {
-                                clonedLayoutFragmentCount++;
-                                var clonedPortletLayout = {};
-                                dojo.lang.mixin( clonedPortletLayout, layoutFragment );
-                                clonedPortletLayout.fragments = new Array();
-                                clonedPortletLayout.layoutFragmentIndexes = new Array();
-                                clonedPortletLayout.otherFragmentIndexes = new Array();
-                                clonedPortletLayout.documentOrderIndex = layoutFragment.fragments[i].documentOrderIndex;
-                                clonedPortletLayout.clonedFromRootId = clonedPortletLayout.id;
-                                clonedPortletLayout.clonedLayoutFragmentIndex = clonedLayoutFragmentCount;
-                                clonedPortletLayout.id = clonedPortletLayout.id + "-rootclone_"
+ clonedLayoutFragmentCount;
-                                currentClonedLayoutFragment = clonedPortletLayout ;
-                            }
-                            clonedPortletLayout.fragments.push( layoutFragment.fragments[i]
);
-                            clonedPortletLayout.otherFragmentIndexes.push( clonedPortletLayout.fragments.length
-1 );
+                            includeFrag = false;
+                            break;
                         }
                     }
+                    if ( includeFrag )
+                        correctedFragments.push( layoutFragment.fragments[ i ] );
                 }
+                layoutFragment.fragments = correctedFragments;
+                layoutFragment.otherFragmentIndexes = new Array();
             }
         }
-        else if ( layoutFragment.otherFragmentIndexes != null && layoutFragment.otherFragmentIndexes.length
> 0 )
-        {   // root fragment contains portlet fragments only
-            var pageColumnStartIndex = this.columns.length;
-            var columnsInLayout = this._layoutRegisterAndCreateColumnsModel( layoutFragment
);
-            this._layoutCreatePortletsModel( layoutFragment, columnsInLayout, pageColumnStartIndex,
portletsByPageColumn );
-        }
-        return portletsByPageColumn;
+        this._layoutCreatePortletsModel( layoutFragment, columnsInLayout, allColumnsStartIndex,
portletsByPageColumn ) ;
+
+        return columnsInLayout;
     },
 
     _layoutFragmentChildCollapse: function( layoutFragment, targetLayoutFragment )
@@ -1317,7 +1332,7 @@
         return hasNestedLayouts;
     },
 
-    _layoutRegisterAndCreateColumnsModel: function( layoutFragment )
+    _layoutRegisterAndCreateColumnsModel: function( layoutFragment, parentColumn )
     {   // columnSizes: sizes, columnSizesSum: sizesSum
         this.layouts[ layoutFragment.id ] = layoutFragment;
         var columnsInLayout = new Array();
@@ -1333,6 +1348,12 @@
                     size = size - 1;
                 var colModelObj = new jetspeed.om.Column( i, layoutFragment.id, size, this.columns.length
);
                 this.columns.push( colModelObj );
+                if ( parentColumn != null )
+                {
+                    if ( parentColumn.columnChildren == null )
+                        parentColumn.columnChildren = new Array();
+                    parentColumn.columnChildren.push( colModelObj );
+                }
                 columnsInLayout.push( colModelObj );
             }
         }
@@ -1476,18 +1497,32 @@
         return ( aZIndex - bZIndex );
     },
 
-    _createColumns: function( columnsParent )
+    _createColumnsStart: function( allColumnsParent )
     {
-        if ( ! this.columns || this.columns.length == 0 ) return;
+        if ( ! this.columnsStructure || this.columnsStructure.length == 0 ) return;
         var columnContainer = document.createElement( "div" );
         columnContainer.id = jetspeed.id.COLUMNS;
         columnContainer.setAttribute( "id", jetspeed.id.COLUMNS );
-        for ( var colIndex = 0 ; colIndex < this.columns.length ; colIndex++ )
+        for ( var colIndex = 0 ; colIndex < this.columnsStructure.length ; colIndex++
)
         {
-            var colObj = this.columns[colIndex];
-            colObj.createColumn( columnContainer );
+            var colObj = this.columnsStructure[colIndex];
+            this._createColumns( colObj, columnContainer ) ;
         }
-        columnsParent.appendChild( columnContainer );
+        allColumnsParent.appendChild( columnContainer );
+    },
+
+    _createColumns: function( column, columnContainer )
+    {
+        column.createColumn() ;
+        if ( column.columnChildren != null && column.columnChildren.length > 0
)
+        {
+            for ( var colIndex = 0 ; colIndex < column.columnChildren.length ; colIndex++
)
+            {
+                var colObj = column.columnChildren[ colIndex ];
+                this._createColumns( colObj, column.domNode ) ;
+            }
+        }
+        columnContainer.appendChild( column.domNode );
     },
     _removeColumns: function( /* DOM Node */ preserveWindowNodesInNode )
     {
@@ -1598,21 +1633,6 @@
         }
         return result;
     },
-
-    _debugDumpPortletZIndexInfo: function()
-    {
-        var portletArray = this._getPortletArrayByZIndex();
-        var dumpMsg = "";
-        for ( var i = 0; i < portletArray.length; i++ )
-        {
-            var portlet = portletArray[i];
-            if ( i > 0 ) dumpMsg += ", ";
-            var windowState = portlet.getLastSavedWindowState();
-            var zIndex = ( windowState ? windowState.zIndex : "null" );
-            dumpMsg += "[" + portlet.entityId + "] zIndex=" + zIndex;
-        }
-        return dumpMsg;
-    },
     _getPortletArrayByZIndex: function()
     {
         var portletArray = this.getPortletArray();
@@ -1747,6 +1767,19 @@
             portlet._destroy();
         }
     },
+    debugDumpLastSavedWindowStateAllPortlets: function()
+    {
+        var portletArray = this.getPortletArray();
+        var dumpMsg = "";
+        for ( var i = 0; i < portletArray.length; i++ )
+        {
+            var portlet = portletArray[i];
+            if ( i > 0 ) dumpMsg += "\r\n";
+            var windowState = portlet.getLastSavedWindowState();
+            dumpMsg += "[" + portlet.name + "] " + jetspeed.printobj( windowState, true );
+        }
+        return dumpMsg;
+    },
     debugDumpWindowStateAllPortlets: function()
     {
         dojo.debug("==== window-state all-portlets ====" );
@@ -2035,6 +2068,7 @@
     size: null,
     pageColumnIndex: null,
     domNode: null,
+    columnContainer: false,
 
     createColumn: function( columnContainer )
     {
@@ -2047,7 +2081,8 @@
         divElmt.style.minHeight = "40px";
         divElmt.className = columnClass;
         this.domNode = divElmt;
-        columnContainer.appendChild( divElmt );
+        if ( columnContainer != null )
+            columnContainer.appendChild( divElmt );
     },
     containsNode: function( node )
     {
@@ -2360,7 +2395,7 @@
     getLastSavedWindowState: function()
     {
         if ( ! this.lastSavedWindowState )
-            dojo.raise( "portlet.getLastSavedWindowState() is null - portlet not properly
initialized." );
+            dojo.raise( "portlet.getLastSavedWindowState() is null - portlet (" + this.name
+ ") not properly initialized." );
         return this.lastSavedWindowState;
     },
     getInitialWindowDimensions: function( dimensionsObj, reset )
@@ -2850,7 +2885,7 @@
     },
     notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl,
domainModelObject )
     {
-        dojo.raise( "BasicContentListener notifyFailure url=" + requestUrl + " type=" + type
+ " error=" + error ) ;
+        dojo.raise( "BasicContentListener notifyFailure url: " + requestUrl + " type: " +
type + jetspeed.url.formatBindError( error ) );
     }
 };
 
@@ -2876,7 +2911,7 @@
     },
     notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl,
/* Portlet */ portlet )
     {
-        dojo.raise( "PortletContentListener notifyFailure url=" + requestUrl + " type=" +
type + " error=" + error ) ;
+        dojo.raise( "PortletContentListener notifyFailure url: " + requestUrl + " type: "
+ type + jetspeed.url.formatBindError( error ) );
     }
 };
 
@@ -2908,8 +2943,7 @@
     },
     notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl,
/* Portlet */ portlet )
     {
-        dojo.raise( "PortletActionContentListener notifyFailure type=" + type ) ;
-        dojo.debugShallow( error );
+        dojo.raise( "PortletActionContentListener notifyFailure type: " + type + jetspeed.url.formatBindError(
error ) );
     }
 };
 
@@ -3507,7 +3541,7 @@
     },
     notifyFailure: function( /* String */ type, /* String */ error, /* String */ requestUrl,
domainModelObject )
     {
-        dojo.raise( "PortletSelectorAjaxApiContentListener error [" + domainModelObject.toString()
+ "] url: " + requestUrl + " type: " + type + " error: " + error );
+        dojo.raise( "PortletSelectorAjaxApiContentListener error [" + domainModelObject.toString()
+ "] url: " + requestUrl + " type: " + type + jetspeed.url.formatBindError( error ) );
     },
 
     parsePortlets: function( /* XMLNode */ node )
@@ -3647,6 +3681,19 @@
         dumpClosure.dumpMsg = "column " + i + ": " + dumpClosure.dumpMsg;
         dojo.debug( dumpClosure.dumpMsg );
     }
+};
+
+jetspeed.ui.dumpPortletWindowWidgets = function()
+{
+    var portletWindows = jetspeed.ui.getAllPortletWindowWidgets();
+    var pwOut = "";
+    for ( var i = 0 ; i < portletWindows.length; i++ )
+    {
+        if ( i > 0 )
+            pwOut += ", ";
+        pwOut += portletWindows[i].widgetId;
+    }
+    dojo.debug( "PortletWindow widgets: " + pwOut );
 };
 
 jetspeed.ui.dumpPortletWindowWidgets = function()

Modified: portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/HtmlFloatingPane.css
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/HtmlFloatingPane.css?view=diff&rev=482987&r1=482986&r2=482987
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/HtmlFloatingPane.css (original)
+++ portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/HtmlFloatingPane.css Wed
Dec  6 01:32:23 2006
@@ -38,8 +38,10 @@
 .dojoFloatingPane {
 	/* essential css */
 	position: absolute;
-    overflow: hidden;		/* dojo says 'visible' with this explanation "so drop shadow is displayed""
*/
+    overflow-y: hidden;		/* dojo says 'visible' with this explanation "so drop shadow is
displayed"" */
                             /* we says 'hidden' cause IE likes to kindly expand div to fit
content otherwise */
+    overflow-x: hidden;
+
 	z-index: 10;
 
 	/* styling css */

Modified: portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/PortletWindow.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/PortletWindow.js?view=diff&rev=482987&r1=482986&r2=482987
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/PortletWindow.js (original)
+++ portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/widget/PortletWindow.js Wed Dec
 6 01:32:23 2006
@@ -1353,11 +1353,11 @@
 
         if ( this.windowHeightToFit )
         {
-            this.domNode.style.overflow = "visible";
+            this.domNode.style.overflowY = "visible";
             this.domNode.style.height = "";
         }
         else
-            this.domNode.style.overflow = "hidden";
+            this.domNode.style.overflowY = "hidden";
 
         if ( this.windowPositionStatic )
         {
@@ -1382,12 +1382,12 @@
         {
             if ( this.windowHeightToFit )
             {
-                this.containerNode.style.overflow = "visible";
+                this.containerNode.style.overflowY = "visible";
                 this.containerNode.style.height = "";
             }
             else
             {
-                this.containerNode.style.overflow = "auto";
+                this.containerNode.style.overflowY = "auto";
             }
             if ( dojo.render.html.ie )
             {
@@ -1852,29 +1852,43 @@
 
             var inColIndex = this.portletWindow.getPageColumnIndex();
 
-            this.columnsX = new Array( jetspeed.page.columns.length );
+            this.columnDimensions = new Array( jetspeed.page.columns.length );
             for ( var i = 0 ; i < jetspeed.page.columns.length ; i++ )
             {
-                this.columnsX[ i ] = dojo.html.getAbsolutePosition( jetspeed.page.columns[i].domNode,
true ).x;
+                var col = jetspeed.page.columns[i];
+                if ( ! col.columnContainer )
+                {
+                    var colAbsPos = dojo.html.getAbsolutePosition( col.domNode, true );
+                    var marginBox = dojo.html.getMarginBox( col.domNode );
+                    this.columnDimensions[ i ] = { left: (colAbsPos.x), right: (colAbsPos.x
+ marginBox.width), top: (colAbsPos.y), bottom: (colAbsPos.y + marginBox.height) };
+                }
             }
             
             var inCol = ( inColIndex >= 0 ? jetspeed.page.columns[ inColIndex ] : null
);
             pwGhost.col = inCol;
         }
 
-        //dojo.debug( "PortletWindowDragMoveObject [" + this.portletWindow.widgetId + "]
onDragStart:  portletWindowNode.hasParent=" + dojo.dom.hasParent( portletWindowNode ) + "
dragOffset.left=" + this.dragOffset.left + " dragOffset.top=" + this.dragOffset.top + " dragStartPosition.left="
+ this.dragStartPosition.left + " dragStartPosition.top=" + this.dragStartPosition.top );
+        // debugging
+        /*
+        var posDump = "dragOffset={" + jetspeed.printobj(this.dragOffset,true) + "} dragStartPosition={"
+ jetspeed.printobj(this.dragStartPosition) + "}";
+        if ( this.windowPositionStatic )
+        {
+            for ( var i = 0; i < jetspeed.page.columns.length ; i++ )
+            {
+                posDump += " col[" + i + "]: {" + jetspeed.printobj( this.columnDimensions[i]
) + "}";
+            }
+            posDump += "}";
+        }
+        dojo.debug( "PortletWindowDragMoveObject [" + this.portletWindow.widgetId + "] onDragStart:
 portletWindowNode.hasParent=" + dojo.dom.hasParent( portletWindowNode ) + " " + posDump );
+        */
     },
     onDragMove: function( e )
     {
-        //jetspeed.widget.PortletWindowDragMoveObject.superclass.onDragMove.call( this, e
);
-        // BOZO: code copied from dojo.dnd.HtmlDragMoveObject.onDragMove
+        // NOTE: code copied from dojo.dnd.HtmlDragMoveObject.onDragMove
 
-        var mouse = dojo.html.getCursorPosition(e);
 		this.updateDragOffset();
-		var x = this.dragOffset.x + mouse.x;
-		var y = this.dragOffset.y + mouse.y;
-        //var x = mouse.x ;
-        //var y = mouse.y ;
+		var x = this.dragOffset.x + e.pageX;
+		var y = this.dragOffset.y + e.pageY;
 
 		if (this.constrainToContainer) {
 			if (x < this.constraints.minX) { x = this.constraints.minX; }
@@ -1883,6 +1897,8 @@
 			if (y > this.constraints.maxY) { y = this.constraints.maxY; }
 		}
 
+		this.setAbsolutePosition(x, y);
+
 		if(!this.disableY) { this.dragClone.style.top = y + "px"; }
 		if(!this.disableX) { this.dragClone.style.left = x + "px"; }
 
@@ -1891,35 +1907,47 @@
         if ( this.windowPositionStatic )
         {
             var colIndex = -1;
-            for ( var i = jetspeed.page.columns.length-1 ; i >= 0  ; i-- )
+            //dojo.debug( "PortletWindowDragMoveObject onDragMove pick column: offsetWidth="
+ this.domNode.offsetWidth + " offsetHeight=" + this.domNode.offsetHeight + " x=" + x + "
y=" + y + " dragOffset.x=" + this.dragOffset.x + " dragOffset.y=" + this.dragOffset.y + "
e.pageX=" + e.pageX + " e.pageY=" + e.pageY );
+            var offsetWidthHalf = this.domNode.offsetWidth / 2;
+            var offsetHeightHalf = this.domNode.offsetHeight / 2;
+            var noOfCols = jetspeed.page.columns.length;
+            for ( var i = 0 ; i < noOfCols ; i++ )
             {
-                //dojo.debug( "PortletWindowDragMoveObject onDragMove: col[" + i + "] columnsX="
+ this.columnsX[i] + " this.domNode.offsetWidth/2=" + (this.domNode.offsetWidth/2) + " x="
+ x );
-                if ( ( x + ( this.domNode.offsetWidth / 2 ) ) >= this.columnsX[ i ] )
+                var colDims = this.columnDimensions[ i ];
+                if ( colDims != null )
                 {
-                    if ( y + ( this.domNode.offsetHeight / 2 ) >=  dojo.html.getAbsolutePosition(
jetspeed.page.columns[i].domNode, true ).y )
+                    var xTest = x + offsetWidthHalf;
+                    if ( xTest >= colDims.left && xTest <= colDims.right )
                     {
-                        colIndex = i;
-                        break;
+                        var yTest = y + offsetHeightHalf;
+                        if ( yTest >= colDims.top && yTest <= colDims.bottom
)
+                        {
+                            colIndex = i;
+                            break;
+                        }
                     }
                 }
             }
             var col = ( colIndex >= 0 ? jetspeed.page.columns[ colIndex ] : null );
             //if ( col != null )
-            //    dojo.debug( "PortletWindowDragMoveObject onDragMove: col[" + colIndex +
"] columnsX=" + this.columnsX[colIndex] + " this.domNode.offsetWidth=" + this.domNode.offsetWidth
+ " x=" + x );
+            //    dojo.debug( "PortletWindowDragMoveObject onDragMove: col[" + colIndex +
"] {" + jetspeed.printobj( this.columnDimensions[colIndex] ) + "}" );
             //else
-            //    dojo.debug( "PortletWindowDragMoveObject onDragMove: no col  this.domNode.offsetWidth="
+ this.domNode.offsetWidth + " x=" + x );
+            //    dojo.debug( "PortletWindowDragMoveObject onDragMove: no column" );
             
-            if ( pwGhost.col != col )
+            if ( pwGhost.col != col && col != null )
             {
                 dojo.dom.removeNode( pwGhost );
 				pwGhost.col = col;
 				col.domNode.appendChild(pwGhost);
 			}
             
-            var portletWindowsResult = jetspeed.ui.getPortletWindowChildren( col.domNode,
pwGhost );
-            var portletWindowsInCol = portletWindowsResult.portletWindowNodes;
-            
-            if ( portletWindowsInCol )
+            var portletWindowsResult = null, portletWindowsInCol = null;
+            if ( col != null )
+            {
+                portletWindowsResult = jetspeed.ui.getPortletWindowChildren( col.domNode,
pwGhost );
+                portletWindowsInCol = portletWindowsResult.portletWindowNodes;
+            }
+            if ( portletWindowsInCol != null )
             {
                 var ghostIndex = portletWindowsResult.matchIndex;
                 if ( ghostIndex > 0 )



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