Author: jmorliaguet
Date: Wed Mar 15 00:11:35 2006
New Revision: 2641

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
Log:

- made it possible to register existing page areas as widgets (their content
  will not be managed by the toolkit)



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 Wed Mar 15 
00:11:35 2006
@@ -294,11 +294,22 @@
           var widget_type;
 
           var template = def.widget.template;
+          var area = def.widget.area;
+
+          if (area && template) {
+            CPSSkins.warn("Cannot specify both a widget area and a template.",
+                          el);
+          }
+
+          if (area) {
+            widget_type = 'area';
+          }
+
           if (template) {
             widget_type = 'custom';
           } else {
             /* generic widget type */
-            widget_type = def.widget.type;
+            widget_type = widget_type || def.widget.type;
             if (!widget_type) {
               CPSSkins.warn("Must specify a widget type or a template", el);
             } else if (!(widget_type in this.Widgets)) {
@@ -357,7 +368,7 @@
               } else {
                 CPSSkins.warn("Unknown node id: " + replace, el);
               }
-            } else {
+            } else if (!area) {
               el.parentNode.insertBefore(view.widget, el);
             }
 
@@ -764,7 +775,8 @@
     }
 
     if (this.def.dragging.feedback) {
-      this.moved.setStyle({'width': this.target.getStyle('width')});
+      if (this.target)
+        this.moved.setStyle({'width': this.target.getStyle('width')});
     }
     Event.stop(e);
   },
@@ -1739,6 +1751,11 @@
 // Widgets
 CPSSkins.registerWidgets({
 
+  area: function(def) {
+    var widget = $(def.widget.area);
+    return new CPSSkins.AreaWidget(widget, def);
+  },
+
   custom: function(def) {
     var widget = CPSSkins.Canvas.createNode({
       tag: "div"
@@ -1782,6 +1799,16 @@
   }
 });
 
+// Node widget
+CPSSkins.AreaWidget = Class.create();
+CPSSkins.AreaWidget.prototype = Object.extend(new CPSSkins.View(), {
+
+  inspect: function() {
+    return "[Area Widget " + this.def.widget.area + "]";
+  }
+
+});
+
 // Custom widget
 CPSSkins.CustomWidget = Class.create();
 CPSSkins.CustomWidget.prototype = Object.extend(new CPSSkins.View(), {

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
        Wed Mar 15 00:11:35 2006
@@ -61,7 +61,7 @@
   </style>
 
 </head>
-<body>
+<body id="area">
 
   <h1>CPSSkins: drag-and-drop</h1>
 
@@ -161,6 +161,15 @@
     }
     </ins>
 
+    <ins class="view">
+    {"id": "d2",
+     "widget": {
+        "area": "area"
+     },
+     "model": "dummy",
+     "controllers": ["dnd", "dnd2", "dnd3", "dnd4"]
+    }
+    </ins>
 
   </div>
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to