Author: jmorliaguet
Date: Mon Jan  2 19:02:22 2006
New Revision: 2122

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

 - simplifications and fixes



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 Mon Jan  2 
19:02:22 2006
@@ -302,12 +302,14 @@
   initialize: function(widget, view) {
     this.widget = widget;
     this.view = view;
-    this.area = view.parentNode;
+    this.area = view.parentNode || document;
 
     this.active = false;
 
     var controller = view.getAttribute("controller");
-    this.handlers = controllers[controller].handlers;
+    if (controller) {
+      this.handlers = controllers[controller].handlers;
+    }
 
     this.showEvent = this.showEvent.bindAsEventListener(this);
     this.hideEvent = this.hideEvent.bindAsEventListener(this);
@@ -320,13 +322,16 @@
 
   showEvent: function(e) {
     var element = Event.element(e);
+    var selected = Identifiable.getIdentifiable(element);
+    if (!selected) return;
+
     var x = Event.pointerX(e);
     var y = Event.pointerY(e);
 
     var widget = this.widget;
 
     if (!this.active) {
-      this.selected = Identifiable.getIdentifiable(element);
+      this.selected = selected;
       this.show(x, y);
       this.active = true;
     } else {
@@ -411,8 +416,9 @@
       if (tag.nodeType != 1) continue;
 
       var visible = tag.getAttribute("visible");
+      var disabled = false;
       if (data && visible) {
-        if (!data[visible]) visible = false;
+        if (!data[visible]) disabled = true;
       }
 
       switch (tag.tagName.toLowerCase()) {
@@ -429,16 +435,16 @@
           }
 
           var confirm = tag.getAttribute("confirm");
-          if (confirm && visible) {
+          if (confirm && !disabled) {
             options.attributes.confirm = confirm;
           }
 
           var icon = tag.getAttribute("icon");
-          if (icon && visible) {
+          if (icon && disabled) {
             options.style.backgroundImage = "url(" + icon + ")";
           }
 
-          if (!visible) { 
+          if (disabled) { 
             options.attributes.disabled = true;
             options.class = "disabled";
           }
@@ -469,7 +475,7 @@
         };
 
         case "submenu": {
-          if (!visible) break;
+          if (disabled) break;
           var item = Canvas.addNode(container, {
             tag: "a",
             content: tag.getAttribute("label"),
@@ -494,14 +500,11 @@
             var menu = this._getSubmenu(here);
             if (!menu) return;
 
-            var siblings = here.parentNode.childNodes;
-            for (var i=0;i<siblings.length;i++) {
-              var s = siblings[i];
-              if (s.nodeType != 1) continue;
-              var sm = this._getSubmenu(s);
-              if (sm) Element.hide(sm);
-            }
+            document.getElementsByClassName("submenu", here.parentNode).each(
+              function(v) { Element.hide(v); }
+            );
             Element.show(menu);
+
           }.bindAsEventListener(this);
 
           Event.observe(item, "mouseover", mouseOverEvent);
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to