Author: jmorliaguet
Date: Fri Jan  6 18:24:44 2006
New Revision: 2165

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

- more generic registration (removed switch / case)



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 
18:24:44 2006
@@ -32,27 +32,12 @@
 
   parse: function(node) {
     var elements = node.getElementsByTagName("cpsskins:view");
-    var view = null;
 
     $A(elements).each(function(e, index) {
-
-      // TODO make this more generic
-      switch (e.getAttribute("widget").toLowerCase()) {
-        case "contextmenu": {
-          view = Widgets.contextmenu(e, index);
-          break;
-        }
-        case "tooltip": {
-          view = Widgets.tooltip(e, index);
-          break;
-        }
-        case "panel": {
-          view = Widgets.panel(e, index);
-          break;
-        }
-      }
-
-      if (view) {
+      var widget_id = e.getAttribute("widget").toLowerCase();
+      var factory = Widgets[widget_id];
+      if (factory) {
+        view = factory(e, index);
         var perspectives = (e.getAttribute("perspectives") || "").split(",");
         $A(perspectives).each(function(p) {
           if (!(p in CPSSkins.Perspectives)) {
@@ -61,7 +46,6 @@
           CPSSkins.Perspectives[p].push(view);
         });
       }
-
     });
   },
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to