Author: jmorliaguet
Date: Fri Jan  6 00:52:07 2006
New Revision: 2153

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel6.html
   cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
Log:

- added some basic navigation to switch between 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 Fri Jan  6 
00:52:07 2006
@@ -23,6 +23,9 @@
 
   Perspectives: $H({}),
 
+  CurrentPerspective: "",
+  PreviousPerspective: "",
+
   init: function() {
     CPSSkins.parse(document);
   },
@@ -65,6 +68,26 @@
   switchPerspective: function(perspective) {
     var to_show = [];
     var to_hide = [];
+
+    var path = CPSSkins.CurrentPerspective.split("/");
+    if (perspective == '..') {
+      if (path.length > 0) {
+        perspective = path.slice(0, path.length-1).join("/");
+      }
+    }
+
+    if (perspective.substr(0,2) == "./") {
+      var base = CPSSkins.CurrentPerspective;
+      if (base) {
+        base += "/";
+      }
+      perspective = base + perspective.substr(2);
+    }
+
+    if (perspective == '-') {
+      perspective = CPSSkins.PreviousPerspective;
+    }
+
     CPSSkins.Perspectives.each(function(s) {
       var elements = s[1];
       var path = perspective.split("/");
@@ -85,6 +108,9 @@
 
     $A(to_hide).each(function(e) { e.hide() } );
     $A(to_show).each(function(e) { e.show() } );
+
+    CPSSkins.PreviousPerspective = CPSSkins.CurrentPerspective;
+    CPSSkins.CurrentPerspective = perspective;
   }
 
 }

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    
    Fri Jan  6 00:52:07 2006
@@ -5,7 +5,7 @@
   <p>This is panel 5</p>
 
   <a class="button close"
-     href="javascript:CPSSkins.switchPerspective('site-designer')">
+     href="javascript:CPSSkins.switchPerspective('..')">
   Close</a>
 
   <a class="button" 
href="javascript:CPSSkins.switchPerspective('element-editor/1')">

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    
    Fri Jan  6 00:52:07 2006
@@ -5,7 +5,7 @@
   <p>This is panel 6</p>
 
   <a class="close button"
-     href="javascript:CPSSkins.switchPerspective('element-editor')">
+     href="javascript:CPSSkins.switchPerspective('..')">
   Close</a>
 
 </div>

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    Fri Jan  6 00:52:07 2006
@@ -251,6 +251,40 @@
       assert(!isVisible(p1_2));
       assert(!isVisible(p3));
       assert(!isVisible(p4));
+
+      /* Navigating in the perspective path */
+      // Moving up one level
+      assertEqual(CPSSkins.CurrentPerspective, "2/3/1");
+
+      CPSSkins.switchPerspective("..");
+      assertEqual(CPSSkins.CurrentPerspective, "2/3");
+
+      CPSSkins.switchPerspective("..");
+      assertEqual(CPSSkins.CurrentPerspective, "2");
+
+      CPSSkins.switchPerspective("..");
+      assertEqual(CPSSkins.CurrentPerspective, "");
+
+      // Moving down
+      CPSSkins.switchPerspective("./2");
+      assertEqual(CPSSkins.CurrentPerspective, "2");
+
+      CPSSkins.switchPerspective("./1");
+      assertEqual(CPSSkins.CurrentPerspective, "2/1");
+
+      CPSSkins.switchPerspective("./3");
+      assertEqual(CPSSkins.CurrentPerspective, "2/1/3");
+
+      CPSSkins.switchPerspective("./4/5");
+      assertEqual(CPSSkins.CurrentPerspective, "2/1/3/4/5");
+
+      // Going back the previous perspective in history
+      CPSSkins.switchPerspective("-");
+      assertEqual(CPSSkins.CurrentPerspective, "2/1/3");
+
+      CPSSkins.switchPerspective("-");
+      assertEqual(CPSSkins.CurrentPerspective, "2/1/3/4/5");
+
     }}
 
   });
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to