Author: jmorliaguet
Date: Tue Feb  7 12:33:25 2006
New Revision: 2317

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt
Log:

- small refactoring: the command controller now receives an info structure.



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 Tue Feb  7 
12:33:25 2006
@@ -380,11 +380,12 @@
 CPSSkins.CommandController = Class.create();
 CPSSkins.CommandController.prototype = Object.extend(new 
CPSSkins.Controller(), {
 
-  call: function(view, object, action, args) {
+  call: function(info) {
+    var action = info.action;
     var handler_id = this.def.handlers[action];
     if (handler_id) {
       var handler = CPSSkins.Handlers[handler_id];
-      handler(view.model, object, args);
+      handler(info);
     }
   }
 
@@ -1026,11 +1027,13 @@
     }
   },
 
-  handleAction: function(object, action, args) {
+  handleAction: function(info) {
     var controller = this.controller;
     if (!controller) return;
-    var view = this;
-    controller.call(view, object, action, args);
+    // add some contextual info
+    info.model = this.model;
+    info.view = this;
+    controller.call(info);
   },
 
   getData: function() {
@@ -1425,7 +1428,12 @@
       if (!window.confirm(confirm)) return;
     }
     /* notify the controller to take action */
-    this.handleAction(this.selected, action, choice);
+    var info = {
+      "target": this.selected,
+      "action": action,
+      "options": {'choice': choice}
+    }
+    this.handleAction(info);
     this.active = false;
   },
 

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html
       (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html
       Tue Feb  7 12:33:25 2006
@@ -104,9 +104,12 @@
 
   <!-- Controller -->
   <script type="text/javascript">
-    function displayChoice(model, context, choice) {
+    function displayChoice(info) {
+      var target = info.target;
+      var options = info.options;
+
       $("message").innerHTML +=
-        context.getAttribute('id') + ' =&gt; ' + choice + '\n';
+        target.getAttribute('id') + ' =&gt; ' + options.choice + '\n';
     }
 
     CPSSkins.registerHandlers({'displayChoice': displayChoice});

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html
  (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html
  Tue Feb  7 12:33:25 2006
@@ -164,9 +164,11 @@
 
   <!-- Controller -->
   <script type="text/javascript">
-    function displayChoice(model, context, choice) {
+    function displayChoice(info) {
+      var target = info.target;
+      var options = info.options;
       $("message").innerHTML +=
-        context.getAttribute('id') + ' =&gt; ' + choice + '\n';
+        target.getAttribute('id') + ' =&gt; ' + info.options.choice + '\n';
     }
 
     CPSSkins.registerHandlers({'displayChoice': displayChoice});

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt
        Tue Feb  7 12:33:25 2006
@@ -112,7 +112,7 @@
     InputBox.prototype = Object.extend(new CPSSkins.View(), {
 
       setup: function() {
-        this.changeEvent = this.changeEvent.bindAsEventListener(this);
+        this.submitEvent = this.submitEvent.bindAsEventListener(this);
       },
 
       render: function(data) {
@@ -164,29 +164,36 @@
         });
         form.appendChild(button);
 
-        Event.observe(form, "submit", this.changeEvent);
+        Event.observe(form, "submit", this.submitEvent);
         Form.focusFirstElement(form);
       },
 
-      changeEvent: function(e) {
+      submitEvent: function(e) {
         var target = Event.element(e);
-        var values = {};
+        var data = {};
         $A(Form.getInputs(target)).each(function(i) {
-          values[i.name] = Form.Element.getValue(i);
+          data[i.name] = Form.Element.getValue(i);
         })
-        this.handleAction(target, 'submit', values);
+        info = {
+          "options": data,
+          "action": "submit",
+          "target": target
+        }
+        this.handleAction(info);
       }
 
     });
 
     /* Controller */
 
-    function changeContent(model, context, value) {
-      value['status'] = 'Sending message ...';
-      model.setData(value);
+    function submitContent(info) {
+      var data = info.options;
+      var model = info.model;
+      data['status'] = 'Sending message ...';
+      model.setData(data);
     }
 
-    CPSSkins.registerHandlers({'submitContent': changeContent});
+    CPSSkins.registerHandlers({'submitContent': submitContent});
 
   </script>
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to