Author: jmorliaguet Date: Mon Feb 13 22:42:08 2006 New Revision: 2379 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.css (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.css (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.css (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.css (contents, props changed) Removed: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/style1.css Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel6.html Log:
- test updates for the panel widget - fixed the activation / deactivation of on-demand resources 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 Feb 13 22:42:08 2006 @@ -548,7 +548,12 @@ }); -if (!window.Canvas) { var Canvas = new Object(); } +if (!window.Canvas) { + var Canvas = new Object(); + Canvas.Styles = $({}); + Canvas.Script = $({}); +} + Object.extend(Canvas, { getModel: function(node) { @@ -624,29 +629,50 @@ }, addStyleSheet: function(id, src) { + if (id in Canvas.Styles) { + return; + } var head = document.getElementsByTagName("head")[0]; var link = document.createElement("link"); - link.id = id; + link.id = "cpsskins-style-" + id; link.rel = "stylesheet"; link.href = src; link.type = "text/css"; head.appendChild(link); + Canvas.Styles[id] = src; }, removeStyleSheet: function(id) { - var style = document.getElementById(id); + if (id in Canvas.Styles) { + delete Canvas.Styles[id]; + } + var style = document.getElementById("cpsskins-style-" + id); if (style) { style.parentNode.removeChild(style); } }, addScript: function(id, src) { + if (id in Canvas.Scripts) { + return; + } var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); - script.id = id; + script.id = "cpsskins-script-" + id; script.href = src; script.type = "text/javascript"; head.appendChild(script); + Canvas.Scripts[id] = src; + }, + + removeScript: function(id) { + if (id in Canvas.Scripts) { + delete Canvas.Scripts[src]; + } + var script = document.getElementById("cpsskins-script-" + id); + if (script) { + script.parentNode.removeChild(script); + } } }); @@ -1097,24 +1123,28 @@ }, update: function() { - // getData() causes the view to get rendered. - this.getData(); + var data = this.getData(); + if (data) this.render(data); }, show: function() { if (this.visible) return; - this.prepare(); if (!this.def.model) { var model = Canvas.getModel(this.selected); if (model) { this.observe(model); + } else { + return; } } // get new data this.update(); + // prepare the view + this.prepare(); + if (this.effect) { this.effect.stop(); } @@ -1131,7 +1161,9 @@ }, hide: function() { - if (!this.visible) return; + if (!this.visible) { + return; + } var widget = this.widget; if (this.effect && !this.effect.started) { @@ -1148,6 +1180,7 @@ this.visible = false; this.stopObserving(); + // tear down the view; this.teardown(); }, @@ -1226,7 +1259,7 @@ new Ajax.Request(url, options); CPSSkins.registerEventHandler(evt_id, view, function(event) { - view.update(); + view.getData(); }); CPSSkins.subscribe(evt_id, {'subscriber': view, 'target': null}); @@ -1270,13 +1303,13 @@ var url = data.url; var script = data.script; if (script) { - this.script_id = this.id; + this.script_id = this.def.name; Canvas.addScript(this.script_id, script); } var css = data.css; if (css) { - this.css_id = "cpsskins-panel-css" + this.id; + this.css_id = this.def.model; Canvas.addStyleSheet(this.css_id, css); } @@ -1298,13 +1331,15 @@ }, prepare: function() { - this.update(); }, teardown: function() { if (this.css_id) { Canvas.removeStyleSheet(this.css_id); } + if (this.script_id) { + Canvas.removeScript(this.script_id); + } } }); @@ -1564,6 +1599,9 @@ Object.extend(CPSSkins.ContextualActions.prototype, { prepare: function() { + var selected = this.selected; + if (!selected) return; + var widget = this.widget; Canvas.moveTo(widget, this.mouseX -50, this.mouseY); Canvas.fitInsideScreen(widget); Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html Mon Feb 13 22:42:08 2006 @@ -44,7 +44,7 @@ {"id": "panel1", "data": { "url": "panel1.html", - "css": "style1.css" + "css": "panel1.css" }, "storage": { "type": "ram" @@ -55,7 +55,7 @@ {"id": "panel2", "data": { "url": "panel2.html", - "css": "style2.css" + "css": "panel2.css" }, "storage": { "type": "ram" @@ -66,7 +66,7 @@ {"id": "panel3", "data": { "url": "panel3.html", - "css": "style3.css" + "css": "panel3.css" }, "storage": { "type": "ram" @@ -77,7 +77,7 @@ {"id": "panel4", "data": { "url": "panel4.html", - "css": "style4.css" + "css": "panel4.css" }, "storage": { "type": "ram" Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.css ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.css Mon Feb 13 22:42:08 2006 @@ -0,0 +1,14 @@ + +.panel1 { + background-color: #fec; + padding: 0.5em; + color: red; + margin: 0.5em; + border: 2px solid red; +} + +.panel1 h2 { + color: #000; + font: 20px Arial, sans-serif; +} + Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.html Mon Feb 13 22:42:08 2006 @@ -1,7 +1,7 @@ -<div class="panel" style="background-color: #dec"> +<div class="panel1"> <h2>Panel 1</h2> - <p>This is panel 1</p> + <p>This is red</p> </div> Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.css ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.css Mon Feb 13 22:42:08 2006 @@ -0,0 +1,13 @@ + +.panel2 { + background-color: #eff; + padding: 1em; + color: #00c; + margin: 0.5em; +} + +.panel2 h2 { + color: #009; + font: 17px Arial, sans-serif; +} + Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.html Mon Feb 13 22:42:08 2006 @@ -1,7 +1,7 @@ -<div class="panel" style="background-color: #efc"> +<div class="panel2"> <h2>Panel 2</h2> - <p>This is panel 2</p> + <p>This is blue</p> </div> Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.css ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.css Mon Feb 13 22:42:08 2006 @@ -0,0 +1,14 @@ + +.panel3 { + background-color: #ffc; + border: 1px solid #090; + padding: 0.5em; + color: green; + margin: 1em; +} + +.panel3 h2 { + color: #090; + font: bold 15px Arial, sans-serif; +} + Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.html Mon Feb 13 22:42:08 2006 @@ -1,7 +1,7 @@ -<div class="panel" style="background-color: #ffc"> +<div class="panel3"> <h2>Panel 3</h2> - <p>This is panel 3</p> + <p>This is green</p> </div> Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.css ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.css Mon Feb 13 22:42:08 2006 @@ -0,0 +1,14 @@ + +.panel4 { + background-color: #fef; + padding: 1em; + border: 1px solid #ccc; + color: #909; +} + +.panel4 h2 { + color: #609; + border-bottom: 1px solid #666; + font: bold 16px Verdana, Arial, sans-serif; +} + Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.html Mon Feb 13 22:42:08 2006 @@ -1,7 +1,7 @@ -<div class="panel" style="background-color: #eff"> +<div class="panel4"> <h2>Panel 4</h2> - <p>This is panel 4</p> + <p>This is violet</p> </div> Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html Mon Feb 13 22:42:08 2006 @@ -1,4 +1,4 @@ -<div class="popup" style="background-color:#efc; z-index:2"> +<div class="popup"> <h2>Panel 5</h2> @@ -22,9 +22,9 @@ <td> <ins class="view"> {"widget": { - "type": "panel", - "url": "panel1.html" + "type": "panel" }, + "model": "panel1", "show_effect": { "transition": "fadein" }, @@ -35,9 +35,9 @@ <td> <ins class="view"> {"widget": { - "type": "panel", - "url": "panel2.html" + "type": "panel" }, + "model": "panel2", "show_effect": { "transition": "fadein" }, @@ -48,9 +48,9 @@ <td> <ins class="view"> {"widget": { - "type": "panel", - "url": "panel3.html" + "type": "panel" }, + "model": "panel3", "show_effect": { "transition": "fadein" }, @@ -61,9 +61,9 @@ <td> <ins class="view"> {"widget": { - "type": "panel", - "url": "panel4.html" + "type": "panel" }, + "model": "panel4", "show_effect": { "transition": "fadein" }, @@ -74,9 +74,9 @@ <td> <ins class="view"> {"widget": { - "type": "panel", - "url": "panel6.html" + "type": "panel" }, + "model": "panel5", "show_effect": { "transition": "fadein" }, Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel6.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel6.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel6.html Mon Feb 13 22:42:08 2006 @@ -1,4 +1,4 @@ -<div class="popup" style="background-color:#fd0; z-index:3"> +<div class="popup"> <h2>Panel 6</h2> -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins