Author: jmorliaguet
Date: Fri Jan  6 23:22:18 2006
New Revision: 2166

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- implemented a simple observer:

  each view can register an observer that will monitor a data provider for
  changes.

  when the data (model) is changed the view is updated by calling:

  update(data) 

- renamed Renderers as Widgets



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 Fri Jan  6 
23:22:18 2006
@@ -21,6 +21,8 @@
 
   Controllers: $H({}),
 
+  Observers: $H({}),
+
   Perspectives: $H({}),
 
   CurrentPerspective: "",
@@ -45,11 +47,22 @@
           }
           CPSSkins.Perspectives[p].push(view);
         });
+
+        var observed = e.getAttribute("observe");
+        if (observed) {
+          observed = $(observed);
+          if (!(observed in CPSSkins.Observers)) {
+            CPSSkins.Observers[observed] = $A([]);
+          }
+          CPSSkins.Observers[observed].push(view);
+        }
       }
+
     });
   },
 
   /* Controller */
+
   getController: function(view) {
     var controller = view.getAttribute("controller");
     return this.Controllers[controller];
@@ -268,6 +281,11 @@
       //node.parentNode.removeChild(old);
     }
     node.parentNode.insertBefore(comment, node);
+
+    CPSSkins.Observers[node].each(function(v) {
+      v.update(data);
+    });
+
   },
 
   updateNodeData: function(element, data) {
@@ -421,9 +439,7 @@
       style: {display: "none"},
       attributes: {id: "cpsskins-panel" + index}
     });
-
     return new CPSSkins.Panel(widget, view);
-
   }
 
 });
@@ -441,14 +457,14 @@
     this.url = this.view.getAttribute("url");
     this.css_id = null;
     this.script_id = null;
-    this.init();
+    this.render();
   },
 
   inspect: function() {
     return '[CPSSkins Panel:' + this.url + ']';
   },
 
-  init: function() {
+  render: function() {
     var script = this.view.getAttribute("script");
     if (script) {
       this.script_id = this.id;
@@ -548,7 +564,7 @@
   },
 
   hideEvent: function(e) {
-    Element.hide(this.widget);
+    this.hide();
     var x = Event.pointerX(e);
     var y = Event.pointerY(e);
     if (!Position.within(this.area, x, y)) {
@@ -563,7 +579,7 @@
     if (!action) return;
     var choice = element.getAttribute("choice") || action;
     var confirm = element.getAttribute("confirm");
-    Element.hide(this.widget);
+    this.hide();
     if (confirm) {
       if (!window.confirm(confirm)) return;
     }
@@ -736,6 +752,10 @@
         };
       }
     }
+  },
+
+  hide: function() {
+    Element.hide(this.widget);
   }
 
 }
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to