Author: ddumont
Date: Wed Feb 29 14:31:07 2012
New Revision: 1295130

URL: http://svn.apache.org/viewvc?rev=1295130&view=rev
Log:
Pass more information into some lifecycle event listeners.

Modified:
    
shindig/trunk/features/src/main/javascript/features/container.site/site_holder.js
    shindig/trunk/features/src/main/javascript/features/container/container.js
    
shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js

Modified: 
shindig/trunk/features/src/main/javascript/features/container.site/site_holder.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container.site/site_holder.js?rev=1295130&r1=1295129&r2=1295130&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/container.site/site_holder.js
 (original)
+++ 
shindig/trunk/features/src/main/javascript/features/container.site/site_holder.js
 Wed Feb 29 14:31:07 2012
@@ -129,7 +129,7 @@ osapi.container.SiteHolder.prototype.cre
         height: renderParams[osapi.container.RenderParam.HEIGHT],
         width: renderParams[osapi.container.RenderParam.WIDTH],
         onload: this.onLoad_ ?
-                ('window.' + this.onLoad_ + "('" + this.getUrl() + "');") : 
undef
+                ('window.' + this.onLoad_ + "('" + this.getUrl() + "', '" + 
this.site_.getId() + "');") : undef
       };
    if (overrides) {
      for(var i in overrides) {

Modified: 
shindig/trunk/features/src/main/javascript/features/container/container.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/container.js?rev=1295130&r1=1295129&r2=1295130&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/container.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/container/container.js 
Wed Feb 29 14:31:07 2012
@@ -139,8 +139,8 @@ osapi.container.Container = function(opt
   this.tokenRefreshTimer_ = null;
 
   var self = this;
-  window[osapi.container.CallbackType.GADGET_ON_LOAD] = function(gadgetUrl){
-      self.applyLifecycleCallbacks_(osapi.container.CallbackType.ON_RENDER, 
gadgetUrl);
+  window[osapi.container.CallbackType.GADGET_ON_LOAD] = function(gadgetUrl, 
siteId){
+      self.applyLifecycleCallbacks_(osapi.container.CallbackType.ON_RENDER, 
gadgetUrl, siteId);
   };
 
   this.initializeMixins_();
@@ -211,7 +211,7 @@ osapi.container.Container.prototype.navi
     finishNavigate = function(preferences) {
       renderParams[RenderParam.USER_PREFS] = preferences;
       
self.applyLifecycleCallbacks_(osapi.container.CallbackType.ON_BEFORE_NAVIGATE,
-              gadgetUrl);
+              gadgetUrl, site.getId());
       // TODO: Lifecycle, add ability for current gadget to cancel nav.
       site.navigateTo(gadgetUrl, viewParams, renderParams, 
function(gadgetInfo) {
         // TODO: Navigate to error screen on primary gadget load failure
@@ -820,17 +820,16 @@ osapi.container.Container.prototype.refr
 
 /**
  * invokes methods on the gadget lifecycle callback registered with the
- * container.
+ * container.  The callback will be passed the remainder of the arguments 
after methodName.
  * @param {string} methodName of the callback method to be called.
- * @param {Object} data to be passed to the callback method.
  * @private
  */
-osapi.container.Container.prototype.applyLifecycleCallbacks_ = function(
-    methodName, data) {
+osapi.container.Container.prototype.applyLifecycleCallbacks_ = 
function(methodName) {
+  var args = Array.prototype.slice.call(arguments, 1);
   for (name in this.gadgetLifecycleCallbacks_) {
     var method = this.gadgetLifecycleCallbacks_[name][methodName];
     if (method) {
-      method(data);
+      method.apply(null, args);
     }
   }
 };

Modified: 
shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js?rev=1295130&r1=1295129&r2=1295130&view=diff
==============================================================================
--- 
shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js
 (original)
+++ 
shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js
 Wed Feb 29 14:31:07 2012
@@ -73,7 +73,7 @@ GadgetHolderTest.prototype.testRenderWit
       ' hspace="0"' +
       ' frameborder="0"' +
       ' scrolling="no"' +
-      ' onload="window.__gadgetOnLoad(\'gadget.xml\');"' +
+      ' onload="window.__gadgetOnLoad(\'gadget.xml\', \'123\');"' +
       ' marginheight="0"' +
       ' vspace="0"' +
       ' id="__gadget_123"' +
@@ -112,7 +112,7 @@ GadgetHolderTest.prototype.testRenderWit
       ' height="111"' +
       ' frameborder="0"' +
       ' scrolling="no"' +
-      ' onload="window.__gadgetOnLoad(\'gadget.xml\');"' +
+      ' onload="window.__gadgetOnLoad(\'gadget.xml\', \'123\');"' +
       ' class="xyz"' +
       ' marginheight="0"' +
       ' vspace="0"' +


Reply via email to