Skip to content
Permalink
Browse files

Tabs: Updated to use new trigger() method.

  • Loading branch information
scottgonzalez committed Jul 14, 2008
1 parent 86f15f8 commit 5750375701b0e15d8010208fad5f912c44adaba9
Showing with 10 additions and 30 deletions.
  1. +10 −30 ui/ui.tabs.js
@@ -134,17 +134,16 @@ $.widget("ui.tabs", {

// seems to be expected behavior that the show callback is fired
var onShow = function() {
$(self.element).triggerHandler('tabsshow',
[self.fakeEvent('tabsshow'), self.ui(self.$tabs[o.selected], self.$panels[o.selected])], o.show);
};
self.trigger('show', null,
self.ui(self.$tabs[o.selected], self.$panels[o.selected]));
};

// load if remote tab
if ($.data(this.$tabs[o.selected], 'load.tabs'))
this.load(o.selected, onShow);
// just trigger show event
else
onShow();

}

// clean up to avoid memory leaks in certain versions of IE 6
@@ -198,9 +197,7 @@ $.widget("ui.tabs", {
$show[0].style.filter = '';

// callback
$(self.element).triggerHandler('tabsshow',
[self.fakeEvent('tabsshow'), self.ui(clicked, $show[0])], o.show);

self.trigger('show', null, self.ui(clicked, $show[0]));
});
}

@@ -229,7 +226,7 @@ $.widget("ui.tabs", {
if (($li.hasClass(o.selectedClass) && !o.unselect)
|| $li.hasClass(o.disabledClass)
|| $(this).hasClass(o.loadingClass)
|| $(self.element).triggerHandler('tabsselect', [self.fakeEvent('tabsselect'), self.ui(this, $show[0])], o.select) === false
|| self.trigger('select', null, self.ui(this, $show[0])) === false
) {
this.blur();
return false;
@@ -354,9 +351,7 @@ $.widget("ui.tabs", {
}

// callback
this.element.triggerHandler('tabsadd',
[this.fakeEvent('tabsadd'), this.ui(this.$tabs[index], this.$panels[index])], o.add
);
this.trigger('add', null, this.ui(this.$tabs[index], this.$panels[index]));
},
remove: function(index) {
var o = this.options, $li = this.$lis.eq(index).remove(),
@@ -373,9 +368,7 @@ $.widget("ui.tabs", {
this.tabify();

// callback
this.element.triggerHandler('tabsremove',
[this.fakeEvent('tabsremove'), this.ui($li.find('a')[0], $panel[0])], o.remove
);
this.trigger('remove', null, this.ui($li.find('a')[0], $panel[0]));
},
enable: function(index) {
var o = this.options;
@@ -393,10 +386,7 @@ $.widget("ui.tabs", {
o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });

// callback
this.element.triggerHandler('tabsenable',
[this.fakeEvent('tabsenable'), this.ui(this.$tabs[index], this.$panels[index])], o.enable
);

this.trigger('enable', null, this.ui(this.$tabs[index], this.$panels[index]));
},
disable: function(index) {
var self = this, o = this.options;
@@ -407,9 +397,7 @@ $.widget("ui.tabs", {
o.disabled.sort();

// callback
this.element.triggerHandler('tabsdisable',
[this.fakeEvent('tabsdisable'), this.ui(this.$tabs[index], this.$panels[index])], o.disable
);
this.trigger('disable', null, this.ui(this.$tabs[index], this.$panels[index]));
}
},
select: function(index) {
@@ -461,9 +449,7 @@ $.widget("ui.tabs", {
$.data(a, 'cache.tabs', true); // if loaded once do not load them again

// callbacks
$(self.element).triggerHandler('tabsload',
[self.fakeEvent('tabsload'), self.ui(self.$tabs[index], self.$panels[index])], o.load
);
self.trigger('load', null, self.ui(self.$tabs[index], self.$panels[index]));
o.ajaxOptions.success && o.ajaxOptions.success(r, s);

// This callback is required because the switch has to take
@@ -506,12 +492,6 @@ $.widget("ui.tabs", {
$(this).removeClass([o.selectedClass, o.unselectClass,
o.disabledClass, o.panelClass, o.hideClass].join(' '));
});
},
fakeEvent: function(type) {
return $.event.fix({
type: type,
target: this.element[0]
});
}
});

0 comments on commit 5750375

Please sign in to comment.
You can’t perform that action at this time.