Author: rbaxter85
Date: Wed Aug 10 20:56:14 2011
New Revision: 1156364

URL: http://svn.apache.org/viewvc?rev=1156364&view=rev
Log:
SHINDIG-1566
Committed For Jason Chiang
Mostly cleanup work around argument names.  Also added some reference 
implementation code.

Modified:
    
shindig/trunk/content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js
    
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js
    
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements.js
    
shindig/trunk/features/src/test/javascript/features/open-views/viewEnhancements-test.js

Modified: 
shindig/trunk/content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js?rev=1156364&r1=1156363&r2=1156364&view=diff
==============================================================================
--- 
shindig/trunk/content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js
 (original)
+++ 
shindig/trunk/content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js
 Wed Aug 10 20:56:14 2011
@@ -349,6 +349,17 @@ function MediaUI(social) {
    */
   function editMediaItemPopupInGadget(album, mediaItem) {
 
+    function resultCallback(result) {
+      if (result != null) {
+        console.log('container width = ' + result.width);
+        console.log('container height = ' + result.height);
+      }
+    }
+    // Just an example to show how to use the getContainerDimensions API,
+    // it doesn't serve any other purpose for editMediaItemPopupInGadget
+    // function.
+    gadgets.window.getContainerDimensions(resultCallback);
+
     function callback(newMediaItem) {
       var albumId = mediaItem == null ? album.id : mediaItem.albumId;
 

Modified: 
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js?rev=1156364&r1=1156363&r2=1156364&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js
 (original)
+++ 
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js
 Wed Aug 10 20:56:14 2011
@@ -332,21 +332,23 @@
 
   /**
    * Gets the dimensions of the container displaying the gadget.
+   *
+   * @param {function}
+   *          resultCallback: Callback function will be called with the return
+   *          value as a parameter.
    */
-  function getContainerDimensions() {
-    var el = document.documentElement; // Container
-    // element
-    if (el !== undefined)
-      // return client width and client height
-      return {
-        'width' : el.clientWidth,
-        'height' : el.clientHeight
-      };
-    else
-      return {
-        'width' : -1,
-        'height' : -1
-      };
+  function getContainerDimensions(resultCallback) {
+    if (resultCallback == null) {
+      return;
+    }
+    var el = document.documentElement; // Container element
+    var result = {'width' : -1, 'height': -1};
+    if (el !== undefined) {
+      result.width = el.clientWidth;
+      result.height = el.clientHeight;
+    }
+    // return client width and client height
+    resultCallback(result);
   }
 
   osapi.container.Container.addMixin('views', function(container) {

Modified: 
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements.js?rev=1156364&r1=1156363&r2=1156364&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements.js
 (original)
+++ 
shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements.js
 Wed Aug 10 20:56:14 2011
@@ -35,8 +35,8 @@ gadgets['window'] = gadgets['window'] ||
    *          closes. The function will be called with the return value as a
    *          parameter.
    * @param {function}
-   *          idCallback: Callback function to be called with the id of the
-   *          Site which has been opened.
+   *          navigateCallback: Callback function to be called with the
+   *          site and gadget metadata.
    * @param {Object}
    *          opt_params: These are optional parameters which can be used to
    *          open gadgets. The following parameters may be included in this
@@ -48,9 +48,10 @@ gadgets['window'] = gadgets['window'] ||
    *          parameters for the view being rendered.
    */
 
-  gadgets.views.openGadget = function(resultCallback, idCallback, opt_params) {
+  gadgets.views.openGadget = function(resultCallback, navigateCallback,
+          opt_params) {
     gadgets.rpc.call('..', 'gadgets.views.openGadget', null, resultCallback,
-        idCallback, opt_params);
+        navigateCallback, opt_params);
   };
 
   /**
@@ -92,14 +93,14 @@ gadgets['window'] = gadgets['window'] ||
    *          url: URL to a web page to open in a URL site in the container.
    *          (Note this should not be a URL to a gadget definition.).
    * @param {function}
-   *          idCallback: Callback function to be called with the id of the
+   *          navigateCallback: Callback function to be called with the
    *          site which has been opened.
    * @param {string=}
    *          opt_viewTarget: Optional parameter,the view that indicates where
    *          to open the URL.
    */
-  gadgets.views.openUrl = function(url, idCallback, opt_viewTarget) {
-    gadgets.rpc.call('..', 'gadgets.views.openUrl', null, url, idCallback,
+  gadgets.views.openUrl = function(url, navigateCallback, opt_viewTarget) {
+    gadgets.rpc.call('..', 'gadgets.views.openUrl', null, url, 
navigateCallback,
         opt_viewTarget);
   }
 
@@ -107,12 +108,12 @@ gadgets['window'] = gadgets['window'] ||
    * Closes an opened site. If the opt_id parameter is null the container will
    * close the calling site.
    *
-   * @param {string}
-   *          opt_id: Optional parameter which specifies what site to close.
+   * @param {Object=}
+   *          opt_site: Optional parameter which specifies what site to close.
    *          If null it will close the current gadget site.
    */
-  gadgets.views.close = function(id) {
-    gadgets.rpc.call('..', 'gadgets.views.close', null, id);
+  gadgets.views.close = function(opt_site) {
+    gadgets.rpc.call('..', 'gadgets.views.close', null, opt_site);
   };
 
   /**
@@ -138,7 +139,7 @@ gadgets['window'] = gadgets['window'] ||
    */
   gadgets.window.getContainerDimensions = function(resultCallback) {
     gadgets.rpc.call('..', 'gadgets.window.getContainerDimensions',
-        resultCallback, null);
+        null, resultCallback);
   }
 
 }());

Modified: 
shindig/trunk/features/src/test/javascript/features/open-views/viewEnhancements-test.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/open-views/viewEnhancements-test.js?rev=1156364&r1=1156363&r2=1156364&view=diff
==============================================================================
--- 
shindig/trunk/features/src/test/javascript/features/open-views/viewEnhancements-test.js
 (original)
+++ 
shindig/trunk/features/src/test/javascript/features/open-views/viewEnhancements-test.js
 Wed Aug 10 20:56:14 2011
@@ -130,8 +130,8 @@ ViewEnhancementsTest.inherits(TestCase);
 
     this.assertEquals('..', rpcs[0][0]);
     this.assertEquals('gadgets.window.getContainerDimensions', rpcs[0][1]);
-    this.assertEquals(resultCallback, rpcs[0][2]);
-    this.assertNull('Assert null error', rpcs[0][3]);
+    this.assertNull('Assert null error', rpcs[0][2]);
+    this.assertEquals(resultCallback, rpcs[0][3]);
   };
 
 })();


Reply via email to