]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: Rename select event to beforeActivate. Fixes #7136 Tabs: Rename select event...
authorDavid Petersen <public@petersendidit.com>
Sun, 27 Mar 2011 21:02:58 +0000 (17:02 -0400)
committerDavid Petersen <public@petersendidit.com>
Sun, 27 Mar 2011 21:02:58 +0000 (17:02 -0400)
tests/unit/tabs/tabs_defaults.js
tests/unit/tabs/tabs_defaults_deprecated.js
tests/unit/tabs/tabs_deprecated.js
tests/unit/tabs/tabs_events.js
ui/jquery.ui.tabs.js

index e155a3dac5b7ba01d6b21120fd9da7e45fa13cea..194d2b76c1c7995bc184cc66f0822bcebac94884 100644 (file)
@@ -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
index 47fd75d8f1b1b9b14e3248e8e1f1c569f11a641b..03ee13d3d517b41a9c48e1bc36842a1f590de743 100644 (file)
@@ -7,6 +7,7 @@ var tabs_defaults = {
        add: null,
        ajaxOptions: null,
        beforeload: null,
+       beforeActivate: null,
        cache: false,
        collapsible: false,
        cookie: null,
index ba1a778b09af3a8ca1b6b7736357de443b132bb6..38fa6db71083a854e5ef117f45eb79e8d7a2ca55 100644 (file)
@@ -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() {
index 60affd7ff49fb98ebbd5cfb552fb4b4aeba1257c..4fedde84239819d12219b23969d452a717c05c09 100644 (file)
@@ -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() {
index d605b2d48d2a46093e7eb50c2ce10cb0d645bca6..8508f0adb15b6e02a2078240efa93e9d4ddf2c12 100755 (executable)
@@ -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 );
                        }
                };