Author: jmorliaguet
Date: Sat Feb 25 21:38:44 2006
New Revision: 2467

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

- better API for registering controllers, storage adapters, widgets, effects



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 Sat Feb 25 
21:38:44 2006
@@ -44,6 +44,11 @@
   _currentPerspective: "",
   _previousPerspective: "",
 
+  Controllers: $H({}),
+  Effects: $H({}),
+  Storages: $H({}),
+  Widgets: $H({}),
+
   init: function() {
     CPSSkins.parse(document);
   },
@@ -70,6 +75,22 @@
     return controller;
   },
 
+  registerControllers: function(controllers) {
+    Object.extend(CPSSkins.Controllers, controllers)
+  },
+
+  registerEffects: function(effects) {
+    Object.extend(CPSSkins.Effects, effects)
+  },
+
+  registerStorages: function(storages) {
+    Object.extend(CPSSkins.Storages, storages)
+  },
+
+  registerWidgets: function(widgets) {
+    Object.extend(CPSSkins.Widgets, widgets)
+  },
+
   /* Error handling */
   warn: function(msg, context) {
     var div = document.createElement("div");
@@ -390,8 +411,7 @@
 
 }
 
-if (!CPSSkins.Controllers) { CPSSkins.Controllers = new Object(); }
-Object.extend(CPSSkins.Controllers, {
+CPSSkins.registerControllers({
 
   'command': function(node, def) {
     return new CPSSkins.CommandController(node, def);
@@ -842,7 +862,7 @@
 
 // Effects
 
-CPSSkins.Effects = {
+CPSSkins.registerEffects({
 
   show: function(node, options) {
     var delay = options.delay;
@@ -915,7 +935,7 @@
     });
     return new CPSSkins.Scheduler(options);
   }
-}
+});
 
 // Model
 
@@ -1114,8 +1134,7 @@
 
 }
 
-if (!CPSSkins.Storages) { CPSSkins.Storages = new Object(); }
-Object.extend(CPSSkins.Storages, {
+CPSSkins.registerStorages({
 
   ram: function(model) {
     return new CPSSkins.RAMStorage(model);
@@ -1381,15 +1400,7 @@
 
 }
 
-// Renderer: instanciate a widget.
-if (!CPSSkins.Widgets) { CPSSkins.Widgets = new Object(); }
-
-Object.extend(CPSSkins, {
-  registerWidgets: function(widgets) {
-    Object.extend(CPSSkins.Widgets, widgets)
-  }
-});
-
+// Widgets
 CPSSkins.registerWidgets({
 
   custom: function(def) {
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to