Author: jmorliaguet
Date: Tue May 16 22:54:51 2006
New Revision: 3151

Modified:
   cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js

Log:

- simpler syntax, normalization of strings in hashes



Modified: cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js
==============================================================================
--- cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js    
(original)
+++ cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js    Tue May 
16 22:54:51 2006
@@ -207,20 +207,20 @@
     if (!length) {
       return;
     }
-    var progress = {'initialized': 0};
+    var progress = {initialized: 0};
 
     this.registerEventHandler("initialized", progress, function(event) {
       var progress = event.scope;
       progress.initialized += 1;
       if (progress.initialized >= length) {
         CPSSkins._load(node);
-        CPSSkins.unsubscribe("initialized", {'scope': progress});
-        CPSSkins.notify("parsed", {'publisher': node});
+        CPSSkins.unsubscribe("initialized", {scope: progress});
+        CPSSkins.notify("parsed", {publisher: node});
         CPSSkins.getViews().invoke('attachControllers');
       }
     });
     CPSSkins.subscribe("initialized",
-      {'subscriber': progress, 'scope': progress}
+      {subscriber: progress, scope: progress}
     );
 
     elements.each(function(el) {
@@ -229,7 +229,7 @@
         var options = {
           onComplete: function(req) {
             CPSSkins._eval(el, req.responseText);
-            CPSSkins.notify('initialized', {'publisher': el, 'scope': 
progress});
+            CPSSkins.notify('initialized', {publisher: el, scope: progress});
           }
         };
         var parts = url.split('?');
@@ -242,7 +242,7 @@
         /* the definition is written inline */
         CPSSkins._eval(el, el.innerHTML);
         el.innerHTML = '';
-        CPSSkins.notify('initialized', {'publisher': el, 'scope': progress});
+        CPSSkins.notify('initialized', {publisher: el, scope: progress});
       }
     });
   },
@@ -285,7 +285,7 @@
               this._controllers[id] = controller;
             }
             CPSSkins.notify("registered controller",
-              {'publisher': controller, 'scope': id}
+              {publisher: controller, scope: id}
             );
           }
           break;
@@ -297,7 +297,7 @@
             model = new CPSSkins.Model(node, def);
             this._models[id] = model;
             CPSSkins.notify("registered model",
-              {'publisher': model, 'scope': id}
+              {publisher: model, scope: id}
             );
           }
           break;
@@ -349,11 +349,11 @@
                 var view = event.subscriber;
                 view.observe(model);
                 CPSSkins.unsubscribe("registered model",
-                  {'scope': model.hash()}
+                  {scope: model.hash()}
                 );
               });
               CPSSkins.subscribe("registered model",
-                {'subscriber': view, 'scope': model_id}
+                {subscriber: view, scope: model_id}
               );
             }
 
@@ -369,10 +369,7 @@
             } else if (!area) {
               el.parentNode.insertBefore(view.widget, el);
             }
-
-            CPSSkins.notify("registered view",
-              {'publisher': view, 'scope': id}
-            );
+            CPSSkins.notify("registered view", {publisher: view, scope: id});
           }
           break;
         }
@@ -520,11 +517,11 @@
       }
     });
 
-    CPSSkins.subscribe("command", {'subscriber': controller, 'publisher': 
view});
+    CPSSkins.subscribe("command", {subscriber: controller, publisher: view});
   },
 
   unregister: function(view) {
-    CPSSkins.unsubscribe("command", {'subscriber': this, 'publisher': view});
+    CPSSkins.unsubscribe("command", {subscriber: this, publisher: view});
   }
 
 });
@@ -541,7 +538,7 @@
     var rules = this.def.rules;
     var model = view.model;
     var controller = this;
-    var info = {'model': model, 'view': view, 'controller': controller};
+    var info = {model: model, view: view, controller: controller};
 
     var handlers = this.handlers;
     $H(rules).each(function(r) {
@@ -772,8 +769,8 @@
       view.stopObserving();
     });
 
-    CPSSkins.subscribe("gained focus", {'subscriber': controller});
-    CPSSkins.subscribe("lost focus", {'subscriber': controller});
+    CPSSkins.subscribe("gained focus", {subscriber: controller});
+    CPSSkins.subscribe("lost focus", {subscriber: controller});
   }
 
 });
@@ -819,7 +816,7 @@
     }
 
     var dragEvent = this.dragEvent.bindAsEventListener(
-                      Object.extend(this, {'widget': widget}));
+                      Object.extend(this, {widget: widget}));
     Event.observe(widget, "mousedown", dragEvent);
 
   },
@@ -827,7 +824,7 @@
   unregister: function(view) {
     var widget = view.widget;
     var dragEvent = this.dragEvent.bindAsEventListener(
-                      Object.extend(this, {'widget': widget}));
+                      Object.extend(this, {widget: widget}));
     Event.stopObserving(widget, "mousedown", dragEvent);
   },
 
@@ -898,7 +895,7 @@
 
     if (this.def.dragging.feedback) {
       var dim = draggable.getDimensions();
-      var feedback = CPSSkins.Canvas.createNode({"tag": "div"});
+      var feedback = CPSSkins.Canvas.createNode({tag: 'div'});
       feedback.setStyle({
         'z-index': parseInt(draggable.getStyle('z-index') || 0) +1,
         'width': dim.width + 'px',
@@ -906,7 +903,7 @@
       });
       if (this.def.dragging.feedback.clone) {
         var clone = $(draggable.cloneNode(true));
-        clone.setStyle({'margin': '0'});
+        clone.setStyle({margin: '0'});
         feedback.appendChild(clone);
       } else {
         feedback.setStyle({
@@ -927,8 +924,8 @@
     this.dragged = draggable;
     this.dragged.setOpacity(this.def.dragging.opacity || 0.8);
 
-    this.moved.setStyle({'position': 'absolute'});
-    this.moved.moveTo({'x': x-this.x1, 'y': y-this.y1});
+    this.moved.setStyle({position: 'absolute'});
+    this.moved.moveTo({x: x-this.x1, y: y-this.y1});
 
     Event.observe(document, "mousemove", this.moveEvent);
     Event.observe(document, "mouseup", this.dropEvent);
@@ -1047,7 +1044,7 @@
       if (highlight && this._dropzones) {
         this._dropzones.each(function(el) {
           CPSSkins.Effects.deactivate(el,
-            {'duration': highlight.duration || 1000}
+            {duration: highlight.duration || 1000}
           );
         });
       }
@@ -1055,10 +1052,10 @@
       if (zoomto) {
         var pos = Position.cumulativeOffset(this.target);
         this.moved.moveTo({
-          'x': pos[0],
-          'y': pos[1],
-          'duration': zoomto.duration || 400,
-          'onComplete': function() { this.parentNode.removeChild(this); }
+          x: pos[0],
+          y: pos[1],
+          duration: zoomto.duration || 400,
+          onComplete: function() { this.parentNode.removeChild(this); }
         });
       }
     }
@@ -1086,7 +1083,7 @@
         this.switchTo(perspective);
       }
     }.bind(this));
-    CPSSkins.subscribe("parsed", {"subscriber": this, "publisher": this.node});
+    CPSSkins.subscribe("parsed", {subscriber: this, publisher: this.node});
   },
 
   register: function(view) {
@@ -1292,8 +1289,8 @@
     var regExp = new RegExp("^rgb\\((\\d+),(\\d+),(\\d+)\\)$");
     var bgColor = element.getStyle('background-color') || 'rgb(255,255,255)';
     var match = regExp.exec(bgColor.replace(/\s+/g,''));
-    if (!match) return {'r': 1, 'g': 1, 'b': 1};
-    return {'r': match[1]/255, 'g': match[2]/255, 'b': match[3]/255}
+    if (!match) return {r: 1, g: 1, b: 1};
+    return {r: match[1]/255, g: match[2]/255, b: match[3]/255}
   },
 
   moveTo: function(element, options) {
@@ -1333,7 +1330,7 @@
       if (y + height > page_h) y = page_h - height;
       if (y < offsetY) y = offsetY;
     }
-    element.setStyle({'left': x + 'px', 'top': y + 'px' });
+    element.setStyle({left: x + 'px', top: y + 'px' });
   }
 
 });
@@ -1459,7 +1456,7 @@
     }
     Object.extend(options, {
       action: function(value) {
-        node.setBackgroundColor({'r': bg.r, 'g': bg.g, 'b': bg.b-value});
+        node.setBackgroundColor({r: bg.r, g: bg.g, b: bg.b-value});
       }
     });
     return new CPSSkins.Scheduler(options);
@@ -1469,7 +1466,7 @@
     var bg = node._saved_bg_color;
     Object.extend(options, {
       action: function(value) {
-        node.setBackgroundColor({'r': bg.r, 'g': bg.g, 'b': bg.b-(1-value)});
+        node.setBackgroundColor({r: bg.r, g: bg.g, b: bg.b-(1-value)});
       },
       onComplete: function() { node.setBackgroundColor(bg) }
     });
@@ -1528,12 +1525,12 @@
       var view = event.subscriber;
       view.refresh();
     });
-    CPSSkins.subscribe('changed', {'subscriber': view, 'publisher': model});
+    CPSSkins.subscribe('changed', {subscriber: view, publisher: model});
   },
 
   removeObserver: function(view) {
     var model = this;
-    CPSSkins.unsubscribe('changed', {'subscriber': view, 'publisher': model});
+    CPSSkins.unsubscribe('changed', {subscriber: view, publisher: model});
   },
 
   /* Private API */
@@ -1551,7 +1548,7 @@
   _setStorageAdapter: function() {
     var storage_def = this.def.storage;
     if (!storage_def) {
-      storage_def = {"type": "ram"};
+      storage_def = {type: 'ram'};
       this.def.storage = storage_def;
     }
     var model = this;
@@ -1560,10 +1557,10 @@
     // the model reacts to events on the storage and notifies observers
     CPSSkins.registerEventHandler('stored', model, function(event) {
       var model = event.subscriber;
-      CPSSkins.notify('changed', {'publisher': model});
+      CPSSkins.notify('changed', {publisher: model});
     });
 
-    CPSSkins.subscribe('stored', {'subscriber': model, 'publisher': storage});
+    CPSSkins.subscribe('stored', {subscriber: model, publisher: storage});
 
     var refresh = storage_def.refresh;
     if (refresh && refresh > 0) {
@@ -1672,7 +1669,7 @@
     });
     if (!this._data || !this._compareData(this.read(), new_data)) {;
       this.model.writeData(new_data);
-      CPSSkins.notify('stored', {'publisher': this});
+      CPSSkins.notify('stored', {publisher: this});
     }
     return new_data;
   },
@@ -1815,14 +1812,14 @@
     CPSSkins.registerEventHandler('stored', storage, function(event) {
       event.subscriber.merge(event.publisher.read());
       // propagate the event
-      CPSSkins.notify('stored', {'publisher': storage});
+      CPSSkins.notify('stored', {publisher: storage});
     });
 
     this.model.def.storage.units.each(function(p) {
       var model = CPSSkins.getModelById(p);
       models.push(model);
       CPSSkins.subscribe('stored',
-        {'subscriber': storage, 'publisher': model.storage}
+        {subscriber: storage, publisher: model.storage}
       );
     });
     this.models = models;
@@ -1950,12 +1947,11 @@
   },
 
   focus: function() {
-    CPSSkins.notify("gained focus", {'publisher': this,
-                                     'context': this.selected});
+    CPSSkins.notify("gained focus", {publisher: this, context: this.selected});
   },
 
   defocus: function() {
-    CPSSkins.notify("lost focus", {'publisher': this});
+    CPSSkins.notify("lost focus", {publisher: this});
   },
 
   show: function() {
@@ -2016,42 +2012,42 @@
 
   custom: function(def) {
     var widget = CPSSkins.Canvas.createNode({
-      tag: "div"
+      tag: 'div'
     });
     return new CPSSkins.CustomWidget(widget, def);
   },
 
   contextmenu: function(def) {
     var widget = CPSSkins.Canvas.createNode({
-      tag: "div",
-      classes: "contextMenu",
-      style: {position:"absolute", display:"none"}
+      tag: 'div',
+      classes: 'contextMenu',
+      style: {position: 'absolute', display: 'none'}
     });
     return new CPSSkins.ContextualMenu(widget, def);
   },
 
   contextactions: function(def) {
     var widget = CPSSkins.Canvas.createNode({
-      tag: "div",
-      classes: "contextActions",
-      style: {position:"absolute", display:"none"}
+      tag: 'div',
+      classes: 'contextActions',
+      style: {position: 'absolute', display: 'none'}
     });
     return new CPSSkins.ContextualActions(widget, def);
   },
 
   tooltip: function(def) {
     var widget = CPSSkins.Canvas.createNode({
-      tag: "div",
-      classes: "tooltip",
-      style: {position: "absolute", display: "none"}
+      tag: 'div',
+      classes: 'tooltip',
+      style: {position: 'absolute', display: 'none'}
     });
     return new CPSSkins.Tooltip(widget, def);
   },
 
   panel: function(def) {
     var widget = CPSSkins.Canvas.createNode({
-      tag: "div",
-      style: {display: "none"}
+      tag: 'div',
+      style: {display: 'none'}
     });
     return new CPSSkins.Panel(widget, def);
   }
@@ -2081,7 +2077,7 @@
         onComplete: function(req) {
           view.source = req.responseText;
           CPSSkins.notify("loaded template",
-            {'publisher': view, 'scope': view.hash()}
+            {publisher: view, scope: view.hash()}
           );
         }
       }
@@ -2097,11 +2093,11 @@
         var view = event.subscriber;
         view.reload();
         view.attachControllers();
-        CPSSkins.unsubscribe("loaded template", {'scope': view.hash()});
+        CPSSkins.unsubscribe("loaded template", {scope: view.hash()});
       });
 
       CPSSkins.subscribe("loaded template",
-        {'subscriber': view, 'scope': view.hash()}
+        {subscriber: view, scope: view.hash()}
       );
     }
 
@@ -2246,12 +2242,12 @@
 
         case "item": {
           var options = {
-            tag: "a",
-            style: {display: "block"},
+            tag: 'a',
+            style: {display: 'block'},
             classes: [],
             attributes: {
               action: item.action,
-              href: "javascript:void(0)"
+              href: 'javascript:void(0)'
             }
           }
 
@@ -2286,8 +2282,8 @@
           var choices = item.choices;
           (data[choices] || []).each(function(s) {
             var options = {
-              tag: "a",
-              style: {display: "block"},
+              tag: 'a',
+              style: {display: 'block'},
               attributes: {
                 action: item.action,
                 choice: s.choice,
@@ -2322,10 +2318,10 @@
 
         case "submenu": {
           var options = {
-            tag: "a",
-            classes: "submenuitem",
-            style: {display: "block"},
-            attributes: {href:"javascript:void(0)"}
+            tag: 'a',
+            classes: 'submenuitem',
+            style: {display: 'block'},
+            attributes: {href: 'javascript:void(0)'}
           };
 
           if (disabled) { options.classes = "disabled"; }
@@ -2333,10 +2329,10 @@
 
           var icon = item.icon || "noicon.png";
           submenuitem.appendChild(createNode({
-            tag: "img",
+            tag: 'img',
             attributes: {
-              "src": icon,
-              "alt": "*"
+              src: icon,
+              alt: '*'
             }
           }));
 
@@ -2345,13 +2341,13 @@
           }
 
           var submenu = createNode({
-            tag: "div",
-            classes: "submenu",
+            tag: 'div',
+            classes: 'submenu',
             style: {
-              position: "absolute",
-              left: this.submenuLeft + "px",
-              display: "none",
-              margin: "-20px 0 0 0"
+              position: 'absolute',
+              left: this.submenuLeft + 'px',
+              display: 'none',
+              margin: '-20px 0 0 0'
             }
           });
           submenuitem.appendChild(document.createTextNode(item.label));
@@ -2411,10 +2407,10 @@
     }
     /* notify the controller to take action */
     var info = {
-      "target": this.selected,
-      "publisher": this,
-      "subscriber": this.controller,
-      "options": {'action': action, 'choice': choice}
+      target: this.selected,
+      publisher: this,
+      subscriber: this.controller,
+      options: {action: action, choice: choice}
     }
     CPSSkins.notify("command", info);
     Event.stop(e);
@@ -2453,12 +2449,12 @@
         if (!data[visible]) return;
      }
       var options = {
-        tag: "a",
-        style: {display: "block"},
+        tag: 'a',
+        style: {display: 'block'},
         classes: [],
         attributes: {
           action: item.action,
-          href: "javascript:void(0)"
+          href: 'javascript:void(0)'
         }
       }
 
@@ -2470,10 +2466,10 @@
       var a = createNode(options);
       var icon = disabled ? "noicon.png": (item.icon || "noicon.png");
       a.appendChild(createNode({
-        tag: "img",
+        tag: 'img',
         attributes: {
-          "src": icon,
-          "alt": "*"
+          src: icon,
+          alt: '*'
         }
       }));
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to