Author: zhen
Date: Fri Jan 11 20:29:45 2008
New Revision: 611363

URL: http://svn.apache.org/viewvc?rev=611363&view=rev
Log:
Added "settitle" support using IFPC.


Added:
    incubator/shindig/trunk/javascript/container/sample7.html   (with props)
Modified:
    incubator/shindig/trunk/features/settitle/settitle.js
    incubator/shindig/trunk/javascript/container/gadgets.js

Modified: incubator/shindig/trunk/features/settitle/settitle.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/settitle/settitle.js?rev=611363&r1=611362&r2=611363&view=diff
==============================================================================
--- incubator/shindig/trunk/features/settitle/settitle.js (original)
+++ incubator/shindig/trunk/features/settitle/settitle.js Fri Jan 11 20:29:45 
2008
@@ -28,6 +28,11 @@
  * @param {String} title Preferred title.
  */
 gadgets.Window.setTitle = function(title) {
-  // TODO
+  var modId = 'remote_module_' + (new gadgets.Prefs()).getModuleId();
+  var ifpcRelay = gadgets.util.getUrlParameters().parent || '';
+  gadgets.IFPC_.call(modId, 'set_title', [modId, title], ifpcRelay, null, '');
 };
+
+// Alias for legacy code
+var _IG_SetTitle = gadgets.Window.setTitle;
 

Modified: incubator/shindig/trunk/javascript/container/gadgets.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/gadgets.js?rev=611363&r1=611362&r2=611363&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/gadgets.js (original)
+++ incubator/shindig/trunk/javascript/container/gadgets.js Fri Jan 11 20:29:45 
2008
@@ -225,6 +225,7 @@
   gadgets.GadgetService.call(this);
   gadgets.IFPC_.registerService('resize_iframe', this.setHeight);
   gadgets.IFPC_.registerService('set_pref', this.setUserPref);
+  gadgets.IFPC_.registerService('set_title', this.setTitle);
 };
 
 gadgets.IfrGadgetService.inherits(gadgets.GadgetService);
@@ -237,7 +238,10 @@
 };
 
 gadgets.IfrGadgetService.prototype.setTitle = function(gadget, title) {
-  throw Error(gadgets.error.TO_BE_DONE);
+  var element = document.getElementById(gadget + '_title');
+  if (element) {
+    element.innerHTML = title.replace(/&/g, '&amp;').replace(/</g, '&lt;');
+  }
 };
 
 /**
@@ -451,7 +455,8 @@
 gadgets.IfrGadget.prototype.cssClassGadgetContent = 'gadgets-gadget-content';
 
 gadgets.IfrGadget.prototype.getTitleBarContent = function(continuation) {
-  continuation('<div class="' + this.cssClassTitleBar + '"><span class="' +
+  continuation('<div class="' + this.cssClassTitleBar + '"><span id="' +
+      this.getIframeId() + '_title" class="' +
       this.cssClassTitle + '">Title</span> | <span class="' +
       this.cssClassTitleButtonBar +
       '"><a href="#" onclick="gadgets.container.getGadget(' + this.id +

Added: incubator/shindig/trunk/javascript/container/sample7.html
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/sample7.html?rev=611363&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/container/sample7.html (added)
+++ incubator/shindig/trunk/javascript/container/sample7.html Fri Jan 11 
20:29:45 2008
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Sample: settitle support</title>
+<!-- default container look and feel -->
+<link rel="stylesheet" href="gadgets.css">
+<script type="text/javascript" src="json.js"></script>
+<script type="text/javascript" src="ifpc.js"></script>
+<script type="text/javascript" src="cookies.js"></script>
+<script type="text/javascript" src="gadgets.js"></script>
+<script type="text/javascript">
+var specUrl0 = 'http://www.google.com/ig/modules/test_settitle_html.xml';
+
+function init() {
+  gadgets.container.layoutManager =
+      new gadgets.FloatLeftLayoutManager('gadget-parent');
+
+  gadgets.container.setParentUrl('ifpc_relay.html');
+  var gadget = gadgets.container.createGadget({specUrl: specUrl0});
+  gadget.setServerBase('http://localhost:8080/gadgets/'); 
+  gadgets.container.addGadget(gadget);
+};
+
+function renderGadgets() {
+  gadgets.container.renderGadgets();
+};
+</script>
+</head>
+<body onLoad="init();renderGadgets()">
+  <h2>Sample: settitle support</h2>
+  <div>(Requires a Shindig server running at http://localhost:8080)</div>
+  <div id="gadget-parent" class="gadgets-gadget-parent"></div>
+</body>
+</html>

Propchange: incubator/shindig/trunk/javascript/container/sample7.html
------------------------------------------------------------------------------
    svn:executable = *


Reply via email to