Author: jmorliaguet Date: Sun Jan 1 23:56:29 2006 New Revision: 2113 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.css cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log:
- "invisible" menu items are disabled. Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.css ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.css (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.css Sun Jan 1 23:56:29 2006 @@ -24,6 +24,7 @@ } .contextMenu a { + cursor: default; text-decoration: none; vertical-align: top; background-repeat: no-repeat; @@ -33,6 +34,14 @@ width: 86px; } +.contextMenu a.disabled { + color: #ccc; +} + +.contextMenu a.disabled:hover { + color: #ccc; +} + .contextMenu a:hover { background-color: #3465a4; color: #fff; 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 Sun Jan 1 23:56:29 2006 @@ -252,8 +252,7 @@ var widget = Canvas.addNode(document.body, { tag: "div", class: ["contextMenu", view.getAttribute("class")], - style: {position:"absolute", display:"none", cursor:"default", - whitespace:"nowrap"} + style: {position:"absolute", display:"none", whitespace:"nowrap"} }); new CPSSkins.ContextualMenu(widget, view); }, @@ -295,6 +294,7 @@ var widget = this.widget; if (this.active) { if (Position.within(widget, x, y)) { + if (element.getAttribute("disabled")) return; var action = element.getAttribute("action"); if (!action) return; var confirm = element.getAttribute("confirm"); @@ -384,26 +384,33 @@ var visible = tag.getAttribute("visible"); if (data && visible) { - if (!data[visible]) continue; + if (!data[visible]) visible = false; } switch (tag.tagName.toLowerCase()) { case "item": { - var style = {display: "block"}; - var icon = tag.getAttribute("icon"); - if (icon) { - style.backgroundImage = "url(" + icon + ")"; - } - Canvas.addNode(container, { + var options = { tag: "a", content: tag.getAttribute("label"), - style: style, + style: {display: "block"}, attributes: { action: tag.getAttribute("action"), href: "javascript:void(0)" } - }); + } + + var icon = tag.getAttribute("icon"); + if (icon) { + options.style.backgroundImage = "url(" + icon + ")"; + } + + if (!visible) { + options.attributes.disabled = true; + options.class = "disabled"; + } + + Canvas.addNode(container, options); break; }; @@ -413,27 +420,28 @@ var choices = tag.getAttribute("choices"); var items = data[choices] || []; for (var j=0;j<items.length;j++) { - var style = {display: "block"}; - var icon = tag.getAttribute("icon"); - if (icon) { - style.backgroundImage = "url(" + icon + ")"; - } - Canvas.addNode(container, { + + var options = { tag: "a", content: items[j].label, - style: style, + style: {display: "block"}, attributes: { action: tag.getAttribute("action"), choice: items[j].choice, href: "javascript:void(0)" } - }); - + } + var icon = tag.getAttribute("icon"); + if (icon) { + options.style.backgroundImage = "url(" + icon + ")"; + } + Canvas.addNode(container, options); }; break; }; case "submenu": { + if (!visible) break; var item = Canvas.addNode(container, { tag: "a", content: tag.getAttribute("label"), -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins