You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by rg...@apache.org on 2010/10/23 03:25:14 UTC

svn commit: r1026540 - in /incubator/wookie/trunk/widgets/widget-template: index.html scripts/properties.js scripts/ui.js

Author: rgardler
Date: Sat Oct 23 01:25:14 2010
New Revision: 1026540

URL: http://svn.apache.org/viewvc?rev=1026540&view=rev
Log:
Add simple demonstration of property handling

Added:
    incubator/wookie/trunk/widgets/widget-template/scripts/properties.js   (with props)
Modified:
    incubator/wookie/trunk/widgets/widget-template/index.html
    incubator/wookie/trunk/widgets/widget-template/scripts/ui.js

Modified: incubator/wookie/trunk/widgets/widget-template/index.html
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/index.html?rev=1026540&r1=1026539&r2=1026540&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/index.html (original)
+++ incubator/wookie/trunk/widgets/widget-template/index.html Sat Oct 23 01:25:14 2010
@@ -20,7 +20,8 @@
         <meta http-equiv="pragma" content="no-cache"/>
         <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/ui.js" charset="utf-8"></script>
+        <script type="text/javascript" src="scripts/properties.js" charset="utf-8"></script>  
 		<title>@widget.shortname@</title>
 	</head>
 	<body>
@@ -31,9 +32,8 @@
 		  <p>@widget.description@</p>
 		</div>
 		<div id="wookie-settings">
-	      <p>This is the settings pane, it is hidden by default. 
-	         If your widget does not have any settings then remove this pane.</p>
-	       <p><input type="submit" class="wookie-form-button" value="Save" onclick="wookieShowMain()"/></p>
+	      <p>Frontpage content</p> <textarea rows="6" cols="20" id="wookie-template-property-content"></textarea>
+	      <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/scripts/properties.js
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/scripts/properties.js?rev=1026540&view=auto
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/scripts/properties.js (added)
+++ incubator/wookie/trunk/widgets/widget-template/scripts/properties.js Sat Oct 23 01:25:14 2010
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//
+// Helper methods for manipulating the widget properties
+//
+
+/**
+ * Save the properties and take any appropriate actions then display the
+ * main page again.
+ */
+function saveProperties() {
+    var text = dwr.util.getValue("wookie-template-property-content");
+    Widget.preferences.setItem("content", text);
+    wookieShowMain();
+}
+

Propchange: incubator/wookie/trunk/widgets/widget-template/scripts/properties.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/wookie/trunk/widgets/widget-template/scripts/ui.js
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/widget-template/scripts/ui.js?rev=1026540&r1=1026539&r2=1026540&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/widget-template/scripts/ui.js (original)
+++ incubator/wookie/trunk/widgets/widget-template/scripts/ui.js Sat Oct 23 01:25:14 2010
@@ -15,21 +15,41 @@
  * limitations under the License.
  */
 
+var username="FIXME: set username";
+
 /**
  * Helper methods for manipulating the widget UI.
  */
 
 
 function wookieShowSettings(event) {
-	var content = document.getElementById("wookie-content");
-	var settings = document.getElementById("wookie-settings");
-	content.style.display="none";
-	settings.style.display="block";
+	var elemContent = document.getElementById("wookie-content");
+	var elemSettings = document.getElementById("wookie-settings");
+	
+	var elemContentProperty = document.getElementById("wookie-template-property-content");
+	elemContentProperty.innerHTML = elemContent.innerHTML;
+	
+	elemContent.style.display="none";
+	elemSettings.style.display="block";
 }
 
 function wookieShowMain(event) {
-	var content = document.getElementById("wookie-content");
-	var settings = document.getElementById("wookie-settings");
-	content.style.display="block";
-	settings.style.display="none";	
+	var content = Widget.preferences.getItem("content");
+	var elemContent = document.getElementById("wookie-content");
+	elemContent.innerHTML = content;
+	
+	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
+
+/*
+ * 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>");
 }
\ No newline at end of file