Author: jmorliaguet Date: Mon Dec 26 19:09:37 2005 New Revision: 2085 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log:
- simplifications / 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 Dec 26 19:09:37 2005 @@ -26,17 +26,37 @@ if (!tag.match(/^cpsskins:/i)) continue; var element = elements[i]; switch (tag.toLowerCase()) { - case 'cpsskins:contextmenu': Renderer.contextmenu(element); - case 'cpsskins:tooltip': Renderer.tooltip(element); + case 'cpsskins:contextmenu': { + Renderer.contextmenu(element); + break; + } + case 'cpsskins:tooltip': { + Renderer.tooltip(element); + break; + } } } } } +Event.observe(window, 'load', CPSSkins.init); + + +// Controller var controllers = []; -Event.observe(window, 'load', CPSSkins.init); +CPSSkins.Controller = Class.create(); +CPSSkins.Controller.prototype = { + + initialize: function(id) { + this.id = id; + controllers.push(this); + }, + + add: function(items) { + } +} // Identifiable DOM elements. if (!window.Identifiable) var Identifiable = new Object(); @@ -111,7 +131,7 @@ }); -// Renderer +// Renderer (converts XML controls to XHTML) if (!window.Renderer) { var Renderer = new Object(); } Object.extend(Renderer, { @@ -123,18 +143,19 @@ var items = node.getElementsByTagName('item'); var actions = new Object(); for (var i=0;i<items.length;i++) { - var item = document.createElement('a'); var data = items[i]; var action = data.getAttribute('action'); + actions[action] = { + handler: data.getAttribute('handler') || function() {}, + visible: data.getAttribute('visible') || '', + choices: data.getAttribute('choices') || '' + }; + 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); - actions[action] = {}; - actions[action]['handler'] = data.getAttribute('handler') || function() {}; - actions[action]['visible'] = data.getAttribute('visible') || ''; - actions[action]['choices'] = data.getAttribute('choices') || ''; } var area = node.getAttribute('area'); node.parentNode.replaceChild(menu, node); @@ -157,21 +178,6 @@ }); -// Controller -CPSSkins.Controller = Class.create(); -CPSSkins.Controller.prototype = { - - initialize: function(id) { - this.id = id; - controllers.push(this); - }, - - add: function(items) { - // TODO - } - -} - // Contextual menu CPSSkins.ContextualMenu = Class.create(); CPSSkins.ContextualMenu.prototype = { @@ -324,8 +330,10 @@ }, setup: function(e) { + var text = Event.element(e).getAttribute(this.options.text); + if (!text) return; this.hint = { - text: Event.element(e).getAttribute(this.options.text) || '', + text: text, x: Event.pointerX(e), y: Event.pointerY(e) } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins