Permalink
Browse files

tabset activateTab handles -1 for no selection

  • Loading branch information...
1 parent 994b797 commit b655311cac5a304d66906924c6027e6489402e3f @jcarrig jcarrig committed Jul 13, 2012
Showing with 14 additions and 11 deletions.
  1. +14 −11 src/js/tab_set.js
View
25 src/js/tab_set.js
@@ -68,7 +68,8 @@
activateTab : function(index) {
- $(this.el).removeClass('no_selection');
+ var noSelection = index < 0;
+ $(this.el).toggleClass('no_selection', noSelection);
// hide all content panels
_(this._contents).each(function(content) {
@@ -83,16 +84,18 @@
if(_(this._selectedIndex).exists()) {
$(this.el).removeClass('index_' + this._selectedIndex);
}
- $(this.el).addClass('index_' + index);
- this._selectedIndex = index;
-
- // select the appropriate tab
- $(this._tabs[index]).addClass('selected');
-
- // show the proper contents
- $(this._contents[index]).show();
-
- this._callbacks[index]();
+
+ if(!noSelection){
+ $(this.el).addClass('index_' + index);
+ this._selectedIndex = index;
+ // select the appropriate tab
+ $(this._tabs[index]).addClass('selected');
+ // show the proper contents
+ $(this._contents[index]).show();
+ this._callbacks[index]();
+ }else{
+ this._selectedIndex = null;
+ }
},
// returns the index of the selectedTab

0 comments on commit b655311

Please sign in to comment.