Author: jmorliaguet
Date: Tue Feb  7 10:25:36 2006
New Revision: 2314

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
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/quiz/cpsskins_quiz.pt
Log:

- added different types of controllers:

  - "command" controller (maps a command to a handler)

  - "form" controller (will call setData(...) with the form parameters as
    a data 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 
10:25:36 2006
@@ -203,9 +203,13 @@
       switch(classid) {
 
         case "controller": {
-          var controller = new CPSSkins.Controller(el, def);
-          CPSSkins.Controllers[name] = controller;
-          CPSSkins.notify("registered controller " + def.id, controller);
+          var controller_type = def.type || "command";
+          var factory = Controllers[controller_type];
+          if (factory) {
+            var controller = factory(el, def);
+            CPSSkins.Controllers[name] = controller;
+            CPSSkins.notify("registered controller " + def.id, controller);
+          }
           break;
         }
 
@@ -347,10 +351,44 @@
   initialize: function(node, def) {
     this.node = this.node;
     this.def = def;
+    this.setup();
+  },
+
+  setup: function() {
+    /* to override */
   }
 
 }
 
+if (!window.Controllers) { var Controllers = new Object(); }
+Object.extend(Controllers, {
+
+  command: function(node, def) {
+    return new CPSSkins.CommandController(node, def);
+  },
+
+  form: function(node, def) {
+    return new CPSSkins.FormController(node, def);
+  }
+});
+
+CPSSkins.CommandController = Class.create();
+CPSSkins.CommandController.prototype = Object.extend(new 
CPSSkins.Controller(), {
+
+  setup: function() {
+  }
+
+});
+
+CPSSkins.FormController = Class.create();
+CPSSkins.FormController.prototype = Object.extend(new CPSSkins.Controller(), {
+
+  setup: function() {
+    alert('setup');
+  }
+
+});
+
 
 // Identifiable DOM elements.
 if (!window.Identifiable) var Identifiable = new Object();

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 10:25:36 2006
@@ -16,6 +16,7 @@
 
   <ins class="controller">
   {"id": "controller",
+   "type": "command",
    "handlers": {
      "edit": "displayChoice",
      "copy": "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 10:25:36 2006
@@ -18,6 +18,7 @@
 
   <ins class="controller">
   {"id": "controller",
+   "type": "command",
    "handlers": {
      "edit": "displayChoice",
      "copy": "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 10:25:36 2006
@@ -174,7 +174,7 @@
         $A(Form.getInputs(target)).each(function(i) {
           values[i.name] = Form.Element.getValue(i);
         })
-        this.handleAction(target, 'send', values);
+        this.handleAction(target, 'submit', values);
       }
 
     });
@@ -202,11 +202,14 @@
   </p>
   <p>There are two main views: the chat area and the input form</p>
 
+  /* to convert into a form controller */
   <ins class="controller">
   {"id": "controller",
+   "type": "command",
    "handlers": {
-     "send": "submitContent"
-  }}
+     "submit": "submitContent"
+   }}
+  }
   </ins>
 
   <div id="area0">

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
        Tue Feb  7 10:25:36 2006
@@ -140,6 +140,7 @@
 
   <ins class="controller">
   {"id": "controller",
+   "type": "command",
    "handlers": {
      "change": "changeContent"
   }}
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to