Author: jmorliaguet
Date: Sat Jan 14 13:05:42 2006
New Revision: 2207

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

- renamed "tag" as "def" for the object's definition

- objects can specify the data source (<object data="someurl.txt">)
  (not implemented)



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 Jan 14 
13:05:42 2006
@@ -59,35 +59,46 @@
         return;
       }
 
-      if (classid != "cpsskins:view") {
-        return;
-      }
+      switch(classid) {
 
-      var config = CPSSkins.jsonParse(el);
+        case "cpsskins:model": {
+          var data = el.getAttribute("data");
+          if (data) {
+            // fetch data
+          }
+          break;
+        }
 
-      var widget_type = config.widget.type;
-      if (!(widget_type in Widgets)) {
-        return;
-      }
-      var factory = Widgets[widget_type];
-      if (factory) {
-        view = factory(config);
-        view.id = index;
-        el.parentNode.insertBefore(view.widget, el);
-
-        var perspectives = config.perspectives || [];
-        $A(perspectives).each(function(p) {
-          if (!p) return;
-          if (!(p in CPSSkins.Perspectives)) {
-            CPSSkins.Perspectives[p] = $A([]);
+        case "cpsskins:view": {
+          var config = CPSSkins.jsonParse(el);
+
+          var widget_type = config.widget.type;
+          if (!(widget_type in Widgets)) {
+            return;
           }
-          CPSSkins.Perspectives[p].push(view);
-        });
+          var factory = Widgets[widget_type];
+          if (factory) {
+            view = factory(config);
+            view.id = index;
+            el.parentNode.insertBefore(view.widget, el);
+
+            var perspectives = config.perspectives || [];
+            $A(perspectives).each(function(p) {
+              if (!p) return;
+              if (!(p in CPSSkins.Perspectives)) {
+                CPSSkins.Perspectives[p] = $A([]);
+              }
+              CPSSkins.Perspectives[p].push(view);
+            });
 
-        var model = config.model;
-        if (model) {
-          CPSSkins.addObserver(model, view)
+            var model = config.model;
+            if (model) {
+              CPSSkins.addObserver(model, view)
+            }
+          }
+          break;
         }
+
       }
 
     });
@@ -530,33 +541,33 @@
 CPSSkins.View = function() {};
 CPSSkins.View.prototype = {
 
-  initialize: function(widget, tag) {
+  initialize: function(widget, def) {
     this.widget = widget;
-    this.tag = tag;
+    this.def = def;
 
-    var controller_id = tag.controller || null;
+    var controller_id = def.controller || null;
     if (controller_id) {
       this.controller = CPSSkins.Controllers[controller_id];
     } else {
       this.controller = null;
     }
 
-    var model = tag.model;
+    var model = def.model;
     if (model) {
       this.model = $(model);
     } else {
       this.model = null;
     }
 
-    this.show_effect = tag.show_effect || {};
-    this.hide_effect = tag.hide_effect || {};
+    this.show_effect = def.show_effect || {};
+    this.hide_effect = def.hide_effect || {};
 
     this.setup();
   },
 
   /* Public API */
   inspect: function() {
-    return "[CPSSkins " + this.tag.getAttribute("widget") + "]";
+    return "[CPSSkins " + this.def.widget + "]";
   },
 
   setup: function() {
@@ -650,31 +661,31 @@
 if (!window.Widgets) { var Widgets = new Object(); }
 Object.extend(Widgets, {
 
-  contextmenu: function(tag) {
+  contextmenu: function(def) {
     var widget = Canvas.createNode({
       tag: "div",
       classes: "contextMenu",
       style: {position:"absolute", display:"none"}
     });
-    return new CPSSkins.ContextualMenu(widget, tag);
+    return new CPSSkins.ContextualMenu(widget, def);
 
   },
 
-  tooltip: function(tag) {
+  tooltip: function(def) {
     var widget = Canvas.createNode({
       tag: "div",
       classes: "tooltip",
       style: {position:"absolute", display:"none"}
     });
-    return new CPSSkins.Tooltip(widget, tag);
+    return new CPSSkins.Tooltip(widget, def);
   },
 
-  panel: function(tag) {
+  panel: function(def) {
     var widget = Canvas.createNode({
       tag: "div",
       style: {display: "none"}
     });
-    return new CPSSkins.Panel(widget, tag);
+    return new CPSSkins.Panel(widget, def);
   }
 
 });
@@ -686,7 +697,7 @@
 
   setup: function() {
     this.visible = false;
-    this.url = this.tag.widget.url;
+    this.url = this.def.widget.url;
     this.css_id = null;
     this.script_id = null;
 
@@ -703,7 +714,7 @@
 
   render: function(data) {
     var url = data;
-    var script = this.tag.widget.script;
+    var script = this.def.widget.script;
     if (script) {
       this.script_id = this.id;
       Canvas.addScript(this.script_id, script);
@@ -727,7 +738,7 @@
   },
 
   prepare: function() {
-    var css = this.tag.widget.css;
+    var css = this.def.widget.css;
     if (css) {
       this.css_id = "cpsskins-panel-css" + this.id;
       Canvas.addStyleSheet(this.css_id, css);
@@ -747,7 +758,7 @@
 CPSSkins.ContextualMenu.prototype = Object.extend(new CPSSkins.View(), {
 
   setup: function() {
-    this.area = this.tag.parentNode || document;
+    this.area = this.def.parentNode || document;
     this.active = false;
 
     this.showEvent = this.showEvent.bindAsEventListener(this);
@@ -764,7 +775,7 @@
 
   render: function(data) {
     this.widget.innerHTML = '';
-    this._renderFragment(this.widget, this.tag.widget, data);
+    this._renderFragment(this.widget, this.def.widget, data);
   },
 
   _getSubmenu: function(element) {
@@ -899,7 +910,7 @@
     Canvas.fitInsideScreen(widget);
 
     // TODO: move this elsewhere
-    if (!this.tag.model) {
+    if (!this.def.model) {
       CPSSkins.addObserver(selected, this);
     }
   },
@@ -976,7 +987,7 @@
 CPSSkins.Tooltip.prototype = Object.extend(new CPSSkins.View(), {
 
   setup: function() {
-    this.area = this.tag.parentNode;
+    this.area = this.def.parentNode;
 
     this.showEvent = this.showEvent.bindAsEventListener(this);
     this.hideEvent = this.hideEvent.bindAsEventListener(this);
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to