Skip to content
Permalink
Browse files

Tabs: Rename select event to beforeActivate. Fixes #7136 Tabs: Rename…

… select event to beforeActivate
  • Loading branch information...
petersendidit committed Mar 27, 2011
1 parent 787efd3 commit 8b0c3618bdebddd98d4c09e77d14c50c4f4d3190
@@ -5,13 +5,13 @@
var tabs_defaults = {
activate: null,
beforeload: null,
beforeActivate: null,
collapsible: false,
cookie: null,
disabled: false,
event: "click",
fx: null,
load: null,
select: null
load: null
};

// FAIL: falsy values break the cookie option
@@ -7,6 +7,7 @@ var tabs_defaults = {
add: null,
ajaxOptions: null,
beforeload: null,
beforeActivate: null,
cache: false,
collapsible: false,
cookie: null,
@@ -188,6 +188,27 @@ test('show', function() {

});

test('select', function() {
expect(7);

var eventObj;
el = $('#tabs1').tabs({
select: function(event, ui) {
ok(true, 'select triggered after initialization');
equals(this, el[0], "context of callback");
equals(event.type, 'tabsselect', 'event type in callback');
equals(ui.tab, el.find('a')[1], 'contain tab as DOM anchor element');
equals(ui.panel, el.find('div')[1], 'contain panel as DOM div element');
equals(ui.index, 1, 'contain index');
evenObj = event;
}
});
el.tabs('select', 1);

el.find( "li:eq(1) a" ).simulate( "click" );
equals( evenObj.originalEvent.type, "click", "select triggered by click" );
});

module("tabs (deprecated): methods");

test('add', function() {
@@ -5,15 +5,15 @@

module("tabs: events");

test('select', function() {
test('beforeActivate', function() {
expect(7);

var eventObj;
el = $('#tabs1').tabs({
select: function(event, ui) {
ok(true, 'select triggered after initialization');
beforeActivate: function(event, ui) {
ok(true, 'beforeActivate triggered after initialization');
equals(this, el[0], "context of callback");
equals(event.type, 'tabsselect', 'event type in callback');
equals(event.type, 'tabsbeforeactivate', 'event type in callback');
equals(ui.tab, el.find('a')[1], 'contain tab as DOM anchor element');
equals(ui.panel, el.find('div')[1], 'contain panel as DOM div element');
equals(ui.index, 1, 'contain index');
@@ -23,7 +23,7 @@ test('select', function() {
el.tabs('select', 1);

el.find( "li:eq(1) a" ).simulate( "click" );
equals( evenObj.originalEvent.type, "click", "select triggered by click" );
equals( evenObj.originalEvent.type, "click", "beforeActivate triggered by click" );
});

test('beforeload', function() {
@@ -28,13 +28,13 @@ $.widget( "ui.tabs", {
options: {
activate: null,
beforeload: null,
beforeActivate: null,
cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
collapsible: false,
disabled: false,
event: "click",
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
load: null,
select: null
load: null
},

_create: function() {
@@ -363,8 +363,8 @@ $.widget( "ui.tabs", {
$li.hasClass( "ui-state-disabled" ) ||
// tab is already loading
$li.hasClass( "ui-state-processing" ) ||
// allow canceling by select event
self._trigger( "select", event, self._ui( el, $show[ 0 ] ) ) === false ) {
// allow canceling by beforeActivate event
self._trigger( "beforeActivate", event, self._ui( el, $show[ 0 ] ) ) === false ) {
el.blur();
return;
}
@@ -927,10 +927,11 @@ if ( $.uiBackCompat !== false ) {
};
}( jQuery, jQuery.ui.tabs.prototype ) );

// show event
// show and select event
(function( $, prototype ) {
$.extend( prototype.options, {
show: null
show: null,
select: null
});
var _trigger = prototype._trigger;

@@ -939,7 +940,9 @@ if ( $.uiBackCompat !== false ) {
if ( !ret ) {
return false;
}
if ( type === "activate" ) {
if ( type === "beforeActivate" ) {
ret = _trigger.call( this, "select", event, data );
} else if ( type === "activate" ) {
ret = _trigger.call( this, "show", event, data );
}
};

0 comments on commit 8b0c361

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