Revision: 2428
          http://vexi.svn.sourceforge.net/vexi/?rev=2428&view=rev
Author:   clrg
Date:     2007-10-11 15:08:09 -0700 (Thu, 11 Oct 2007)

Log Message:
-----------
Allow show=null with cardpanes and reset stepping history on null put

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/vexi/layout/cardpane.t

Modified: trunk/widgets/org.vexi.widgets/src/vexi/layout/cardpane.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/vexi/layout/cardpane.t   2007-10-11 
13:38:41 UTC (rev 2427)
+++ trunk/widgets/org.vexi.widgets/src/vexi/layout/cardpane.t   2007-10-11 
22:08:09 UTC (rev 2428)
@@ -28,8 +28,7 @@
         
         var showlock = false;
         
-        var displayFunc = function(v)
-        {
+        var displayFunc = function(v) {
             if (showlock) { cascade = v; return; }
             cascade = false;
             if (prevstep) show = prevstep;
@@ -39,13 +38,11 @@
         }
         
         /** card management */
-        th_content ++= function(v)
-        {
-            // childadded write trap
-            v.Children ++= function(c)
-            {
-                if (c != null)
-                {
+        th_content ++= function(v) {
+            cascade = v;
+            
+            v.Children ++= function(c) {
+                if (c != null) {
                     cascade = c;
                     // show c if it is the first card
                     if (v.numchildren > 1) c.display = false;
@@ -56,8 +53,7 @@
                 
                 c = thisbox[arguments.trapname];
                 // if c is the shown card, attempt to show another
-                if (show == c)
-                {
+                if (show == c) {
                     if (nextcard) nextcard = true;
                     else if (prevcard) prevcard = true;
                 }
@@ -72,8 +68,6 @@
                 c.display --= displayFunc;
                 cascade = null;
             }
-            
-            cascade = v;
         }
         
         /** write trap to show a card by box or index */
@@ -81,20 +75,31 @@
         {
             var card;
             
-            if (typeof(v) == "number")
-            {
+            // display nothing and reset stepping
+            if (v == null) {
+                showlock = true;
+                if (show) show.display = false;
+                showlock = false;
+                stepmarker = 0;
+                stepping = false;
+                steps = [];
+                cascade = v;
+                return;
+            }
+            
+            // validate show by index
+            if (typeof(v) == "number") {
                 if (v >= th_content.numchildren)
                     throw "Invalid card index put to cardpane.show: "+v;
                 card = th_content[v];
-            }
-            else if (typeof(v) == "box")
-            {
+            // validate show by card
+            } else if (typeof(v) == "box") {
                 if (0 > th_content.indexof(v))
                     throw "Invalid card object put to cardpane.show: "+v;
                 card = v;
-            }
-            else throw "Put a value other than a box or box index to 
cardpane.show";
+            } else throw "Put a value other than a box or box index to 
cardpane.show";
             
+            // nothing to do
             if (card == show) return;
             
             // hide the previously shown card and show the new one
@@ -104,8 +109,7 @@
             showlock = false;
             
             // remember where we are
-            if (remembersteps and !stepping)
-            {
+            if (remembersteps and !stepping) {
                 stepmarker ++;
                 if (stepmarker != steps.length) steps.splice(stepmarker, 
steps.length - stepmarker);
                 if (stepmarker > 100) steps.splice(0);
@@ -129,16 +133,14 @@
     </ui:box>
     
     /** write trap to show the next card in the cardpane */
-    static.ncWriteFunc = function(v)
-    {
+    static.ncWriteFunc = function(v) {
         if (trapee.nextcard)
             trapee.show = trapee.nextcard;
         cascade = v;
     }
     
     /** read trap to fetch the next card in the cardpane */
-    static.ncReadFunc = function()
-    {
+    static.ncReadFunc = function() {
         var ind = trapee.th_content.indexof(trapee.show);
         if (trapee.show and trapee.th_content.numchildren-1 > ind)
             return trapee.th_content[ind+1];
@@ -146,8 +148,7 @@
     }
     
     /** write trap to step forward to the next in the show-chain */
-    static.nsWriteFunc = function(v)
-    {
+    static.nsWriteFunc = function(v) {
         trapee.stepping = true;
         if (trapee.nextstep) trapee.show = trapee.nextstep;
         trapee.stepping = false;
@@ -155,32 +156,28 @@
     }
     
     /** read trap to fetch the next step in the show-chain */
-    static.nsReadFunc = function()
-    {
+    static.nsReadFunc = function() {
         if (trapee.remembersteps and trapee.steps.length-1 > trapee.stepmarker)
             return trapee.steps[trapee.stepmarker+1];
         else return false;
     }
     
     /** write trap to show the previous card in the cardpane */
-    static.pcWriteFunc = function(v)
-    {
+    static.pcWriteFunc = function(v) {
         cascade = v;
         if (trapee.prevcard)
             trapee.show = trapee.prevcard;
     }
     
     /** read trap to fetch the previous card in the cardpane */
-    static.pcReadFunc = function()
-    {
+    static.pcReadFunc = function() {
         var ind = trapee.th_content.indexof(trapee.show);
         if (trapee.show and ind > 0) return trapee.th_content[ind-1];
         else return false;
     }
     
     /** write trap to step back to the previous in the show-chain */
-    static.psWriteFunc = function(v)
-    {
+    static.psWriteFunc = function(v) {
         trapee.stepping = true;
         if (trapee.prevstep) trapee.show = trapee.prevstep;
         trapee.stepping = false;
@@ -188,8 +185,7 @@
     }
     
     /** read trap to fetch the previous step in the show-chain */
-    static.psReadFunc = function()
-    {
+    static.psReadFunc = function() {
         if (trapee.remembersteps and trapee.stepmarker > 0)
             return trapee.steps[trapee.stepmarker - 1];
         else return false;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to