]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: Trigger the select event when collapsing. Fixes #8813 - Tabs: select event...
authorScott González <scott.gonzalez@gmail.com>
Wed, 14 Nov 2012 19:59:12 +0000 (14:59 -0500)
committerScott González <scott.gonzalez@gmail.com>
Wed, 14 Nov 2012 19:59:12 +0000 (14:59 -0500)
tests/unit/tabs/tabs_deprecated.js
ui/jquery.ui.tabs.js

index 297a4546e0825067989b48b97be82de49d38377a..36ad98f380d422f5f33c01b5f25baa1192399c29 100644 (file)
@@ -359,7 +359,7 @@ test( "show", function() {
 });
 
 test( "select", function() {
-       expect( 13 );
+       expect( 18 );
 
        var element = $( "#tabs1" ).tabs({
                        active: false,
@@ -391,8 +391,12 @@ test( "select", function() {
        state( element, 0, 1, 0 );
 
        // collapsing
-       element.one( "tabsselect", function() {
-               ok( false, "collapsing" );
+       element.one( "tabsselect", function( event, ui ) {
+               ok( !( "originalEvent" in event ), "originalEvent" );
+               strictEqual( ui.tab, anchors[ 1 ], "ui.tab" );
+               strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
+               equal( ui.index, 1, "ui.index" );
+               state( element, 0, 1, 0 );
        });
        element.tabs( "option", "active", false );
        state( element, 0, 0, 0 );
index 9b97f9cdaf1e5b39387c18467ab3f4733e946223..8e09764b793a151b3e6afecc3199e4e46e12037a 100644 (file)
@@ -1187,15 +1187,20 @@ if ( $.uiBackCompat !== false ) {
                        }
                },
                _trigger: function( type, event, data ) {
-                       var ret = this._superApply( arguments );
+                       var tab, panel,
+                               ret = this._superApply( arguments );
+
                        if ( !ret ) {
                                return false;
                        }
-                       if ( type === "beforeActivate" && data.newTab.length ) {
+
+                       if ( type === "beforeActivate" ) {
+                               tab = data.newTab.length ? data.newTab : data.oldTab;
+                               panel = data.newPanel.length ? data.newPanel : data.oldPanel;
                                ret = this._super( "select", event, {
-                                       tab: data.newTab.find( ".ui-tabs-anchor" )[ 0],
-                                       panel: data.newPanel[ 0 ],
-                                       index: data.newTab.closest( "li" ).index()
+                                       tab: tab.find( ".ui-tabs-anchor" )[ 0],
+                                       panel: panel[ 0 ],
+                                       index: tab.closest( "li" ).index()
                                });
                        } else if ( type === "activate" && data.newTab.length ) {
                                ret = this._super( "show", event, {