fix attribute
[roojs1] / examples / bootstrap / dashboard3.slidetest.js
index 1c0733e..c85c7b6 100644 (file)
@@ -1,12 +1,29 @@
 
 
-dashboard3.slidetest = function (tba,tbb, dir)
+dashboard3.slidetest = function (tbb)
 {
-    this.tba = tba;
+    
+    
+    this.tba =  Roo.bootstrap.NavGroup.get(tbb.navId).getActive();
     this.tbb = tbb;
+    if (!this.tba) {
+        alert("could not get active tab");
+        return;
+    }
+    if (this.tba.tabId == this.tbb.tabId) {
+        return; // same tab...
+    }
+    
+    
     this.el = tba.el;
     this.nel = tbb.el;
-    this.dir = dir;
+    
+    // we can work out the direction based on the sequence..
+    this.pel = this.el.findParent('.tab-content', 3, true);
+    var cn = this.pel.select('.tab-pane',true);
+    this.dir = cn.indexOf(this.nel) -  cn.indexOf(this.el);
+    
+    
     this.slide();
 }
 Roo.apply(dashboard3.slidetest.prototype, {
@@ -20,7 +37,7 @@ Roo.apply(dashboard3.slidetest.prototype, {
         
         // first tabcontent - needs overflow hidden..
         
-        this.pel = this.el.findParent('.tab-content', 3, true);
+        
         this.pel.setStyle('overflow', 'hidden');
         var obox = this.pel.getBox(true,true);
         
@@ -43,6 +60,7 @@ Roo.apply(dashboard3.slidetest.prototype, {
         var start = this.dir > 0 ? (box.width + obox.x + 50 ) : (-1 * (box.width + 50)) + obox.x;
         
         var end = this.dir > 0 ? -1 * (box.width + 50 ) : (box.width + obox.x + 50 );
+        
         this.nel.setStyle({
             position: 'absolute',
             left : start + 'px',
@@ -64,7 +82,7 @@ Roo.apply(dashboard3.slidetest.prototype, {
         this.el.animate({
             left : {
                 from : obox.x , 
-                to : -1 * (box.width + 50 )
+                to : end 
             }
         }, 0.5, false, 'easeOut', 'run');
         
@@ -73,10 +91,11 @@ Roo.apply(dashboard3.slidetest.prototype, {
     },
     completeSlide : function()
     {
+        // remove styles + classes.. that we have added..
+        this.nel.removeClass('active');
+        this.pel.setStyle('overflow', '');
           
-          this.el.removeClass('active');
-          
-          this.pel.setStyle('overflow', '');
+        // reset the styles
           this.nel.setStyle({
             position: '',
             left : '',
@@ -93,8 +112,10 @@ Roo.apply(dashboard3.slidetest.prototype, {
             top : '',
             width :'',
             height: ''
-          });  
-            
+        });
+        // apply the data..
+        this.tba.setActive(false);
+        this.tbb.setActive(true);
         
     }