Reviewers: rbaxter85, dev_shindig.apache.org,

Description:
1. Update implementation of gadgets.window.getContainerDimensions based
on latest API which will call the callback function with the dimension
object as parameter.
2. correct the feature docs.

Please review this at http://codereview.appspot.com/4800050/

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


### Eclipse Workspace Patch 1.0
#P shindig-project
Index: content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js
===================================================================
--- content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js (revision 1150846) +++ content/samplecontainer/examples/media-openGadgets/MediaUIOpenGadgets.js (working copy)
@@ -349,6 +349,14 @@
    */
   function editMediaItemPopupInGadget(album, mediaItem) {

+    function resultCallback(result) {
+      if (result != null) {
+        console.log('container width = ' + result.width);
+        console.log('container height = ' + result.height);
+      }
+    }
+    gadgets.window.getContainerDimensions(resultCallback);
+
     function callback(newMediaItem) {
       var albumId = mediaItem == null ? album.id : mediaItem.albumId;

Index: features/src/main/javascript/features/open-views/viewenhancements-container.js
===================================================================
--- features/src/main/javascript/features/open-views/viewenhancements-container.js (revision 1150848) +++ features/src/main/javascript/features/open-views/viewenhancements-container.js (working copy)
@@ -332,21 +332,28 @@

   /**
    * 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() {
+  function getContainerDimensions(resultCallback) {
+    if (resultCallback == null) {
+      return;
+    }
     var el = document.documentElement; // Container
     // element
     if (el !== undefined)
       // return client width and client height
-      return {
+      resultCallback({
         'width' : el.clientWidth,
         'height' : el.clientHeight
-      };
+      });
     else
-      return {
+      resultCallback({
         'width' : -1,
         'height' : -1
-      };
+      });
   }

   osapi.container.Container.addMixin('views', function(container) {
Index: features/src/main/javascript/features/open-views/viewenhancements.js
===================================================================
--- features/src/main/javascript/features/open-views/viewenhancements.js (revision 1150848) +++ features/src/main/javascript/features/open-views/viewenhancements.js (working copy)
@@ -35,8 +35,8 @@
* 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 @@
    *          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 @@
* 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 @@
* 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.getContainerDimensions = function(resultCallback) {
     gadgets.rpc.call('..', 'gadgets.window.getContainerDimensions',
-        resultCallback, null);
+        null, resultCallback);
   }

 }());
Index: features/src/test/javascript/features/open-views/viewEnhancements-test.js
===================================================================
--- features/src/test/javascript/features/open-views/viewEnhancements-test.js (revision 1150704) +++ features/src/test/javascript/features/open-views/viewEnhancements-test.js (working copy)
@@ -130,8 +130,8 @@

     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