Author: jmorliaguet
Date: Sat Jan 14 14:02:55 2006
New Revision: 2208

Added:
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_remote_data.html
   (contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/data1.txt   
(contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/data2.txt   
(contents, props changed)
Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- implemented object's remote data (read-only so far)

- added functional test



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Sat Jan 14 
14:02:55 2006
@@ -59,15 +59,24 @@
         return;
       }
 
-      switch(classid) {
+      var url = el.getAttribute("data");
+      if (url) {
+         new Ajax.Request(url, {
+           onComplete: function(req) {
+             el.innerHTML = req.responseText;
+             CPSSkins.load(el, classid, index);
+           }
+         });
+      } else {
+        load(el, classid);
+      }
 
-        case "cpsskins:model": {
-          var data = el.getAttribute("data");
-          if (data) {
-            // fetch data
-          }
-          break;
-        }
+    });
+  },
+
+  load: function(el, classid, index) {
+
+      switch(classid) {
 
         case "cpsskins:view": {
           var config = CPSSkins.jsonParse(el);
@@ -78,7 +87,7 @@
           }
           var factory = Widgets[widget_type];
           if (factory) {
-            view = factory(config);
+            var view = factory(config);
             view.id = index;
             el.parentNode.insertBefore(view.widget, el);
 
@@ -100,8 +109,6 @@
         }
 
       }
-
-    });
   },
 
   addObserver: function(model, view) {

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_remote_data.html
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_remote_data.html
  Sat Jan 14 14:02:55 2006
@@ -0,0 +1,79 @@
+<?xml version="1.0" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xml:lang="en" lang="en"
+      xmlns="http://www.w3.org/1999/xhtml";
+      xmlns:cpsskins=http://namespaces.zope.org/cpsskins";>
+<head>
+  <title>CPSSkins Unit test file</title>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+  <script src="../../prototype.js" type="text/javascript"></script>
+  <script src="../../json.js" type="text/javascript"></script>
+  <script src="../../cpsskins.js" type="text/javascript"></script>
+  <link rel="stylesheet" href="../../cpsskins.css" type="text/css" />
+
+  <style type="text/css">
+    pre {
+      padding: 0.5em;
+    }
+    a {
+      border: 1px solid #999;
+      background-color: #efc;
+      padding: 0.5em;
+      text-decoration: none;
+    }
+    #area1 {
+      padding: 1em;
+    }
+  </style>
+
+</head>
+<body>
+
+  <h1>CPSSkins: remote data</h1>
+
+  <p>The object's definiton for both the model and the view can specify a
+     remote location from which the data will be fetched.
+  </p>
+
+
+  <div id="area1">
+
+    <object classid="cpsskins:model" data="data1.txt">
+    </object>
+    <a href="#">Open</a>
+
+    <object classid="cpsskins:view" data="data2.txt">
+    </object>
+
+  </div>
+
+
+  <h2>Source:</h2>
+  <pre>
+  &lt;object classid="cpsskins:model" data="data1.txt"&gt;
+  &lt;/object&gt;
+  &lt;a href="#"&gt;Open&lt;/a&gt;
+
+  &lt;object classid="cpsskins:view" data="data2.txt"&gt;
+  &lt;/object&gt;
+  </pre>
+
+  <h3>data1.txt</h3>
+  <pre>{"hint":"Click here to open the document."}</pre>
+
+  <h3>data2.txt</h3>
+  <pre>{"widget": {
+   "type": "tooltip"
+ },
+
+ "show_effect": {
+   "transition": "fadein"
+ },
+
+ "hide_effect": {
+   "transition": "fadeout"
+}}</pre>
+
+</body>
+</html>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/data1.txt
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/data1.txt  
Sat Jan 14 14:02:55 2006
@@ -0,0 +1 @@
+{"hint":"Click here to open the document."}

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/data2.txt
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/data2.txt  
Sat Jan 14 14:02:55 2006
@@ -0,0 +1,12 @@
+
+{"widget": {
+   "type": "tooltip"
+ },
+
+ "show_effect": {
+   "transition": "fadein"
+ },
+
+ "hide_effect": {
+   "transition": "fadeout"
+}}
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to