Author: jmorliaguet
Date: Wed Jan  4 23:48:35 2006
New Revision: 2139

Added:
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/style1.css  
 (contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/style2.css  
 (contents, props changed)
Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html
Log:

- added support for one stylesheet per panel



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 Wed Jan  4 
23:48:35 2006
@@ -23,8 +23,11 @@
 
   Perspectives: $H({}),
 
+  Panels: [],
+
   init: function() {
     var elements = document.getElementsByTagName("*");
+    var id = 0;
     $A(elements).findAll(function(e) {
       return e.tagName.match(/^cpsskins:/i)
     }).each(function(e) {
@@ -38,9 +41,11 @@
           break;
         }
         case "cpsskins:panel": {
+          panel_id += 1;
           var perspectives = (e.getAttribute("perspectives")
                               || "default").split(",");
           var panel = new Renderers.panel(e);
+          panel.id = 'cpsskins-panel' + id;
           $A(perspectives).each(function(p) {
             if (!(p in CPSSkins.Perspectives)) {
               CPSSkins.Perspectives[p] = $A([]);
@@ -272,6 +277,23 @@
       left = parseInt(left);
       if (left + width > page_w) { element.style.left = left - width + "px"};
     }
+  },
+
+  addStyleSheet: function(id, src) {
+    var head = document.getElementsByTagName("head")[0];
+    var link = document.createElement("link");
+    link.id = id;
+    link.rel = "stylesheet";
+    link.href = src;
+    link.type = "text/css";
+    head.appendChild(link);
+  },
+
+  removeStyleSheet: function(id) {
+    var style = document.getElementById(id);
+    if (style) {
+      style.parentNode.removeChild(style);
+    }
   }
 
 });
@@ -347,7 +369,8 @@
 
 });
 
-// Panel
+// Panels
+
 CPSSkins.Panel = Class.create();
 CPSSkins.Panel.prototype = {
 
@@ -359,6 +382,7 @@
     this.fadein = this.view.getAttribute("fadein") || false;
     this.url = this.view.getAttribute("url");
     this.rendered = false;
+    this.css_id = null;
   },
 
   inspect: function() {
@@ -384,6 +408,11 @@
     if (this.visible) return;
     if (!this.rendered) this.update();
 
+    var css = this.view.getAttribute("css");
+    if (css) {
+      this.css_id = this.id;
+      Canvas.addStyleSheet(this.css_id, css);
+    }
     var widget = this.widget;
     if (this.saved) {
       widget.innerHTML = this.saved;
@@ -409,6 +438,10 @@
     this.saved = widget.innerHTML;
     Element.hide(widget);
     this.visible = false;
+
+    if (this.css_id) {
+      Canvas.removeStyleSheet(this.css_id);
+    }
   }
 }
 

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
   Wed Jan  4 23:48:35 2006
@@ -38,11 +38,16 @@
     <tr style="vertical-align: top">
       <td colspan="3">
 
-        <cpsskins:panel perspectives="page-designer,layout-designer"
-                        url="panel1.html">
+        <cpsskins:panel
+            perspectives="page-designer,layout-designer"
+            url="panel1.html"
+            css="style1.css">
         </cpsskins:panel>
 
-        <cpsskins:panel perspectives="site-designer" url="panel2.html">
+        <cpsskins:panel
+            perspectives="site-designer"
+            url="panel2.html"
+            css="style2.css">
         </cpsskins:panel>
 
       </td>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/style1.css
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/style1.css 
Wed Jan  4 23:48:35 2006
@@ -0,0 +1,6 @@
+
+h2 {
+  color: #009;
+  border-bottom: 1px solid #666;
+  font: Arial, sans-serif;
+}

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/style2.css
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/style2.css 
Wed Jan  4 23:48:35 2006
@@ -0,0 +1,7 @@
+
+h2 {
+  color: #630;
+  border-left: 4px solid #666;
+  padding-left: 0.5em;
+  border-color: #fc0;
+}
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to