Author: doll
Date: Tue Mar 11 04:29:47 2008
New Revision: 635891

URL: http://svn.apache.org/viewvc?rev=635891&view=rev
Log:
The sample container ifpc calls now work out of the box. 

- To fix this added a new gadget.getAdditionalParams() method. Use this method 
to add any additional custom parameters into the iframe url. This gets rid of 
the need to make the horribly large getIframeUrl method and bigger as time goes 
on.


Modified:
    incubator/shindig/trunk/javascript/container/gadgets.js
    incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html

Modified: incubator/shindig/trunk/javascript/container/gadgets.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/gadgets.js?rev=635891&r1=635890&r2=635891&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/gadgets.js (original)
+++ incubator/shindig/trunk/javascript/container/gadgets.js Tue Mar 11 04:29:47 
2008
@@ -234,7 +234,7 @@
   if (height > gadgets.container.maxheight_) {
     height = gadgets.container.maxheight_;
   }
-  
+
   var element = document.getElementById(this.f);
   if (element) {
     element.style.height = height + 'px';
@@ -361,7 +361,7 @@
  *    "viewParams": a javascript object containing attribute value pairs
  *        for this gadgets
  *    "secureToken": an encoded token that is passed on the URL hash
- *    "hashData": Query-string like data that will be added to the 
+ *    "hashData": Query-string like data that will be added to the
  *        hash portion of the URL.
  *    "title": the default title to use for the title bar.
  *    "height": height of the gadget
@@ -440,6 +440,14 @@
   throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
 };
 
+/*
+ * Gets additional parameters to append to the iframe url
+ * Override this method if you need any custom params.
+ */
+gadgets.Gadget.prototype.getAdditionalParams = function() {
+  return '';
+}
+
 
 // ---------
 // IfrGadget
@@ -470,7 +478,7 @@
 gadgets.IfrGadget.prototype.rpcRelay = 'files/rpc_relay.html';
 
 gadgets.IfrGadget.prototype.getTitleBarContent = function(continuation) {
-  continuation('<div id="' + this.cssClassTitleBar + '-' + this.id + 
+  continuation('<div id="' + this.cssClassTitleBar + '-' + this.id +
       '" class="' + this.cssClassTitleBar + '"><span id="' +
       this.getIframeId() + '_title" class="' +
       this.cssClassTitle + '">' + (this.title ? this.title : 'Title') + 
'</span> | <span class="' +
@@ -502,9 +510,9 @@
   continuation('<div class="' + this.cssClassGadgetContent + '"><iframe id="' +
       iframeId + '" name="' + iframeId + '" class="' + this.cssClassGadget +
       '" src="' + this.getIframeUrl() +
-      '" frameborder="no" scrolling="no"' + 
+      '" frameborder="no" scrolling="no"' +
       (this.height ? ' height="' + this.height + '"' : '') +
-      (this.width ? ' width="' + this.width + '"' : '') + 
+      (this.width ? ' width="' + this.width + '"' : '') +
       '></iframe></div>');
 };
 
@@ -518,19 +526,20 @@
 
 gadgets.IfrGadget.prototype.getIframeUrl = function() {
   return this.serverBase_ + 'ifr?' +
-      'url=' + encodeURIComponent(this.specUrl) + 
-      '&synd=' + this.SYND + 
-      '&mid=' +  this.id + 
+      'url=' + encodeURIComponent(this.specUrl) +
+      '&synd=' + this.SYND +
+      '&mid=' +  this.id +
       '&nocache=' + gadgets.container.nocache_ +
       '&country=' + gadgets.container.country_ +
       '&lang=' + gadgets.container.language_ +
       '&view=' + gadgets.container.view_ +
       (gadgets.container.parentUrl_ ? '&parent=' + 
encodeURIComponent(gadgets.container.parentUrl_) : '') +
       (this.debug ? '&debug=1' : '') +
+      this.getAdditionalParams() +
       this.getUserPrefsParams() +
-      '#rpctoken=' + this.rpcToken + 
+      '#rpctoken=' + this.rpcToken +
       (this.secureToken ? '&st=' + (this.secureToken || "") : '') +
-      (this.viewParams ? 
+      (this.viewParams ?
           '&view-params=' +  
encodeURIComponent(JSON.stringify(this.viewParams)) : '') +
       (this.hashData ? '&' + this.hashData : '');
 };
@@ -684,7 +693,7 @@
 
 gadgets.Container.prototype.setMaxHeight = function(maxheight) {
   this.maxheight_ = maxheight;
-};  
+};
 
 gadgets.Container.prototype.getGadgetKey_ = function(instanceId) {
   return 'gadget_' + instanceId;

Modified: 
incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html?rev=635891&r1=635890&r2=635891&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html 
(original)
+++ incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html Tue 
Mar 11 04:29:47 2008
@@ -74,6 +74,8 @@
 function changeGadgetUrl() {
   useCaja = document.getElementById("useCajaCheckbox").checked;
   useCache = document.getElementById("useCacheCheckbox").checked;
+  gadgets.container.nocache_ = useCache ? 0 : 1;
+
   usePermissive = document.getElementById("usePermissiveCheckbox").checked;
   doEvil = document.getElementById("doEvilCheckbox").checked;
 
@@ -95,21 +97,16 @@
 
 SampleContainerGadget.inherits(gadgets.IfrGadget);
 
-SampleContainerGadget.prototype.getIframeUrl = function() {
-  var url = this.serverBase_ + 'ifr?url=' +
-      encodeURIComponent(this.specUrl) + '&synd=' + this.SYND + '&mid=' +
-      this.id + '&parent=' + encodeURIComponent(gadgets.container.parentUrl_) +
-      '&ogc=' + document.location.host + this.getUserPrefsParams();
+SampleContainerGadget.prototype.getAdditionalParams = function() {
+  var params = ''
+
   if (useCaja) {
-    url += "&caja=1";
-  }
-  if (!useCache) {
-    url += "&nocache=1";
+    params += "&caja=1";
   }
   if (usePermissive) {
-    url += "&usepermissive=1";
+    params += "&usepermissive=1";
   }
-  return url;
+  return params;
 };
 gadgets.container.gadgetClass = SampleContainerGadget;
 


Reply via email to