Author: jmorliaguet
Date: Wed Mar 15 21:04:16 2006
New Revision: 2642

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

- controllers have an 'unregister(view)' function



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 Wed Mar 15 
21:04:16 2006
@@ -449,8 +449,11 @@
 
   register: function(view) {
     /* to override */
-  }
+  },
 
+  unregister: function(view) {
+    /* to override */
+  }
 }
 
 CPSSkins.registerControllers({
@@ -507,6 +510,10 @@
     });
 
     CPSSkins.subscribe("command", {'subscriber': controller, 'publisher': 
view});
+  },
+
+  unregister: function(view) {
+    CPSSkins.unsubscribe("command", {'subscriber': this, 'publisher': view});
   }
 
 });
@@ -535,6 +542,9 @@
         })
       }
     })
+  },
+
+  unregister: function(view) {
   }
 
 });
@@ -542,12 +552,16 @@
 CPSSkins.FormController = Class.create();
 CPSSkins.FormController.prototype = Object.extend(new CPSSkins.Controller(), {
 
-  register: function(view) {
+  setup: function() {
+    this.submitEvent = this.submitEvent.bindAsEventListener(this);
+  },
 
-    var widget = view.widget;
+  register: function(view) {
+    Event.observe(view.widget, "submit", this.submitEvent);
+  },
 
-    this.submitEvent = this.submitEvent.bindAsEventListener(this);
-    Event.observe(widget, "submit", this.submitEvent);
+  unregister: function(view) {
+    Event.stopObserving(view.widget, "submit", this.submitEvent);
   },
 
   submitEvent: function(e) {
@@ -1643,10 +1657,15 @@
     var controllers_id = view.getControllers();
     controllers_id.each(function(c) {
     var controller = CPSSkins.getControllerById(c);
-      if (controller) { controller.register(view); }
+      if (controller) { view.attach(controller); }
     });
   },
 
+  attach: function(controller) {
+    controller.unregister(this);
+    controller.register(this);
+  },
+
   observe: function(model) {
     model.addObserver(this);
     this.model = model;
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to