Roo/bootstrap/TabPanel.js
[roojs1] / Roo / bootstrap / TabPanel.js
index ba9d358..c92294b 100644 (file)
@@ -14,7 +14,6 @@
  * @cfg {String} tabId  unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
  * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
  * @cfg {String} href click to link..
- * @cfg {Boolean} swiping enable swiping on mobile (default true)
  * 
  * 
  * @constructor
@@ -53,14 +52,15 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
     html: false,
     tabId: false,
     navId : false,
-    swiping : true,
     href : '',
     
     getAutoCreate : function(){
-        var cfg = {
+        
+       
+       var cfg = {
             tag: 'div',
             // item is needed for carousel - not sure if it has any effect otherwise
-            cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
+            cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
             html: this.html || ''
         };
         
@@ -72,6 +72,7 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
             cfg.tabId = this.tabId;
         }
         
+       
         
         return cfg;
     },
@@ -95,11 +96,9 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
             }
         }
         
-        if(this.href.length){
-            this.el.on('click', this.onClick, this);
-        }
+        this.el.on('click', this.onClick, this);
         
-        if(Roo.isTouch && this.swiping){
+        if(Roo.isTouch){
             this.el.on("touchstart", this.onTouchStart, this);
             this.el.on("touchmove", this.onTouchMove, this);
             this.el.on("touchend", this.onTouchEnd, this);
@@ -131,6 +130,10 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
     {
         e.preventDefault();
         
+        if(!this.href.length){
+            return;
+        }
+        
         window.location.href = this.href;
     },
     
@@ -138,10 +141,11 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
     startY : 0,
     endX : 0,
     endY : 0,
+    swiping : false,
     
     onTouchStart : function(e)
     {
-        e.preventDefault();
+        this.swiping = false;
         
         this.startX = e.browserEvent.touches[0].clientX;
         this.startY = e.browserEvent.touches[0].clientY;
@@ -149,7 +153,7 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
     
     onTouchMove : function(e)
     {
-        e.preventDefault();
+        this.swiping = true;
         
         this.endX = e.browserEvent.touches[0].clientX;
         this.endY = e.browserEvent.touches[0].clientY;
@@ -157,14 +161,14 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
     
     onTouchEnd : function(e)
     {
-        e.preventDefault();
+        if(!this.swiping){
+            this.onClick(e);
+            return;
+        }
         
         var tabGroup = this.parent();
         
-        Roo.log(this.startX);
-        Roo.log(this.startY);
-        
-        if(this.startX < this.endX){ // swiping right
+        if(this.endX > this.startX){ // swiping right
             tabGroup.showPanelPrev();
             return;
         }
@@ -173,7 +177,6 @@ Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component,  {
             tabGroup.showPanelNext();
             return;
         }
-        
     }