Author: jmorliaguet
Date: Fri Dec 30 21:59:34 2005
New Revision: 2098

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

- cleanup before refactoring of the contextual menu



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 Dec 30 
21:59:34 2005
@@ -212,46 +212,51 @@
 if (!window.Renderer) { var Renderer = new Object(); }
 Object.extend(Renderer, {
 
-  contextmenu: function(node) {
-    var menu = document.createElement('div');
-    Element.addClassName(menu, 'contextMenu');
-    Element.addClassName(menu, node.getAttribute('class'));
-    var items = node.getElementsByTagName('item');
-    var actions = new Object();
-    for (var i=0;i<items.length;i++) {
-      var data = items[i];
-      var action = data.getAttribute('action');
-      actions[action] = {
-        handler: data.getAttribute('handler') || function() {},
-        visible: data.getAttribute('visible') || '',
-        choices: data.getAttribute('choices') || ''
+  contextmenu: function(view) {
+    var widget = document.createElement('div');
+    Element.addClassName(widget, 'contextMenu');
+    Element.addClassName(widget, view.getAttribute('class'));
+
+    var tags = view.getElementsByTagName('*');
+    for (var i=0;i<tags.length;i++) {
+      var tag = tags[i];
+      switch (tag.tagName.toLowerCase()) {
+        case 'item': {
+          var item = document.createElement('a');
+          item.innerHTML = tag.getAttribute('label');
+          item.setAttribute("href", "#");
+          widget.appendChild(item);
+          break;
         };
-      var item = document.createElement('a');
-      item.setAttribute('href', '#');
-      item.setAttribute('action', action);
-      item.setAttribute('confirm', data.getAttribute('confirm'));
-      item.appendChild(document.createTextNode(data.innerHTML));
-      menu.appendChild(item);
+        case 'items': {
+          break;
+        };
+        case 'submenu': {
+          break;
+        };
+      }
+
     }
-    var area = node.getAttribute('area');
-    menu.style.display = 'none';
-    node.parentNode.replaceChild(menu, node);
-    var controller = node.getAttribute('controller');
-    new CPSSkins.ContextualMenu(menu, area, controller, actions);
+
+    Canvas.addWidget(widget);
+    var area = view.parentNode;
+    var controller = view.getAttribute('controller');
+    new CPSSkins.ContextualMenu(widget, area, controller, actions);
   },
 
-  tooltip: function(node) {
-    var tooltip = document.createElement('div');
-    Element.addClassName(tooltip, 'tooltip')
-    tooltip.style.position = 'absolute';
-    tooltip.style.display = 'none';
+  tooltip: function(view) {
+    var widget = document.createElement('div');
+    Element.addClassName(widget, 'tooltip')
+    widget.style.position = 'absolute';
+    widget.style.display = 'none';
+
+    Canvas.addWidget(widget);
+    var area = view.parentNode;
     var options = {
-      showdelay: node.getAttribute('showdelay') || 1000,
-      hidedelay: node.getAttribute('hidedelay') || 100,
+      showdelay: view.getAttribute('showdelay') || 1000,
+      hidedelay: view.getAttribute('hidedelay') || 100,
     }
-    var area = node.parentNode;
-    Canvas.addWidget(tooltip);
-    new CPSSkins.Tooltip(tooltip, area, options);
+    new CPSSkins.Tooltip(widget, area, options);
   }
 
 });
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to