Author: jmorliaguet
Date: Sun Feb  5 12:02:21 2006
New Revision: 2296

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/quiz/cpsskins_quiz.pt
Log:

- registered a "local storage" (cookies) not implemented yet



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 Sun Feb  5 
12:02:21 2006
@@ -748,63 +748,43 @@
 if (!window.Storages) { var Storages = new Object(); }
 Object.extend(Storages, {
 
-  compound: function(model) {
-    return new CPSSkins.CompoundStorage(model);
-  },
-
   ram: function(model) {
     return new CPSSkins.RAMStorage(model);
   },
 
+  local: function(model) {
+    return new CPSSkins.LocalStorage(model);
+  },
+
   remote: function(model) {
     return new CPSSkins.RemoteStorage(model);
+  },
+
+  compound: function(model) {
+    return new CPSSkins.CompoundStorage(model);
   }
 
 });
 
-CPSSkins.CompoundStorage = Class.create();
-CPSSkins.CompoundStorage.prototype = Object.extend(
+CPSSkins.RAMStorage = Class.create();
+CPSSkins.RAMStorage.prototype = Object.extend(
   new CPSSkins.StorageAdapter(), {
 
-  setup: function() {
-    var models = $A([]);
-    var storage = this;
-
-    // merge the data from all storages
-    CPSSkins.registerEventHandler('stored', storage, function(event) {
-      event.subscriber.merge(event.target.read());
-      // propagate the event
-      CPSSkins.notify('stored', storage);
-    });
-
-    $A(this.model.def.storage.partitions).each(function(p) {
-      var model = CPSSkins.getModelById(p);
-      models.push(model);
-      CPSSkins.subscribe('stored',
-        {'subscriber': storage, 'target': model.storage}
-      );
-    });
-    this.models = models;
-  },
-
   requestData: function() {
-    var model = this.model;
-    this.write({});
-    $A(this.models).each(function(m) {
-      m.storage.requestData();
-    });
+    /* nothing to do since the data is already there */
+    CPSSkins.notify('stored', this);
   },
 
   storeData: function(data) {
-    var model = this.model;
-    $A(this.models).each(function(m) {
-      m.storage.storeData(data);
-    });
+    /* Store the data directly */
+    this.write(data);
+    CPSSkins.notify('stored', this);
   }
+
 });
 
-CPSSkins.RAMStorage = Class.create();
-CPSSkins.RAMStorage.prototype = Object.extend(
+CPSSkins.LocalStorage = Class.create();
+CPSSkins.LocalStorage.prototype = Object.extend(
   new CPSSkins.StorageAdapter(), {
 
   requestData: function() {
@@ -860,6 +840,48 @@
 
 });
 
+CPSSkins.CompoundStorage = Class.create();
+CPSSkins.CompoundStorage.prototype = Object.extend(
+  new CPSSkins.StorageAdapter(), {
+
+  setup: function() {
+    var models = $A([]);
+    var storage = this;
+
+    // merge the data from all storages
+    CPSSkins.registerEventHandler('stored', storage, function(event) {
+      event.subscriber.merge(event.target.read());
+      // propagate the event
+      CPSSkins.notify('stored', storage);
+    });
+
+    $A(this.model.def.storage.partitions).each(function(p) {
+      var model = CPSSkins.getModelById(p);
+      models.push(model);
+      CPSSkins.subscribe('stored',
+        {'subscriber': storage, 'target': model.storage}
+      );
+    });
+    this.models = models;
+  },
+
+  requestData: function() {
+    var model = this.model;
+    this.write({});
+    $A(this.models).each(function(m) {
+      m.storage.requestData();
+    });
+  },
+
+  storeData: function(data) {
+    var model = this.model;
+    $A(this.models).each(function(m) {
+      m.storage.storeData(data);
+    });
+  }
+});
+
+
 // View
 
 CPSSkins.View = function() {};
@@ -897,7 +919,6 @@
   },
 
   /* Private API */
-
   observe: function(model) {
     model.addObserver(this);
     this.model = model;

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html
        Sun Feb  5 12:02:21 2006
@@ -123,7 +123,7 @@
   <h1>CPSSkins model-view test</h1>
 
   <p>The views observe the model.
-     When the model changes the views gets updated.</p>
+     When the model changes the views get updated.</p>
 
   <h2>Model</h2>
   <ins class="model">

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/quiz/cpsskins_quiz.pt
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/quiz/cpsskins_quiz.pt
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/quiz/cpsskins_quiz.pt
        Sun Feb  5 12:02:21 2006
@@ -15,9 +15,6 @@
         href="/++skin++cpsskins/@@/++resource++cpsskins.css" />
 
   <style type="text/css">
-    .choices {
-      font: 1.3em Arial;
-    }
 
     div.inputbox {
       padding: 0.5em;
@@ -128,6 +125,13 @@
   <p>A <strong>storage adapter</strong> can be specified in the model
      definition to describe how the model will access the data.
   </p>
+  <p>There are 4 types of storages available:</p>
+  <ul>
+    <li><a href="#ram">RAM</a></li>
+    <li><a href="#local">Local</a> (stores the data in cookies)</li>
+    <li><a href="#remote">Remote</a> (accesses a remote server)</li>
+    <li><a href="#compound">Compound</a> (a combination of several 
storages)</li>
+  </ul>
 
   <ins class="controller">
   {"id": "controller",
@@ -137,12 +141,46 @@
   </ins>
 
 
+  <a name="ram"></a>
   <h2>RAM storage</h2>
 
   <p>In a <strong>RAM storage</strong> the data is entirely stored in the
      client's memory. The server is never accessed.
      There is no data persistence.</p>
 
+  <div id="area0">
+
+    <ins class="model">
+    {"id": "ram-data-provider",
+     "data": {
+      "message": "",
+      "content": ""
+     },
+     "storage": {
+       "type": "ram"
+       }
+     }
+    }
+    </ins>
+
+    <ins class="view">
+    {"widget": {
+      "type": "inputbox"
+     },
+     "model": "ram-data-provider",
+     "controller": "controller"
+    }
+    </ins>
+
+  </div>
+
+  <a name="local"></a>
+  <h2>Local storage</h2>
+
+  <p>In a <strong>local storage</strong> the data is stored in a cookie
+     on the client. The server is never accessed. There is data persistence
+     as long as the cookie does not expire.</p>
+
   <div id="area1">
 
     <ins class="model">
@@ -152,7 +190,8 @@
       "content": ""
      },
      "storage": {
-       "type": "ram"
+       "id": "1",
+       "type": "local"
        }
      }
     }
@@ -169,6 +208,8 @@
 
   </div>
 
+
+  <a name="remote"></a>
   <h2>Remote storage</h2>
   <p>In this example the data is stored <strong>on the server</strong> inside
      the session.
@@ -197,6 +238,7 @@
      <cite>dark</cite>
   </p>
 
+
   <div id="area2">
 
     <ins class="model">
@@ -226,8 +268,9 @@
 
   </div>
 
+  <a name="compound"></a>
   <h2>Compound storage</h2>
-  <p>A compound storage is created by combining the storages of different
+  <p>A compound storage is created by putting together the storages of 
different
      models.</p>
 
   <div id="area3">
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to