Author: jmorliaguet
Date: Tue Jan  3 02:05:52 2006
New Revision: 2125

Added:
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html
   (contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.html 
  (contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.html 
  (contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.html 
  (contents, props changed)
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.html 
  (contents, props changed)
Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- saving work: added panels (equivalent of client-side perspectives)



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 Tue Jan  3 
02:05:52 2006
@@ -17,32 +17,47 @@
 */
 
 var CPSSkins = {
-  Version: "0.1",
+  Version: "0.2",
+
+  Controllers: $H({}),
+
+  Perspectives: $H({}),
 
   init: function() {
     var elements = document.getElementsByTagName("*");
-    for (var i=0;i<elements.length;i++) {
-      var element = elements[i];
-      var tag = element.tagName;
-      if (!tag.match(/^cpsskins:/i)) continue;
-      switch (tag.toLowerCase()) {
+    $A(elements).findAll(function(e) {
+      return e.tagName.match(/^cpsskins:/i)
+    }).each(function(e) {
+      switch (e.tagName.toLowerCase()) {
         case "cpsskins:contextmenu": {
-          Renderers.contextmenu(element);
+          Renderers.contextmenu(e);
           break;
         }
         case "cpsskins:tooltip": {
-          Renderers.tooltip(element);
+          Renderers.tooltip(e);
+          break;
+        }
+        case "cpsskins:panel": {
+          var perspective = e.getAttribute("perspective") || "default";
+          if (!(perspective in CPSSkins.Perspectives)) {
+            CPSSkins.Perspectives[perspective] = $A([]);
+          }
+          CPSSkins.Perspectives[perspective].push(Renderers.panel(e));
           break;
         }
       }
-    }
+    });
+  },
+
+  getHandlers: function(controller) {
+    return this.Controllers[controller].handlers;
   }
+
 }
 
 Event.observe(window, "load", CPSSkins.init);
 
 // Controller
-var controllers = new Object();
 
 CPSSkins.Controller = Class.create();
 CPSSkins.Controller.prototype = {
@@ -50,7 +65,7 @@
   initialize: function(id) {
     this.id = id;
     this.handlers = {};
-    controllers[id] = this;
+    CPSSkins.Controllers[id] = this;
   },
 
   register: function(handlers) {
@@ -59,6 +74,7 @@
 
 }
 
+
 // Identifiable DOM elements.
 if (!window.Identifiable) var Identifiable = new Object();
 Object.extend(Identifiable, {
@@ -291,10 +307,38 @@
       style: {position:"absolute", display:"none"}
     });
     new CPSSkins.Tooltip(widget, view);
+  },
+
+  panel: function(view) {
+    var widget = Canvas.addNode(view.parentNode, {tag: "div"});
+    new CPSSkins.Panel(widget, view);
   }
 
 });
 
+// Panel
+CPSSkins.Panel = Class.create();
+CPSSkins.Panel.prototype = {
+
+  initialize: function(widget, view) {
+    this.widget = widget;
+    this.view = view;
+
+    this.update();
+  },
+
+  update: function() {
+    var url = this.view.getAttribute("url");
+    if (url) {
+      new Ajax.Updater(this.widget, url);
+    }
+  },
+
+  show: function() {
+    Element.show(widget);
+  }
+}
+
 // Contextual menu
 CPSSkins.ContextualMenu = Class.create();
 CPSSkins.ContextualMenu.prototype = {
@@ -307,9 +351,7 @@
     this.active = false;
 
     var controller = view.getAttribute("controller");
-    if (controller) {
-      this.handlers = controllers[controller].handlers;
-    }
+    this.handlers = CPSSkins.getHandlers(controller);
 
     this.showEvent = this.showEvent.bindAsEventListener(this);
     this.hideEvent = this.hideEvent.bindAsEventListener(this);

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_panel_test.html
   Tue Jan  3 02:05:52 2006
@@ -0,0 +1,59 @@
+<?xml version="1.0" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xml:lang="en" lang="en"
+      xmlns="http://www.w3.org/1999/xhtml";
+      xmlns:cpsskins=http://namespaces.zope.org/cpsskins";>
+<head>
+  <title>CPSSkins Unit test file</title>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+  <script src="../../prototype.js" type="text/javascript"></script>
+  <script src="../../json.js" type="text/javascript"></script>
+  <script src="../../cpsskins.js" type="text/javascript"></script>
+  <link rel="stylesheet" href="../../cpsskins.css" type="text/css" />
+
+  <style type="text/css">
+    .panel {
+      padding: 1em;
+      margin: 2px;
+      border: 1px solid #999;
+    }
+  </style>
+</head>
+
+<body>
+
+  <h1>CPSSkins panels</h1>
+
+  <table style="width:100%">
+    <tr style="vertical-align: top">
+      <td colspan="2">
+
+        <cpsskins:panel perspective="page-designer" url="panel1.html">
+        </cpsskins:panel>
+
+      </td>
+    </tr>
+
+    <tr style="vertical-align: top">
+      <td>
+
+        <cpsskins:panel perspective="page-designer" url="panel2.html">
+        </cpsskins:panel>
+
+        <cpsskins:panel perspective="layout-designer" url="panel3.html">
+        </cpsskins:panel>
+
+      </td>
+      <td>
+
+        <cpsskins:panel perspective="page-designer" url="panel4.html">
+        </cpsskins:panel>
+
+      </td>
+    </tr>
+  </table>
+
+</body>
+
+</html>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.html
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel1.html    
    Tue Jan  3 02:05:52 2006
@@ -0,0 +1,7 @@
+<div class="panel" style="background-color: #dec">
+
+  <h2>Panel 1</h2>
+
+  <p>This is panel 1</p>
+
+</div>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.html
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel2.html    
    Tue Jan  3 02:05:52 2006
@@ -0,0 +1,7 @@
+<div class="panel" style="background-color: #efc">
+
+  <h2>Panel 2</h2>
+
+  <p>This is panel 2</p>
+
+</div>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.html
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel3.html    
    Tue Jan  3 02:05:52 2006
@@ -0,0 +1,7 @@
+<div class="panel" style="background-color: #ffc">
+
+  <h2>Panel 3</h2>
+
+  <p>This is panel 3</p>
+
+</div>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.html
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel4.html    
    Tue Jan  3 02:05:52 2006
@@ -0,0 +1,7 @@
+<div class="panel" style="background-color: #eff">
+
+  <h2>Panel 4</h2>
+
+  <p>This is panel 4</p>
+
+</div>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to