mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Tabs: Cleaned up _tabId() implementation.
This commit is contained in:
parent
168ab6656d
commit
bc6a28ee03
@ -2,16 +2,22 @@
|
|||||||
|
|
||||||
module("tabs (deprecated): core");
|
module("tabs (deprecated): core");
|
||||||
|
|
||||||
test( "#4581 - title attribute for remote tabs does not support foreign languages", function() {
|
test( "panel ids", function() {
|
||||||
expect( 1 );
|
expect( 2 );
|
||||||
|
|
||||||
$( "#tabs2" ).tabs({
|
var element = $( "#tabs2" ).tabs();
|
||||||
selected: 3,
|
|
||||||
beforeLoad: function( event, ui ) {
|
element.one( "tabsbeforeload", function( event, ui ) {
|
||||||
|
equal( ui.panel.attr( "id" ), "∫ßáö_Սե", "from title attribute" );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
equal( ui.panel.attr( "id" ), "∫ßáö_Սե", "proper title" );
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
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");
|
module("tabs (deprecated): options");
|
||||||
@ -326,14 +332,19 @@ test( "length", function() {
|
|||||||
equals( $( "#tabs2" ).tabs().tabs( "length" ), 4, "ajax tabs with missing panels" );
|
equals( $( "#tabs2" ).tabs().tabs( "length" ), 4, "ajax tabs with missing panels" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test('url', function() {
|
test( "url", function() {
|
||||||
el = $('#tabs2').tabs();
|
expect( 2 );
|
||||||
var tab = el.find('a:eq(3)'),
|
|
||||||
url = tab.attr('href');
|
|
||||||
|
|
||||||
el.tabs('url', 3, "data/test2.html");
|
var element = $( "#tabs2" ).tabs(),
|
||||||
equals(tab.attr('href'), 'data/test2.html', 'Url was updated');
|
tab = element.find( "a" ).eq( 3 );
|
||||||
tab.attr('href', url );
|
|
||||||
|
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 ) );
|
}( jQuery ) );
|
||||||
|
9
ui/jquery.ui.tabs.js
vendored
9
ui/jquery.ui.tabs.js
vendored
@ -128,8 +128,7 @@ $.widget( "ui.tabs", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_tabId: function( a ) {
|
_tabId: function( a ) {
|
||||||
return ( $( a ).attr( "aria-controls" ) || "" ) ||
|
return $( a ).attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
|
||||||
"ui-tabs-" + getNextTabId();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_sanitizeSelector: function( hash ) {
|
_sanitizeSelector: function( hash ) {
|
||||||
@ -860,7 +859,7 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
};
|
};
|
||||||
}( jQuery, jQuery.ui.tabs.prototype ) );
|
}( jQuery, jQuery.ui.tabs.prototype ) );
|
||||||
|
|
||||||
// _tabId method
|
// panel ids (idPrefix option + title attribute)
|
||||||
(function( $, prototype ) {
|
(function( $, prototype ) {
|
||||||
$.extend( prototype.options, {
|
$.extend( prototype.options, {
|
||||||
idPrefix: "ui-tabs-"
|
idPrefix: "ui-tabs-"
|
||||||
@ -868,13 +867,13 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
|
|
||||||
var _tabId = prototype._tabId;
|
var _tabId = prototype._tabId;
|
||||||
prototype._tabId = function( a ) {
|
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, "" ) ||
|
a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
|
||||||
this.options.idPrefix + getNextTabId();
|
this.options.idPrefix + getNextTabId();
|
||||||
};
|
};
|
||||||
}( jQuery, jQuery.ui.tabs.prototype ) );
|
}( jQuery, jQuery.ui.tabs.prototype ) );
|
||||||
|
|
||||||
// _tabId method
|
// _createPanel method
|
||||||
(function( $, prototype ) {
|
(function( $, prototype ) {
|
||||||
$.extend( prototype.options, {
|
$.extend( prototype.options, {
|
||||||
panelTemplate: "<div></div>"
|
panelTemplate: "<div></div>"
|
||||||
|
Loading…
Reference in New Issue
Block a user