Author: jmorliaguet
Date: Fri Feb 24 19:38:27 2006
New Revision: 2445

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

- simpler code



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 Feb 24 
19:38:27 2006
@@ -50,7 +50,7 @@
 
   getModelById: function(id) {
     var model = null;
-    $A(CPSSkins._models).each(function(m) {
+    CPSSkins._models.each(function(m) {
       var def = m.value.def;
       if (def.id == id) {
         model = m.value
@@ -61,7 +61,7 @@
 
   getControllerById: function(id) {
     var controller = null;
-    $A(CPSSkins._controllers).each(function(c) {
+    CPSSkins._controllers.each(function(c) {
       var def = c.value.def;
       if (def.id == id) {
         controller = c.value;
@@ -86,13 +86,13 @@
   /* Internal events */
   subscribe: function(eventid, event) {
     if (!(eventid in CPSSkins._subscribers)) {
-      CPSSkins._subscribers[eventid] = $A([]);
+      CPSSkins._subscribers[eventid] = [];
     }
     CPSSkins._subscribers[eventid].push(event);
   },
 
   unsubscribe: function(eventid, event) {
-    new_subscribers = $A([]);
+    new_subscribers = [];
     CPSSkins._subscribers[eventid].each(function(e) {
       if (!(event.subscriber == e.subscriber && event.publisher == 
e.publisher)) {
         new_subscribers.push(e);
@@ -102,9 +102,9 @@
   },
 
   notify: function(eventid, event) {
-    var subscribers = CPSSkins._subscribers[eventid];
+    var subscribers = CPSSkins._subscribers[eventid] || [];
     var publisher = event.publisher;
-    $A(subscribers).each(function(e) {
+    subscribers.each(function(e) {
       var event_publisher = e.publisher;
       if (event_publisher == publisher || event_publisher == null) {
         var handler = CPSSkins.getEventHandler(eventid, e.subscriber);
@@ -152,7 +152,7 @@
 
   // first stage
   parse: function(node) {
-    var elements = node.getElementsByTagName("ins");
+    var elements = $A(node.getElementsByTagName("ins"));
     var progress = new Object({'initialized': 0});
     var length = elements.length;
 
@@ -164,7 +164,7 @@
       }
     });
 
-    $A(elements).each(function(el, index) {
+   elements.each(function(el, index) {
       var url = el.getAttribute("cite");
       if (url) {
         var options = {
@@ -188,9 +188,9 @@
 
   // second stage
   load: function(node) {
-    var elements = node.getElementsByTagName("ins");
-    $A(["view", "controller", "model"]).each(function(type) {
-      $A(elements).each(function(el, index) {
+    var elements = $A(node.getElementsByTagName("ins"));
+    ["view", "controller", "model"].each(function(type) {
+      elements.each(function(el, index) {
         if (Element.hasClassName(el, type)) {
           CPSSkins.register(el, type, index);
         }
@@ -263,7 +263,7 @@
 
             /* register the controllers */
             var controllers_id = def.controllers || [];
-            $A(controllers_id).each(function(c) {
+            controllers_id.each(function(c) {
               var evt_id = "registered controller " + c;
               CPSSkins.registerEventHandler(evt_id, view, function(event) {
                 var controller = event.publisher;
@@ -288,10 +288,10 @@
 
             /* registers views per perspective */
             var perspectives = def.perspectives || [];
-            $A(perspectives).each(function(p) {
+            perspectives.each(function(p) {
               if (!p) return;
               if (!(p in CPSSkins._perspectives)) {
-                CPSSkins._perspectives[p] = $A([]);
+                CPSSkins._perspectives[p] = [];
               }
               CPSSkins._perspectives[p].push(view);
             });
@@ -361,8 +361,8 @@
       return to_show.indexOf(el) < 0;
     });
 
-    $A(to_hide).each(function(el) { el.hide(); });
-    $A(to_show).each(function(el) { el.show(); });
+    to_hide.each(function(el) { el.hide(); });
+    to_show.each(function(el) { el.show(); });
 
     CPSSkins._previousPerspective = CPSSkins._currentPerspective;
     CPSSkins._currentPerspective = perspective;
@@ -542,13 +542,13 @@
     this.moveEvent = this.moveEvent.bindAsEventListener(this);
     this.dropEvent = this.dropEvent.bindAsEventListener(this);
 
-    $A(this.def.draggable || []).each(function(d) {
-      $A($$(d)).each(function(el) {
+    (this.def.draggable || []).each(function(d) {
+      $$(d).each(function(el) {
         Event.observe(el, "mousedown", dragEvent); });
     });
 
     var dropzones = this._dropzones = [];
-    $A(this.def.droppable || []).each(function(d) {
+    (this.def.droppable || []).each(function(d) {
       $$(d).each(function(el) { dropzones.push(el); });
     });
   },
@@ -580,7 +580,7 @@
     var y = Event.pointerY(e);
 
     var inTarget = false;
-    $A(this._dropzones).each(function(d) {
+    this._dropzones.each(function(d) {
       if (Position.within(d, x, y)) { inTarget = true; }
     });
 
@@ -998,8 +998,8 @@
   initialize: function(model) {
     this.model = model;
     this.setup();
-    this._queue = $A([]);
-    this._queued_data = $H({});
+    this._queue = [];
+    this._queued_data = {};
   },
 
   readTransaction: function(data) {
@@ -1210,7 +1210,7 @@
   new CPSSkins.StorageAdapter(), {
 
   setup: function() {
-    var models = $A([]);
+    var models = [];
     var storage = this;
 
     // merge the data from all storages
@@ -1220,7 +1220,7 @@
       CPSSkins.notify('stored', {'publisher': storage});
     });
 
-    $A(this.model.def.storage.units).each(function(p) {
+    this.model.def.storage.units.each(function(p) {
       var model = CPSSkins.getModelById(p);
       models.push(model);
       CPSSkins.subscribe('stored',
@@ -1232,14 +1232,14 @@
 
   requestData: function() {
     var model = this.model;
-    $A(this.models).each(function(m) {
+    this.models.each(function(m) {
       m.storage.requestData();
     });
   },
 
   storeData: function(data) {
     var model = this.model;
-    $A(this.models).each(function(m) {
+    this.models.each(function(m) {
       m.storage.storeData(data);
     });
   }
@@ -1551,7 +1551,7 @@
   _renderFragment: function(container, fragment, data) {
 
     var createNode = CPSSkins.Canvas.createNode;
-    $A(fragment.items).each(function(item) {
+    fragment.items.each(function(item) {
 
       var type = item.type;
       var visible = item.visible;
@@ -1602,7 +1602,7 @@
         case "selection": {
           if (!data) return;
           var choices = item.choices;
-          $A(data[choices]).each(function(s) {
+          (data[choices] || []).each(function(s) {
             var options = {
               tag: "a",
               style: {display: "block"},
@@ -1783,7 +1783,7 @@
 
   _renderFragment: function(container, fragment, data) {
     var createNode = CPSSkins.Canvas.createNode;
-    $A(fragment.items).each(function(item) {
+    fragment.items.each(function(item) {
       if (item.type != "item") return;
       var visible = item.visible;
       var disabled = false;
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to