Author: jmorliaguet Date: Sat Jan 7 15:24:30 2006 New Revision: 2180 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log:
- Panels and ContextualMenus subclass View - contextual menus register an observer for the context 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 Sat Jan 7 15:24:30 2006 @@ -509,24 +509,23 @@ // Panels CPSSkins.Panel = Class.create(); -CPSSkins.Panel.prototype = { +CPSSkins.Panel.prototype = Object.extend(new CPSSkins.View(), { - initialize: function(widget, tag) { - this.widget = widget; - this.tag = tag; + setup: function() { this.visible = false; this.fadein = this.tag.getAttribute("fadein") || false; this.url = this.tag.getAttribute("url"); this.css_id = null; this.script_id = null; - this.render(); + + this.update(); }, inspect: function() { return '[CPSSkins Panel:' + this.url + ']'; }, - render: function() { + render: function(data) { var script = this.tag.getAttribute("script"); if (script) { this.script_id = this.id; @@ -582,23 +581,21 @@ Canvas.removeStyleSheet(this.css_id); } } -} +}); // Contextual menu CPSSkins.ContextualMenu = Class.create(); -CPSSkins.ContextualMenu.prototype = { - - initialize: function(widget, tag) { - this.widget = widget; - this.tag = tag; - this.area = tag.parentNode || document; +CPSSkins.ContextualMenu.prototype = Object.extend(new CPSSkins.View(), { + setup: function() { + this.area = this.tag.parentNode || document; this.active = false; this.showEvent = this.showEvent.bindAsEventListener(this); this.hideEvent = this.hideEvent.bindAsEventListener(this); this.callEvent = this.callEvent.bindAsEventListener(this); this.mouseOverEvent = this.mouseOverEvent.bindAsEventListener(this); + Event.observe(this.widget, "mousedown", function(e) {Event.stop(e)}); Event.observe(this.widget, "mouseup", this.callEvent); Event.observe(this.widget, "mouseover", this.mouseOverEvent); @@ -626,6 +623,7 @@ }, hideEvent: function(e) { + CPSSkins.removeObserver(this); this.hide(); var x = Event.pointerX(e); var y = Event.pointerY(e); @@ -680,9 +678,9 @@ show: function(x, y) { var selected = this.selected; if (!selected) return; - var widget = this.widget; - var tag = this.tag; + // Display the menu inside the screen + var widget = this.widget; Canvas.moveTo(widget, x, y); Canvas.fitInsideScreen(widget); @@ -691,7 +689,7 @@ v.parentNode.removeChild(v); }); - this._renderFragment(widget, tag); + CPSSkins.addObserver(selected, this); new CPSSkins.Scheduler(widget, { action: function(value) { @@ -704,8 +702,12 @@ }, - _renderFragment: function(container, fragment) { + render: function(data) { var data = Canvas.getNodeData(this.selected); + this._renderFragment(this.widget, this.tag, data); + }, + + _renderFragment: function(container, fragment, data) { var tags = fragment.childNodes; for (var i=0;i<tags.length;i++) { @@ -810,7 +812,7 @@ }); item.appendChild(submenu); - this._renderFragment(submenu, tag); + this._renderFragment(submenu, tag, data); break; }; @@ -820,9 +822,10 @@ hide: function() { Element.hide(this.widget); + CPSSkins.removeObserver(this); } -} +}); // Tooltip CPSSkins.Tooltip = Class.create(); @@ -903,8 +906,6 @@ }.bind(this) }); - CPSSkins.removeObserver(this); - } }); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins