portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r891280 - in /portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp: javascript/jetspeed/jetui/jetui-portal.js jetui/engine/portal.js
Date Wed, 16 Dec 2009 15:58:54 GMT
Author: woonsan
Date: Wed Dec 16 15:58:53 2009
New Revision: 891280

URL: http://svn.apache.org/viewvc?rev=891280&view=rev
Log:
JS2-1084: Adding singleton access method for portal instance.

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=891280&r1=891279&r2=891280&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
Wed Dec 16 15:58:53 2009
@@ -27,6 +27,22 @@
     
     Y.namespace("JetUI");
     
+    // JETUI_YUI must be defined outside. However, just check again not to throw exceptions.
+    if (!JETUI_YUI) {
+        JETUI_YUI = {};
+    }
+    
+    /**
+     * Global method definition to returns the portal singleton instance
+     * @method
+     */
+    JETUI_YUI.getPortalInstance = function() {
+        if (!JETUI_YUI._portalInstance) {
+            JETUI_YUI._portalInstance = new Y.JetUI.Portal(JETUI_YUI.config);
+        }
+        return JETUI_YUI._portalInstance;
+    };
+    
     /**
      * Create a portal to represent a portal screen.
      *
@@ -127,9 +143,11 @@
          * @protected
          */
         initializer : function(cfg) {
-            this.portalContextPath = cfg.portalContextPath;
-            this.portalServletPath = cfg.portalServletPath;
-            this.portalPagePath = cfg.portalPagePath;
+            if (cfg) {
+                this.portalContextPath = cfg.portalContextPath;
+                this.portalServletPath = cfg.portalServletPath;
+                this.portalPagePath = cfg.portalPagePath;
+            }
         },
         
         /**
@@ -193,10 +211,7 @@
          * @method movePortlet
          */
         movePortlet : function(e) {
-            if (!JETUI_YUI || !JETUI_YUI.portalInstance)
-                return;
-            
-            var portal = JETUI_YUI.portalInstance;
+            var portal = JETUI_YUI.getPortalInstance();
             var drop = e.drop.get('node'),
                 drag = e.drag.get('node');
             var dragParent = drag.get('parentNode');
@@ -263,9 +278,7 @@
          * @method removePortlet
          */
         removePortlet : function(e) {
-            if (!JETUI_YUI || !JETUI_YUI.portalInstance)
-                return;
-            var portal = JETUI_YUI.portalInstance;
+            var portal = JETUI_YUI.getPortalInstance();
             var windowId = null;
             if (e instanceof String) {
                 windowId = e;
@@ -287,9 +300,7 @@
          * @method createDecoratorActionNode
          */
         createDecoratorActionNode : function(decoAction) {
-            if (!JETUI_YUI || !JETUI_YUI.portalInstance)
-                return;
-            var portal = JETUI_YUI.portalInstance;
+            var portal = JETUI_YUI.getPortalInstance();
             var node = Y.Node.create("<a class='action portlet-action'/>");
             var icon = Y.Node.create("<img border='0'/>");
             node.setAttribute("href", decoAction.action);
@@ -307,9 +318,7 @@
          * @method onPortletDecorationReadComplete
          */
         onPortletDecorationReadComplete : function(id, o, args) {
-            if (!JETUI_YUI || !JETUI_YUI.portalInstance)
-                return;
-            var portal = JETUI_YUI.portalInstance;
+            var portal = JETUI_YUI.getPortalInstance();
             var windowId = args.complete[0];
             var actionBarElem = args.complete[1];
             var existingActionElem = null;
@@ -345,9 +354,7 @@
          * @method onPortletRenderComplete
          */
         onPortletRenderComplete : function(id, o, args) {
-            if (!JETUI_YUI || !JETUI_YUI.portalInstance)
-                return;
-            var portal = JETUI_YUI.portalInstance;
+            var portal = JETUI_YUI.getPortalInstance();
             var id = id;
             var v = args.complete;
             var windowId = v.get("id");
@@ -395,10 +402,7 @@
          * @method addPortlet
          */
         addPortlet : function(fragment) {
-            if (!JETUI_YUI || !JETUI_YUI.portalInstance)
-                return;
-            
-            var portal = JETUI_YUI.portalInstance;
+            var portal = JETUI_YUI.getPortalInstance();
             var templatePanel = Y.Node.one("#jsPortletTemplate");
             var v = templatePanel.cloneNode(true);
             v.setStyle('display', '');
@@ -440,13 +444,6 @@
     });
     
     /**
-     * The portal singleton instance
-     */
-    if (JETUI_YUI && !JETUI_YUI.portalInstance) {
-        JETUI_YUI.portalInstance = new Y.JetUI.Portal(JETUI_YUI.config);
-    }
-    
-    /**
      * Create a portlet window to represent a portal window.
      *
      * @class JetUI.Portlet

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=891280&r1=891279&r2=891280&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
Wed Dec 16 15:58:53 2009
@@ -4,7 +4,7 @@
 	var config = JETUI_YUI.config;
     Y.log("Starting up JETUI " +  config.engine + " engine...");
 	
-    var portal = JETUI_YUI.portalInstance;
+    var portal = JETUI_YUI.getPortalInstance();
         
     ////////////////////////////////////////////////////    
     // Create Navigator Portlet
@@ -176,7 +176,7 @@
     });
         
 	Y.DD.DDM.on('drag:drophit', function(e) {
-	    var portal = JETUI_YUI.portalInstance;
+	    var portal = JETUI_YUI.getPortalInstance();
 		var drop = e.drop.get('node'),
             drag = e.drag.get('node');
         if (drag.data.get("toolbar"))
@@ -312,7 +312,7 @@
     });
 
     Y.DD.DDM.on('drag:over', function(e) {
-        var portal = JETUI_YUI.portalInstance;
+        var portal = JETUI_YUI.getPortalInstance();
     	if (portal.isMoving)
     		return;
     	



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