]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: cleanup.
authorScott González <scott.gonzalez@gmail.com>
Mon, 4 Apr 2011 21:06:13 +0000 (17:06 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 4 Apr 2011 21:06:13 +0000 (17:06 -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
tests/unit/tabs/tabs_tickets.js
ui/jquery.ui.tabs.js

index 0f33cc28ce957b12e7f78b1dc63aafadfd6ee76e..d64316f9fdb84d8571421f6f0339eec4d26836b4 100644 (file)
@@ -1,17 +1,13 @@
-/*
- * tabs_defaults.js
- */
-
-var tabs_defaults = {
-       activate: null,
-       beforeload: null,
-       beforeActivate: null,
-       collapsible: false,
-       disabled: false,
-       event: "click",
-       fx: null,
-       load: null
-};
-
-// FAIL: falsy values break the cookie option
-commonWidgetTests( "tabs", { defaults: tabs_defaults } );
+commonWidgetTests( "tabs", {
+       defaults: {
+               activate: null,
+//             active: null,
+               beforeLoad: null,
+               beforeActivate: null,
+               collapsible: false,
+               disabled: false,
+               event: "click",
+               fx: null,
+               load: null
+       }
+});
index 03ee13d3d517b41a9c48e1bc36842a1f590de743..c496e72f5f0d8a335cf2db890d0469bbe2062246 100644 (file)
@@ -1,30 +1,26 @@
-/*
- * tabs_defaults.js
- */
-
-var tabs_defaults = {
-       activate: null,
-       add: null,
-       ajaxOptions: null,
-       beforeload: null,
-       beforeActivate: null,
-       cache: false,
-       collapsible: false,
-       cookie: null,
-       disable: null,
-       disabled: false,
-       enable: null,
-       event: "click",
-       fx: null,
-       idPrefix: "ui-tabs-",
-       load: null,
-       panelTemplate: "<div></div>",
-       remove: null,
-       select: null,
-       show: null,
-       spinner: "<em>Loading&#8230;</em>",
-       tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
-};
-
-// FAIL: falsy values break the cookie option
-commonWidgetTests( "tabs", { defaults: tabs_defaults } );
+commonWidgetTests( "tabs", {
+       defaults: {
+               activate: null,
+//             active: null,
+               add: null,
+               ajaxOptions: null,
+               beforeLoad: null,
+               beforeActivate: null,
+               cache: false,
+               collapsible: false,
+               cookie: null,
+               disable: null,
+               disabled: false,
+               enable: null,
+               event: "click",
+               fx: null,
+               idPrefix: "ui-tabs-",
+               load: null,
+               panelTemplate: "<div></div>",
+               remove: null,
+               select: null,
+               show: null,
+               spinner: "<em>Loading&#8230;</em>",
+               tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
+       }
+});
index b784c724e9ac943eac91fe7ba3e213cc1e2b4629..c4a27026d69ed94f44b019d95ff9cb8cbd75668e 100644 (file)
@@ -7,7 +7,7 @@ test( "#4581 - title attribute for remote tabs does not support foreign language
 
        $( "#tabs2" ).tabs({
                selected: 3,
-               beforeload: function( event, ui ) {
+               beforeLoad: function( event, ui ) {
                        event.preventDefault();
                        equal( ui.panel.id, "∫ßáö_Սե", "proper title" );
                }
index c578e5db784bede1db7208836f3759821e4c35ba..9c9fe0cd90a76115077ae3fe732e89828fe32efa 100644 (file)
@@ -139,14 +139,14 @@ test( "activate", function() {
        element.tabs( "option", "active", 1 );
 });
 
-test('beforeload', function() {
+test( "beforeLoad", function() {
        expect( 5 );
 
-       el = $('#tabs2');
+       el = $( "#tabs2" );
 
        el.tabs({
                active: 2,
-               beforeload: function( event, ui ) {
+               beforeLoad: function( event, ui ) {
                        ok( $.isFunction( ui.jqXHR.promise ), 'contain jqXHR object');
                        equals( ui.settings.url, "data/test.html", 'contain ajax settings url');
                        equals( ui.tab, el.find('a')[ 2 ], 'contain tab as DOM anchor element');
@@ -155,7 +155,6 @@ test('beforeload', function() {
                        event.preventDefault();
                }
        });
-
 });
 
 test('load', function() {
index 36ddd6e84d3db79380117658cfdbf22957844580..503f96260af2e81e03b2a056d5af839c90bebfce 100644 (file)
@@ -44,7 +44,7 @@ test('#3627 - Ajax tab with url containing a fragment identifier fails to load',
 
        el = $('#tabs2').tabs({
                active: 2,
-               beforeload: function( event, ui ) {
+               beforeLoad: function( event, ui ) {
                        event.preventDefault();
                        ok(/test.html$/.test( ui.settings.url ), 'should ignore fragment identifier');
                }
@@ -58,7 +58,7 @@ test('#4033 - IE expands hash to full url and misinterprets tab as ajax', functi
        el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>');
        el.appendTo('#main');
        el.tabs({
-               beforeload: function( event, ui ) {
+               beforeLoad: function( event, ui ) {
                        event.preventDefault();
                        ok( false, 'should not be an ajax tab');
                }
index 7544d0302f25cea2424d9a2ecf6961331f0c2ad2..b350f309e716926452de0f550646e667c9aa928d 100755 (executable)
@@ -27,10 +27,11 @@ function getNextListId() {
 $.widget( "ui.tabs", {
        options: {
                activate: null,
-               beforeload: null,
+               // TODO: uncomment (requires fixing code related to active option)
+//             active: null,
+               beforeLoad: null,
                beforeActivate: null,
                collapsible: false,
-               disabled: false,
                event: "click",
                fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
                load: null
@@ -118,13 +119,13 @@ $.widget( "ui.tabs", {
 
        _setOption: function( key, value ) {
                if ( key == "active" ) {
-                       // _activate() will handle invalid values and update this.option
+                       // _activate() will handle invalid values and update this.options
                        this._activate( value );
-                       return
-               } else {
-                       this.options[ key ] = value;
-                       this.refresh();
+                       return;
                }
+
+               this.options[ key ] = value;
+               this.refresh();
        },
 
        _tabId: function( a ) {
@@ -573,8 +574,9 @@ $.widget( "ui.tabs", {
                this.xhr = $.ajax({
                        url: url,
                        beforeSend: function( jqXHR, settings ) {
-                               return self._trigger( "beforeload", null,
-                                               $.extend( { jqXHR: jqXHR, settings: settings }, eventData ) );
+                               // TODO: pass relevant event
+                               return self._trigger( "beforeLoad", null,
+                                       $.extend( { jqXHR : jqXHR, settings: settings }, eventData ) );
                        }
                });
 
@@ -609,8 +611,12 @@ $.widget( "ui.tabs", {
                self.element.dequeue( "tabs" );
 
                return this;
-       }
+       },
 
+       _getPanelForTab: function( tab ) {
+               var id = $( tab ).attr( "aria-controls" );
+               return this.element.find( this._sanitizeSelector( "#" + id ) );
+       }
 });
 
 $.extend( $.ui.tabs, {
@@ -619,7 +625,6 @@ $.extend( $.ui.tabs, {
 
 // DEPRECATED
 if ( $.uiBackCompat !== false ) {
-
        // ajaxOptions and cache options
        (function( $, prototype ) {
                $.extend( prototype.options, {