Author: ivol37 at gmail.com
Date: Thu Dec 16 09:18:05 2010
New Revision: 507

Log:
[AMDATU-160] Replaced the custom render gadget function by the original method. 
The original render gadget function detects if a gadget needs the pubsub2 
feature and will render the gadget in a OpenAjax hub iframe instead of a 
regular iframe. As this switch was missing in the overruled method, pubsub 
didn't work.
To hide the additional titlebar rendered by that function the CSS has been 
customized. This additional titlebar was the reason that this method was 
originally overridden in the dashboard.js. 

Modified:
   trunk/amdatu-opensocial/dashboard/src/main/resources/static/css/gadgets.css
   trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js

Modified: 
trunk/amdatu-opensocial/dashboard/src/main/resources/static/css/gadgets.css
==============================================================================
--- trunk/amdatu-opensocial/dashboard/src/main/resources/static/css/gadgets.css 
(original)
+++ trunk/amdatu-opensocial/dashboard/src/main/resources/static/css/gadgets.css 
Thu Dec 16 09:18:05 2010
@@ -28,8 +28,8 @@
 }
 
 .gadgets-gadget-title-bar {
-  padding: 2px 4px;
-  background-color: #e5ecf9;
+  visibility: hidden;
+  display: none;
 }
 
 .gadgets-gadget-title {

Modified: 
trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js
==============================================================================
--- trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js 
(original)
+++ trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js 
Thu Dec 16 09:18:05 2010
@@ -73,11 +73,32 @@
     my.LayoutManager.inherits(shindig.LayoutManager);
 
     my.LayoutManager.prototype.getGadgetChrome = function(widget) {
-      var chrome = widget.element.find('.widgetcontent').get(0);
-      return chrome;
+      var chromeContainer = document.getElementById(widget.serviceName);
+      var divs = chromeContainer.getElementsByTagName('div');
+      for (var i=0;i<divs.length;i++) {
+        if (divs[i].getAttribute('class') == 'widgetcontent') {
+          return divs[i];
+        }
+      }
     };
 
     my.init = function() {
+      gadgets.pubsub2router.init(
+      {
+        onSubscribe: function(topic, container) {
+          log(container.getClientID() + " subscribes to topic '" + topic + 
"'");
+          return true;
+          // return false to reject the request.
+        },
+        onUnsubscribe: function(topic, container) {
+          log(container.getClientID() + " unsubscribes from topic '" + topic + 
"'");
+        },
+        onPublish: function(topic, data, pcont, scont) {
+          log(pcont.getClientID() + " publishes '" + data + "' to topic '" + 
topic + "' subscribed by " + scont.getClientID());
+          return true;
+          // return false to reject the request.
+        }
+      });
       shindig.container.layoutManager = new my.LayoutManager();
     };
     my.init();
@@ -87,60 +108,12 @@
       var metadata = widget.metadata;
       if (typeof metadata != 'undefined' && typeof metadata.gadgeturl != 
'undefined') {
         var gadget = shindig.container.createGadget(
-            {serviceName: widget.id, specUrl: metadata.gadgeturl, width: 
"100%", secureToken: metadata.securetoken});
+            {serviceName: widget.id, specUrl: metadata.gadgeturl, width: 
"100%", secureToken: metadata.securetoken, cssClassGadgetContent:""});
         shindig.container.addGadget(gadget);
-
-        var chrome = shindig.container.layoutManager.getGadgetChrome(widget);
-
-        // Don't render the header div
-        if (chrome) {
-          getMainContent(gadget, function(content) {
-            chrome.innerHTML = content;
-            var iframe = widget.element.find('.gadgets-gadget').get(0);
-            iframe.src = this.getIframeUrl(gadget);
-
-            // The line below doesn't work for some reason 
-            // window.frames[gadget.getIframeId()].location = 
this.getIframeUrl(gadget);
-          });
-        }
+        shindig.container.renderGadget(gadget);
       };
     };
 
-    // The src attribute for the iframe is added, because when you drag and 
drop a iframe, it is reloaded by the browser
-    getMainContent = function(gadget, continuation) {
-      var iframeId = gadget.getIframeId();
-      gadgets.rpc.setRelayUrl(iframeId, gadget.serverBase_ + gadget.rpcRelay);
-      gadgets.rpc.setAuthToken(iframeId, gadget.rpcToken);
-      continuation('<iframe id="' +
-        iframeId + '" src="about:blank" name="' + iframeId + '" class="' + 
gadget.cssClassGadget +
-        '" src="about:blank' +
-        '" frameborder="no" scrolling="no"' +
-        (gadget.height ? ' height="' + gadget.height + '"' : '') +
-        (gadget.width ? ' width="' + gadget.width + '"' : '') +
-        '></iframe>');
-    };
-
-    getIframeUrl = function(gadget) {
-        return gadget.serverBase_ + 'ifr?' +
-            'container=' + gadget.CONTAINER +
-            '&mid=' + gadget.id +
-            '&nocache=' + shindig.container.nocache_ +
-            '&country=' + shindig.container.country_ +
-            '&lang=' + shindig.container.language_ +
-            '&view=' + shindig.container.view_ +
-            (gadget.specVersion ? '&v=' + gadget.specVersion : '') +
-            (shindig.container.parentUrl_ ? '&parent=' + 
encodeURIComponent(shindig.container.parentUrl_) : '') +
-            (gadget.debug ? '&debug=1' : '') +
-            gadget.getAdditionalParams() +
-            gadget.getUserPrefsParams() +
-            (gadget.secureToken ? '&st=' + gadget.secureToken : '') +
-            '&url=' + encodeURIComponent(gadget.specUrl) +
-            '#rpctoken=' + gadget.rpcToken +
-            (gadget.viewParams ?
-                '&view-params=' + 
encodeURIComponent(gadgets.json.stringify(gadget.viewParams)) : '') +
-            (gadget.hashData ? '&' + gadget.hashData : '');
-    }
-
     $('.widget').live('widgetLoaded',function(e, obj){       
       my.renderGadget(obj);
     });

Reply via email to