- $.wiki.switchToTab = function(tab){
- var self = this;
- var $tab = $(tab);
-
- if($tab.length != 1)
- $tab = $(DEFAULT_PERSPECTIVE);
-
- var $old = $tab.closest('.tabs').find('.active');
-
- $old.each(function(){
- $(this).removeClass('active');
- self.perspectives[$(this).attr('id')].onExit();
- $('#' + $(this).attr('data-ui-related')).hide();
- });
-
- /* show new */
- $tab.addClass('active');
- $('#' + $tab.attr('data-ui-related')).show();
-
- console.log($tab);
- console.log($.wiki.perspectives);
-
- $.wiki.perspectives[$tab.attr('id')].onEnter();
- };
+ $.wiki.exitTab = function(tab){
+ var self = this;
+ var $tab = $(tab);
+ if (!('.active', $tab)) return;
+ $('.active', $tab).removeClass('active');
+ self.perspectives[$tab.attr('id')].onExit();
+ $('#' + $tab.attr('data-ui-related')).hide();
+ }
+
+ $.wiki.switchToTab = function(tab){
+ var self = this;
+ var $tab = $(tab);
+
+ if($tab.length != 1)
+ $tab = $(DEFAULT_PERSPECTIVE);
+
+ var $old_a = $tab.closest('.tabs').find('.active');
+
+ $old_a.each(function(){
+ var tab = $(this).parent()
+ $(this).removeClass('active');
+ self.perspectives[tab.attr('id')].onExit();
+ $('#' + tab.attr('data-ui-related')).hide();
+ });
+
+ /* show new */
+ $('a', tab).addClass('active');
+ $('#' + $tab.attr('data-ui-related')).show();
+
+ console.log($tab);
+ console.log($.wiki.perspectives);
+
+ $.wiki.perspectives[$tab.attr('id')].onEnter();
+ };