Author: woonsan
Date: Fri Dec 11 15:25:44 2009
New Revision: 889650

URL: http://svn.apache.org/viewvc?rev=889650&view=rev
Log:
JS2-1084: Code clean ups in jetspeed portal yui library

Modified:
    
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/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=889650&r1=889649&r2=889650&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
 Fri Dec 11 15:25:44 2009
@@ -19,185 +19,353 @@
 
 YUI.add('jetui-portal', function(Y) {
     
+    /**
+     * JetUI Portal JavaScript Framework
+     *
+     * @module jetui-portal
+     */
+    
     Y.namespace("JetUI");
     
-    ////////////////////////////////////////////////////
-    // the Portal Class
-    //Make this an Event Target so we can bubble to it
+    /**
+     * Create a portal to represent a portal screen.
+     *
+     * @class JetUI.Portal
+     * @extends Base
+     * @param config {Object} Configuration object
+     * @constructor
+     */
     Y.JetUI.Portal = function() {
         Y.JetUI.Portal.superclass.constructor.apply(this, arguments);
     };
     
-    Y.JetUI.Portal.NAME = 'portal';
-    Y.JetUI.Portal.prototype.desktopMode = false;
-    Y.JetUI.Portal.prototype.jstbLeft = null;
-    Y.JetUI.Portal.prototype.jstbRight = null;
-    Y.JetUI.Portal.prototype.isMoving = false;
-    Y.JetUI.Portal.prototype.goingUp = false;
-    Y.JetUI.Portal.prototype.goingRight = false;
-    Y.JetUI.Portal.prototype.lastY = 0;
-    Y.JetUI.Portal.prototype.lastX = 0;  
-    Y.extend(Y.JetUI.Portal, Y.Base);
-    
-    Y.JetUI.Portal.prototype.toggleToolbar = function(toolbar, toggler, 
compareStyle) {
-        toggler.toggleClass('jstbToggle1');
-        toggler.toggleClass('jstbToggle2');
-        var currentStyle = toggler.getAttribute('class');
-        var nodelist = toolbar.get('children');
-        if (currentStyle == compareStyle)
-        {
-            nodelist.setStyle('display', 'block');          
-        }
-        else
-        {
-            nodelist.setStyle('display', 'none');           
-        }           
-        toolbar.fx.set('reverse', !toolbar.fx.get('reverse')); // toggle 
reverse 
-        toolbar.fx.run();
-    };
+    Y.mix(Y.JetUI.Portal, {
+        
+        /**
+         * The identity of the widget.
+         *
+         * @property JetUI.Portal.NAME
+         * @type String
+         * @static
+         */
+        NAME : 'Portal'
+        
+    });
     
-    Y.JetUI.Portal.prototype.moveToLayout = function(e)
-    {
-        var drop = e.drop.get('node'),
-            drag = e.drag.get('node');
-        var dragParent = drag.get('parentNode');       
-        drop.appendChild(drag);
-        if (dragParent.get('children').size() == 0)
-        {
-            //node.plug(Y.Plugin.Drag);
-            var drop = new Y.DD.Drop({
-            node: dragParent,
-            groups: ['portlets']            
-            });
-        }
-        // BOZO: im manipulating internal DD structures, should find a way to 
detach the handler
-        var i = 0;
-        while (i < Y.DD.DDM.targets.length) {
-            if (Y.DD.DDM.targets[i] == e.drop) {
-                Y.DD.DDM.targets.splice(i, 1);
-                break;
+    Y.extend(Y.JetUI.Portal, Y.Base, {
+        
+        /**
+         * @property desktopMode
+         * @type Boolean
+         */
+        desktopMode : false,
+        
+        /**
+         * @property jstbLeft
+         * @type Object
+         */
+        jstbLeft : null,
+        
+        /**
+         * @property jstbRight
+         * @type Object
+         */
+        jstbRight : null,
+        
+        /**
+         * @property isMoving
+         * @type Boolean
+         */
+        isMoving : false,
+        
+        /**
+         * @property goingUp
+         * @type Boolean
+         */
+        goingUp : false,
+        
+        /**
+         * @property goingRight
+         * @type Boolean
+         */
+        goingRight : false,
+        
+        /**
+         * @property lastY
+         * @type Number
+         */
+        lastY : 0,
+        
+        /**
+         * @property lastX
+         * @type Number
+         */
+        lastX : 0,
+        
+        /**
+         * Construction logic executed during instantiation.
+         *
+         * @method initializer
+         * @protected
+         */
+        initializer : function(cfg) { 
+        },
+        
+        /**
+         * Destruction logic executed during instantiation.
+         *
+         * @method initializer
+         * @protected
+         */
+        destructor : function(cfg) { 
+        },
+        
+        /**
+         * Toggles toolbar
+         * 
+         * @method toggleToolbar
+         */
+        toggleToolbar : function(toolbar, toggler, compareStyle) {
+            toggler.toggleClass('jstbToggle1');
+            toggler.toggleClass('jstbToggle2');
+            var currentStyle = toggler.getAttribute('class');
+            var nodelist = toolbar.get('children');
+            if (currentStyle == compareStyle) {
+                nodelist.setStyle('display', 'block');          
+            } else {
+                nodelist.setStyle('display', 'none');           
             }
-            i++;
-        }
-        // I don't think this is working
-        e.drop.unplug(Y.Plugin.Drop);
-    }
-
-    Y.JetUI.Portal.prototype.movePortlet = function(e)
-    {
-        if (!JETUI_YUI_config || !JETUI_YUI_config.portalInstance)
-            return;
-        
-        var portal = JETUI_YUI_config.portalInstance;
-        var drop = e.drop.get('node'),
-            drag = e.drag.get('node');
-        var dragParent = drag.get('parentNode');
-        var dropParent = drop.get('parentNode');
-        if (dropParent == portal.jstbLeft || dropParent == portal.jstbRight)
-        {
-          if (!dropParent.contains(drag)) {
-              dropParent.appendChild(drag);
-          }
-        }
-        else
-        {
-            if (portal.goingUp)
+            toolbar.fx.set('reverse', !toolbar.fx.get('reverse')); // toggle 
reverse 
+            toolbar.fx.run();
+        },
+        
+        /**
+         * @method moveToLayout
+         */
+        moveToLayout : function(e) {
+            var drop = e.drop.get('node'),
+                drag = e.drag.get('node');
+            var dragParent = drag.get('parentNode');       
+            drop.appendChild(drag);
+            if (dragParent.get('children').size() == 0)
             {
-                //Y.log("going UP");
-                // var next = drop.get('previousSibling');
-                var prev = drop.previous();
-                if (prev == null)
-                {
-                    //drag.remove();                    
-                    dropParent.prepend(drag);                   
-                }
-                else
-                {
-                    //drag.remove();
-                    dropParent.insertBefore(drag, drop);
-                }               
+                //node.plug(Y.Plugin.Drag);
+                var drop = new Y.DD.Drop({
+                node: dragParent,
+                groups: ['portlets']            
+                });
             }
-            else
-            {
-                var next = drop.next();
-                if (next == null) 
-                {
-                    //Y.log("going down APPEND");
-                    //drag.remove();
-                    dropParent.appendChild(drag);
+            // BOZO: im manipulating internal DD structures, should find a way 
to detach the handler
+            var i = 0;
+            while (i < Y.DD.DDM.targets.length) {
+                if (Y.DD.DDM.targets[i] == e.drop) {
+                    Y.DD.DDM.targets.splice(i, 1);
+                    break;
                 }
-                else
-                {
-                    //Y.log("going down: " + next); //next.data.get('name'));
-                    //drag.remove();
-                    dropParent.insertBefore(drag, next);
+                i++;
+            }
+            // I don't think this is working
+            e.drop.unplug(Y.Plugin.Drop);
+        },
+        
+        /**
+         * @method movePortlet
+         */
+        movePortlet : function(e) {
+            if (!JETUI_YUI_config || !JETUI_YUI_config.portalInstance)
+                return;
+            
+            var portal = JETUI_YUI_config.portalInstance;
+            var drop = e.drop.get('node'),
+                drag = e.drag.get('node');
+            var dragParent = drag.get('parentNode');
+            var dropParent = drop.get('parentNode');
+            if (dropParent == portal.jstbLeft || dropParent == 
portal.jstbRight) {
+              if (!dropParent.contains(drag)) {
+                  dropParent.appendChild(drag);
+              }
+            } else {
+                if (portal.goingUp) {
+                    //Y.log("going UP");
+                    // var next = drop.get('previousSibling');
+                    var prev = drop.previous();
+                    if (prev == null) {
+                        //drag.remove();                    
+                        dropParent.prepend(drag);                   
+                    } else {
+                        //drag.remove();
+                        dropParent.insertBefore(drag, drop);
+                    }
+                } else {
+                    var next = drop.next();
+                    if (next == null) {
+                        //Y.log("going down APPEND");
+                        //drag.remove();
+                        dropParent.appendChild(drag);
+                    } else {
+                        //Y.log("going down: " + next); 
//next.data.get('name'));
+                        //drag.remove();
+                        dropParent.insertBefore(drag, next);
+                    }
                 }
             }
+            if (dragParent.get('children').size() == 0) {
+                var drop = new Y.DD.Drop({
+                    node: dragParent,
+                    groups: ['portlets']            
+                });
+            }        
         }
-        if (dragParent.get('children').size() == 0)
-        {
-            var drop = new Y.DD.Drop({
-            node: dragParent,
-            groups: ['portlets']            
-            });
-        }        
-    };    
+        
+    });
     
-    ////////////////////////////////////////////////////
-    // the Portlet Class
+    /**
+     * Create a portlet window to represent a portal window.
+     *
+     * @class JetUI.Portlet
+     * @extends Base
+     * @param config {Object} Configuration object
+     * @constructor
+     */
     Y.JetUI.Portlet = function(config) {
         Y.JetUI.Portlet.superclass.constructor.call(this, config);
     };
+    
+    Y.mix(Y.JetUI.Portlet, {
+        
+        /**
+         * The identity of the widget.
+         *
+         * @property JetUI.Portlet.NAME
+         * @type String
+         * @static
+         */
+        NAME : 'Portlet',
+        
+        /**
+         * Static property used to define the default attribute configuration 
of
+         * the Widget.
+         *
+         * @property JetUI.Portlet.ATTRS
+         * @type Object
+         * @protected
+         * @static
+         */
+        ATTRS: {
+            "name" : { value: "undefined" }, 
+            "id" : { value: "0" },
+            "toolbar" : { value : false },
+            "detached" : { value : false },
+            "column" : { value : 0 },
+            "row" : { value : 0 }
+        }
+    });
+
     Y.extend(Y.JetUI.Portlet, Y.Base, {
+        
+        /**
+         * Construction logic executed during instantiation.
+         *
+         * @method initializer
+         * @protected
+         */
         initializer : function(cfg) { 
         },
+        
+        /**
+         * Destruction logic executed during instantiation.
+         *
+         * @method initializer
+         * @protected
+         */
         destructor : function(cfg) { 
-        }               
+        },
+        
+        /**
+         * @method info
+         */
+        info : function() {
+            Y.log("name: " + this.get("name"));
+            Y.log("id  : " + this.get("id"));       
+            Y.log("toolbar  : " + this.get("toolbar"));     
+            Y.log("col, row  : " + this.get("column") + "," + 
this.get("row"));     
+            Y.log("---------");
+        }
     });
-    Y.JetUI.Portlet.NAME = "portlet";
-    Y.JetUI.Portlet.ATTRS = {
-        "name" : { value: "undefined" }, 
-        "id" : { value: "0" },
-        "toolbar" : { value : false },
-        "detached" : { value : false },
-        "column" : { value : 0 },
-        "row" : { value : 0 }
-    };
-    Y.JetUI.Portlet.prototype.info = function() {
-        Y.log("name: " + this.get("name"));
-        Y.log("id  : " + this.get("id"));       
-        Y.log("toolbar  : " + this.get("toolbar"));     
-        Y.log("col, row  : " + this.get("column") + "," + this.get("row"));    
 
-        Y.log("---------");
-    };
 
-    ////////////////////////////////////////////////////
-    // the Layout Class
+    /**
+     * Create a layout window to represent a layout window.
+     *
+     * @class JetUI.Layout
+     * @extends Base
+     * @param config {Object} Configuration object
+     * @constructor
+     */
     Y.JetUI.Layout = function(config) {
         Y.JetUI.Layout.superclass.constructor.call(this, config);
     };
+    
+    Y.mix(Y.JetUI.Layout, {
+        
+        /**
+         * The identity of the widget.
+         *
+         * @property JetUI.Layout.NAME
+         * @type String
+         * @static
+         */
+        NAME : 'Layout',
+        
+        /**
+         * Static property used to define the default attribute configuration 
of
+         * the Widget.
+         *
+         * @property JetUI.Layout.ATTRS
+         * @type Object
+         * @protected
+         * @static
+         */
+        ATTRS: {
+            "name" : { value: "undefined" }, 
+            "id" : { value: "0" },
+            "nested" : { value : false },
+            "column" : { value : 0 },
+            "locked" : { value : false },
+            "row" : { value : 0 }
+        }
+    });
+    
     Y.extend(Y.JetUI.Layout, Y.Base, {
+        
+        /**
+         * Construction logic executed during instantiation.
+         *
+         * @method initializer
+         * @protected
+         */
         initializer : function(cfg) { 
         },
+        
+        /**
+         * Destruction logic executed during instantiation.
+         *
+         * @method initializer
+         * @protected
+         */
         destructor : function(cfg) { 
-        }               
+        },
+        
+        /**
+         * @method info
+         */
+        info : function() {
+            Y.log("name: " + this.get("name"));
+            Y.log("id  : " + this.get("id"));       
+            Y.log("nested  : " + this.get("nested"));       
+            Y.log("locked  : " + this.get("locked"));       
+            Y.log("col, row  : " + this.get("column") + "," + 
this.get("row"));     
+            Y.log("---------");
+        }
     });
-    Y.JetUI.Layout.NAME = "layout";
-    Y.JetUI.Layout.ATTRS = {
-        "name" : { value: "undefined" }, 
-        "id" : { value: "0" },
-        "nested" : { value : false },
-        "column" : { value : 0 },
-        "locked" : { value : false },
-        "row" : { value : 0 }
-    };
-    Y.JetUI.Layout.prototype.info = function() {
-        Y.log("name: " + this.get("name"));
-        Y.log("id  : " + this.get("id"));       
-        Y.log("nested  : " + this.get("nested"));       
-        Y.log("locked  : " + this.get("locked"));       
-        Y.log("col, row  : " + this.get("column") + "," + this.get("row"));    
 
-        Y.log("---------");
-    };
-
+    
 }, '3.0.0', {requires:['dd', 'io', 'dataschema-json', 'node-base', 
'node-menunav']});

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=889650&r1=889649&r2=889650&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
 Fri Dec 11 15:25:44 2009
@@ -412,7 +412,7 @@
         else
         {
                var region = e.drop.get('node').get('region');
-               if (e.drop.get('node').data.name == "portlet")
+               if (e.drop.get('node').data.name == "Portlet")
                {
                        var srcRegion = e.drag.get('node').get('region');
                        if (y >= srcRegion.top && y <= srcRegion.bottom && x >= 
srcRegion.left && x <= srcRegion.right)
@@ -427,7 +427,7 @@
                                portal.isMoving = false;
                        }
                }
-               else if (e.drop.get('node').data.name == "layout")
+               else if (e.drop.get('node').data.name == "Layout")
                {
                        portal.isMoving = true;
                        portal.moveToLayout(e);



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