Author: rgardler
Date: Thu Feb 24 22:14:57 2011
New Revision: 1074316

URL: http://svn.apache.org/viewvc?rev=1074316&view=rev
Log:
add a wave widget template

Added:
    incubator/wookie/trunk/widgets/widget-template/wave/
      - copied from r1074310, 
incubator/wookie/trunk/widgets/widget-template/basic/
    incubator/wookie/trunk/widgets/widget-template/wave/scripts/controller.js   
(with props)
Modified:
    incubator/wookie/trunk/widgets/widget-template/wave/config.xml
    incubator/wookie/trunk/widgets/widget-template/wave/index.html
    incubator/wookie/trunk/widgets/widget-template/wave/scripts/properties.js
    incubator/wookie/trunk/widgets/widget-template/wave/scripts/ui.js

Modified: incubator/wookie/trunk/widgets/widget-template/wave/config.xml
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/wave/config.xml?rev=1074316&r1=1074310&r2=1074316&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/wave/config.xml (original)
+++ incubator/wookie/trunk/widgets/widget-template/wave/config.xml Thu Feb 24 
22:14:57 2011
@@ -25,6 +25,7 @@
   <content src="index.html"/>
   <icon src="images/icon.png"/>
   <author>Apache Wookie (Incubating) Team</author>
+  <feature name="http://wave.google.com"; required="true"/>
   <licence>Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.

Modified: incubator/wookie/trunk/widgets/widget-template/wave/index.html
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/wave/index.html?rev=1074316&r1=1074310&r2=1074316&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/wave/index.html (original)
+++ incubator/wookie/trunk/widgets/widget-template/wave/index.html Thu Feb 24 
22:14:57 2011
@@ -21,20 +21,27 @@
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <link rel="stylesheet" type="text/css" href="style/screen.css" />
         <script type="text/javascript" src="scripts/ui.js" 
charset="utf-8"></script>
-        <script type="text/javascript" src="scripts/properties.js" 
charset="utf-8"></script>  
+        <script type="text/javascript" src="scripts/properties.js" 
charset="utf-8"></script>
+        <script type="text/javascript" src="scripts/controller.js" 
charset="utf-8"></script>  
                <title>@widget.shortname@</title>
        </head>
-       <body>
+       <body onLoad="Controller.init()">
          <div id="wookie-widget">
-               <div id="wookie-toolbar"><img id="wookie-widget-icon" 
src="images/icon_16x16.png" onclick="wookieShowSettings()" 
alt="@widget.shortname@ Icon"/>@widget.shortname@</div>
+               <div id="wookie-toolbar">
+                 <img id="wookie-widget-icon" src="images/icon_16x16.png" 
onclick="wookieShowSettings()" alt="@widget.shortname@ Settings"/>
+                 <span id="wookie-toolbar-text">@widget.shortname@</span>
+               </div>
+               
                <div id="wookie-content">
                  <h2>@widget.shortname@</h2>
                  <p>@widget.description@</p>
                </div>
+               
                <div id="wookie-settings">
-             <p>Frontpage content</p> <textarea rows="6" cols="20" 
id="wookie-template-property-content"></textarea>
+             <p>Reset update count <input type="checkbox" 
id="setting-reset-update-count"></input></p>
              <p><input type="submit" class="wookie-form-button" value="Save" 
onclick="saveProperties()"/>
            </div>
+               
                <div id="wookie-footer">Powered by Apache Wookie 
(Incubating)</div>
          </div>
          

Added: incubator/wookie/trunk/widgets/widget-template/wave/scripts/controller.js
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/wave/scripts/controller.js?rev=1074316&view=auto
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/wave/scripts/controller.js 
(added)
+++ incubator/wookie/trunk/widgets/widget-template/wave/scripts/controller.js 
Thu Feb 24 22:14:57 2011
@@ -0,0 +1,60 @@
+/**
+ * The Controller object
+ * This is used to wire up the view and model with actions
+ */ 
+var Controller = {
+               
+       user: {},
+       updateUser:function() {
+               if (wave.getViewer() != null){
+                       Controller.user.id = wave.getViewer().getId();
+                       Controller.user.username = 
wave.getViewer().getDisplayName();
+                       Controller.user.thumbnail  = 
wave.getViewer().getThumbnailUrl();
+               }
+               if (Controller.user.thumbnail == "" || 
Controller.user.thumbnail == null) { 
+                       Controller.user.thumbnail = "anon.png";
+               }
+               if (Controller.user.username == null || 
Controller.user.username == "") {
+                       Controller.user.username = "anonymous";        
+                       Controller.user.id = "anonymous";
+               }
+       },
+       
+       stateUpdated:function() {
+               Controller.count = 
parseInt(wave.getState().get("update-count"));
+               var elemContent = document.getElementById("wookie-content");
+               var countText = "<p>Update count is now " + Controller.count + 
"</p>";
+               var updateButton = "<p><input type='submit' 
class='wookie-form-button' value='Update Count' 
onclick='Controller.updateCount()' /></p>";
+               elemContent.innerHTML = countText + updateButton;
+               
+               var date = new Date();
+               wookieSetFooter("State Updated " + date.getHours() + ":" + 
date.getMinutes() + ":" + date.getSeconds());
+       },
+       
+       count: 0,
+       updateCount:function() {
+               Controller.count = Controller.count + 1;
+               wave.getState().submitValue("update-count", 
JSON.stringify(Controller.count));
+       },
+       
+       resetCount:function() {
+               Controller.count = 0;
+               wave.getState().submitValue("update-count", 
JSON.stringify(Controller.count));
+       },
+               
+       participantsUpdated:function() {
+               wookieSetFooter("Participants Updated");
+       },
+           
+       init:function() {
+               Controller.updateUser();
+               wave.getState().submitValue("update-count", 
JSON.stringify(Controller.count));
+               /**
+                * Register the event handlers with the Wave feature
+                */
+           wave.setStateCallback(Controller.stateUpdated);
+               wave.setParticipantCallback(Controller.participantsUpdated);
+               Widget.preferences.setItem("content", "<p>Welcome to 
@widget.shortname@, " + Controller.user.username + "</p>");
+               wookieShowMain(null);
+       }
+}
\ No newline at end of file

Propchange: 
incubator/wookie/trunk/widgets/widget-template/wave/scripts/controller.js
------------------------------------------------------------------------------
    svn:executable = *

Modified: 
incubator/wookie/trunk/widgets/widget-template/wave/scripts/properties.js
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/wave/scripts/properties.js?rev=1074316&r1=1074310&r2=1074316&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/wave/scripts/properties.js 
(original)
+++ incubator/wookie/trunk/widgets/widget-template/wave/scripts/properties.js 
Thu Feb 24 22:14:57 2011
@@ -24,8 +24,10 @@
  * main page again.
  */
 function saveProperties() {
-    var text = dwr.util.getValue("wookie-template-property-content");
-    Widget.preferences.setItem("content", text);
+    var clear = dwr.util.getValue("setting-reset-update-count");
+    if (clear == true) {
+      Controller.resetCount();
+    }
+    wookieSetFooter("Properties Saved");
     wookieShowMain();
 }
-

Modified: incubator/wookie/trunk/widgets/widget-template/wave/scripts/ui.js
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/wave/scripts/ui.js?rev=1074316&r1=1074310&r2=1074316&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/wave/scripts/ui.js (original)
+++ incubator/wookie/trunk/widgets/widget-template/wave/scripts/ui.js Thu Feb 
24 22:14:57 2011
@@ -15,41 +15,35 @@
  * limitations under the License.
  */
 
-var username="FIXME: set username";
-
 /**
  * Helper methods for manipulating the widget UI.
  */
-
-
 function wookieShowSettings(event) {
-       var elemContent = document.getElementById("wookie-content");
-       var elemSettings = document.getElementById("wookie-settings");
-       
-       var elemContentProperty = 
document.getElementById("wookie-template-property-content");
-       elemContentProperty.value = elemContent.innerHTML;
+       wookieSetHeader("@widget.shortname@ : Settings");
        
+       var elemContent = document.getElementById("wookie-content");
        elemContent.style.display="none";
+       
+       var elemSettings = document.getElementById("wookie-settings");
        elemSettings.style.display="block";
 }
 
 function wookieShowMain(event) {
-       var content = Widget.preferences.getItem("content");
+       wookieSetHeader("@widget.shortname@ : " + Controller.user.username);
+       
        var elemContent = document.getElementById("wookie-content");
-       elemContent.innerHTML = content;
+       elemContent.style.display="block";
        
        var elemSettings = document.getElementById("wookie-settings");
-       elemContent.style.display="block";
        elemSettings.style.display="none";      
 }
 
-// Functions below this line are for demonstration purposes only and should be 
removed or
-// replaced in production widgets
+function wookieSetHeader(headText) {
+       var headerContent = document.getElementById("wookie-toolbar-text");
+       headerContent.innerHTML = headText;
+}
 
-/*
- * Set the content of the homepage.
- */
-function setContent() {
-    var text = dwr.util.getValue("wookie-template-content");
-    text = dwr.util.escapeHtml(text + "<br/><sub>Set by " + username + 
"</sub>");
+function wookieSetFooter(footText) {
+       var headerContent = document.getElementById("wookie-footer");
+       headerContent.innerHTML = footText;
 }
\ No newline at end of file


Reply via email to