aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-04-05 21:39:02 -0400
committerScott González <scott.gonzalez@gmail.com>2011-04-05 21:39:02 -0400
commitbc6a28ee03ed2eb391ec839a05ced94a84debefe (patch)
treefb5f696d1eed14996fa1d756ac04dfd816e19f55
parent168ab6656d71e6c21ffef7f058b5afa2893007a6 (diff)
downloadjquery-ui-bc6a28ee03ed2eb391ec839a05ced94a84debefe.tar.gz
jquery-ui-bc6a28ee03ed2eb391ec839a05ced94a84debefe.zip
Tabs: Cleaned up _tabId() implementation.
-rw-r--r--tests/unit/tabs/tabs_deprecated.js43
-rwxr-xr-xui/jquery.ui.tabs.js9
2 files changed, 31 insertions, 21 deletions
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js
index 77bf645a6..c6549fd50 100644
--- a/tests/unit/tabs/tabs_deprecated.js
+++ b/tests/unit/tabs/tabs_deprecated.js
@@ -2,16 +2,22 @@
module("tabs (deprecated): core");
-test( "#4581 - title attribute for remote tabs does not support foreign languages", function() {
- expect( 1 );
-
- $( "#tabs2" ).tabs({
- selected: 3,
- beforeLoad: function( event, ui ) {
- event.preventDefault();
- equal( ui.panel.attr( "id" ), "∫ßáö_Սե", "proper title" );
- }
+test( "panel ids", function() {
+ expect( 2 );
+
+ var element = $( "#tabs2" ).tabs();
+
+ element.one( "tabsbeforeload", function( event, ui ) {
+ equal( ui.panel.attr( "id" ), "∫ßáö_Սե", "from title attribute" );
+ event.preventDefault();
+ });
+ element.tabs( "option", "active", 3 );
+
+ element.one( "tabsbeforeload", function( event, ui ) {
+ ok( /^ui-tabs-\d+$/.test( ui.panel.attr( "id" ) ), "generated id" );
+ event.preventDefault();
});
+ element.tabs( "option", "active", 2 );
});
module("tabs (deprecated): options");
@@ -326,14 +332,19 @@ test( "length", function() {
equals( $( "#tabs2" ).tabs().tabs( "length" ), 4, "ajax tabs with missing panels" );
});
-test('url', function() {
- el = $('#tabs2').tabs();
- var tab = el.find('a:eq(3)'),
- url = tab.attr('href');
+test( "url", function() {
+ expect( 2 );
- el.tabs('url', 3, "data/test2.html");
- equals(tab.attr('href'), 'data/test2.html', 'Url was updated');
- tab.attr('href', url );
+ var element = $( "#tabs2" ).tabs(),
+ tab = element.find( "a" ).eq( 3 );
+
+ element.tabs( "url", 3, "data/test2.html" );
+ equals( tab.attr( "href" ), "data/test2.html", "href was updated" );
+ element.one( "tabsbeforeload", function( event, ui ) {
+ equals( ui.ajaxSettings.url, "data/test2.html", "ajaxSettings.url" );
+ event.preventDefault();
+ });
+ element.tabs( "option", "active", 3 );
});
}( jQuery ) );
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index c16fe94c0..646854f49 100755
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -128,8 +128,7 @@ $.widget( "ui.tabs", {
},
_tabId: function( a ) {
- return ( $( a ).attr( "aria-controls" ) || "" ) ||
- "ui-tabs-" + getNextTabId();
+ return $( a ).attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
},
_sanitizeSelector: function( hash ) {
@@ -860,7 +859,7 @@ if ( $.uiBackCompat !== false ) {
};
}( jQuery, jQuery.ui.tabs.prototype ) );
- // _tabId method
+ // panel ids (idPrefix option + title attribute)
(function( $, prototype ) {
$.extend( prototype.options, {
idPrefix: "ui-tabs-"
@@ -868,13 +867,13 @@ if ( $.uiBackCompat !== false ) {
var _tabId = prototype._tabId;
prototype._tabId = function( a ) {
- return ( $( a ).attr( "aria-controls" ) || "" ) ||
+ return $( a ).attr( "aria-controls" ) ||
a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
this.options.idPrefix + getNextTabId();
};
}( jQuery, jQuery.ui.tabs.prototype ) );
- // _tabId method
+ // _createPanel method
(function( $, prototype ) {
$.extend( prototype.options, {
panelTemplate: "<div></div>"