Author: jmorliaguet
Date: Thu Jan  5 16:53:26 2006
New Revision: 2147

Added:
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html 
  (contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/popup.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 a popup window / subperspectives

- panels can pull information from other panels



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 Thu Jan  5 
16:53:26 2006
@@ -24,7 +24,11 @@
   Perspectives: $H({}),
 
   init: function() {
-    var elements = document.getElementsByTagName("*");
+    CPSSkins.parse(document);
+  },
+
+  parse: function(node) {
+    var elements = node.getElementsByTagName("*");
     $A(elements).findAll(function(e) {
       return e.tagName.match(/^cpsskins:/i)
     }).each(function(e, index) {
@@ -62,13 +66,14 @@
     var to_show = [];
     var to_hide = [];
     CPSSkins.Perspectives.each(function(s) {
-      var this_perspective = s[0];
       var elements = s[1];
-      if (perspective == this_perspective) {
-        elements.each(function(el) { to_show.push(el) } );
-      } else {
-        elements.each(function(el) { to_hide.push(el) } );
-      }
+      perspective.split(":").each(function(p)  {
+        if (p.match(s[0]) || s[0] == perspective) {
+          elements.each(function(el) { to_show.push(el) } );
+        } else {
+          elements.each(function(el) { to_hide.push(el) } );
+        }
+      });
     });
 
     // Do not hide objects to be shown
@@ -290,6 +295,15 @@
     if (style) {
       style.parentNode.removeChild(style);
     }
+  },
+
+  addScript: function(id, src) {
+    var head = document.getElementsByTagName("head")[0];
+    var script = document.createElement("script");
+    script.id = id;
+    script.href = src;
+    script.type = "text/javascript";
+    head.appendChild(script);
   }
 
 });
@@ -373,23 +387,32 @@
   initialize: function(widget, view) {
     this.widget = widget;
     this.view = view;
-    this.saved = null;
     this.visible = false;
     this.fadein = this.view.getAttribute("fadein") || false;
     this.url = this.view.getAttribute("url");
-    this.rendered = false;
     this.css_id = null;
+    this.script_id = null;
+    this.init();
   },
 
   inspect: function() {
     return '[CPSSkins Panel:' + this.url + ']';
   },
 
-  update: function() {
+  init: function() {
+    var script = this.view.getAttribute("script");
+    if (script) {
+      this.script_id = this.id;
+      Canvas.addScript(this.script_id, script);
+    }
+
     var url = this.url;
     var options = {
-      onComplete: function() { this.rendered = true }.bind(this)
+      onComplete: function() {
+        CPSSkins.parse(this.widget);
+      }.bind(this)
     };
+
     if (url) {
       var parts = url.split('?');
       if (parts.length == 2) {
@@ -402,17 +425,14 @@
 
   show: function() {
     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;
-    }
     Element.show(widget);
     if (this.fadein) {
       Canvas.setOpacity(widget, 0);
@@ -428,7 +448,6 @@
   hide: function() {
     if (!this.visible) return;
     var widget = this.widget;
-    this.saved = widget.innerHTML;
     Element.hide(widget);
     this.visible = false;
 

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
   Thu Jan  5 16:53:26 2006
@@ -33,6 +33,8 @@
   Page designer</a>
   <a href="javascript:CPSSkins.switchPerspective('layout-designer')">
   Layout designer</a>
+  <a href="javascript:CPSSkins.switchPerspective('element-editor')">
+  Element editor</a>
 
   <table style="width:100%">
     <tr style="vertical-align: top">
@@ -87,6 +89,14 @@
     </tr>
   </table>
 
+  <cpsskins:panel
+      perspectives="element-editor"
+      url="panel5.html"
+      css="popup.css">
+  </cpsskins:panel>
+
+  <div id="message"></div>
+
 </body>
 
 </html>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html    
    Thu Jan  5 16:53:26 2006
@@ -0,0 +1,39 @@
+<div class="popup">
+
+  <h2>Panel 5</h2>
+
+  <p>This is panel 5</p>
+
+  <a class="button"
+     href="javascript:CPSSkins.switchPerspective('site-designer')">
+  Close</a>
+
+  <a href="javascript:CPSSkins.switchPerspective('element-editor:1')">
+  1</a>
+
+  <a href="javascript:CPSSkins.switchPerspective('element-editor:2')">
+  2</a>
+
+  <table style="width: 100%">
+    <tr>
+      <td>
+        <cpsskins:panel perspectives="element-editor:1" url="panel1.html">
+        </cpsskins:panel>
+      </td>
+      <td>
+        <cpsskins:panel perspectives="element-editor:1" url="panel2.html">
+        </cpsskins:panel>
+      </td>
+      <td>
+        <cpsskins:panel perspectives="element-editor:2" url="panel3.html">
+        </cpsskins:panel>
+      </td>
+      <td>
+        <cpsskins:panel perspectives="element-editor:2" url="panel4.html">
+        </cpsskins:panel>
+      </td>
+    </tr>
+  </table>
+  </div>
+
+</div>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/popup.css
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/popup.css  
Thu Jan  5 16:53:26 2006
@@ -0,0 +1,30 @@
+
+.popup {
+  padding: 2em;
+  position: absolute;
+  top: 2em;
+  left: 2em;
+  right: 2em;
+  bottom: 2em;
+  border-top: 1px solid #000;
+  border-left: 1px solid #000;
+  border-right: 2px solid #000;
+  border-bottom: 2px solid #000;
+  background-color: #fff;
+  -moz-border-radius: 10px;
+}
+
+.popup h1 {
+  border-bottom: 1px solid gray;
+}
+
+.popup .button {
+  border: 1px solid gray;
+  padding: 0.3em;
+  background-color: white;
+  position: absolute;
+  bottom: 1em;
+  right: 1em;
+  text-decoration: none;
+  font-size: 14px;
+}
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to