@@ -32,12 +32,9 @@ $.widget( "ui.tabs", {
32
32
disabled : false ,
33
33
event : "click" ,
34
34
fx : null , // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
35
- idPrefix : "ui-tabs-" ,
36
35
load : null ,
37
- panelTemplate : "<div></div>" ,
38
36
select : null ,
39
- show : null ,
40
- tabTemplate : "<li><a href='#{href}'><span>#{label}</span></a></li>"
37
+ show : null
41
38
} ,
42
39
43
40
_create : function ( ) {
@@ -135,7 +132,7 @@ $.widget( "ui.tabs", {
135
132
136
133
_tabId : function ( a ) {
137
134
return ( $ ( a ) . attr ( "aria-controls" ) || "" ) . replace ( / ^ # / , "" ) ||
138
- this . options . idPrefix + getNextTabId ( ) ;
135
+ "ui-tabs-" + getNextTabId ( ) ;
139
136
} ,
140
137
141
138
_sanitizeSelector : function ( hash ) {
@@ -253,11 +250,8 @@ $.widget( "ui.tabs", {
253
250
selector = "#" + id ;
254
251
panel = self . element . find ( selector ) ;
255
252
if ( ! panel . length ) {
256
- panel = $ ( self . options . panelTemplate )
257
- . attr ( "id" , id )
258
- . addClass ( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
259
- . data ( "destroy.tabs" , true )
260
- . insertAfter ( self . panels [ i - 1 ] || self . list ) ;
253
+ panel = self . _createPanel ( id ) ;
254
+ panel . insertAfter ( self . panels [ i - 1 ] || self . list ) ;
261
255
}
262
256
// invalid tab href
263
257
} else {
@@ -271,6 +265,13 @@ $.widget( "ui.tabs", {
271
265
} ) ;
272
266
} ,
273
267
268
+ _createPanel : function ( id ) {
269
+ return $ ( "<div></div>" )
270
+ . attr ( "id" , id )
271
+ . addClass ( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
272
+ . data ( "destroy.tabs" , true ) ;
273
+ } ,
274
+
274
275
_setupFx : function ( fx ) {
275
276
// set up animations
276
277
if ( fx ) {
@@ -772,7 +773,8 @@ if ( $.uiBackCompat !== false ) {
772
773
( function ( $ , prototype ) {
773
774
$ . extend ( prototype . options , {
774
775
add : null ,
775
- remove : null
776
+ remove : null ,
777
+ tabTemplate : "<li><a href='#{href}'><span>#{label}</span></a></li>"
776
778
} ) ;
777
779
778
780
prototype . add = function ( url , label , index ) {
@@ -790,9 +792,7 @@ if ( $.uiBackCompat !== false ) {
790
792
// try to find an existing element before creating a new one
791
793
var $panel = self . element . find ( "#" + id ) ;
792
794
if ( ! $panel . length ) {
793
- $panel = $ ( o . panelTemplate )
794
- . attr ( "id" , id )
795
- . data ( "destroy.tabs" , true ) ;
795
+ $panel = self . _createPanel ( id ) ;
796
796
}
797
797
$panel . addClass ( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" ) ;
798
798
@@ -868,10 +868,30 @@ if ( $.uiBackCompat !== false ) {
868
868
869
869
// _tabId method
870
870
( function ( $ , prototype ) {
871
+ $ . extend ( prototype . options , {
872
+ idPrefix : "ui-tabs-"
873
+ } ) ;
874
+
871
875
var _tabId = prototype . _tabId ;
872
876
prototype . _tabId = function ( a ) {
873
- return a . title && a . title . replace ( / \s / g, "_" ) . replace ( / [ ^ \w \u00c0 - \uFFFF - ] / g, "" ) ||
874
- _tabId . apply ( this , arguments ) ;
877
+ return ( $ ( a ) . attr ( "aria-controls" ) || "" ) . replace ( / ^ # / , "" ) ||
878
+ a . title && a . title . replace ( / \s / g, "_" ) . replace ( / [ ^ \w \u00c0 - \uFFFF - ] / g, "" ) ||
879
+ this . options . idPrefix + getNextTabId ( ) ;
880
+ } ;
881
+ } ( jQuery , jQuery . ui . tabs . prototype ) ) ;
882
+
883
+ // _tabId method
884
+ ( function ( $ , prototype ) {
885
+ $ . extend ( prototype . options , {
886
+ panelTemplate : "<div></div>"
887
+ } ) ;
888
+
889
+ var _createPanel = prototype . _createPanel ;
890
+ prototype . _createPanel = function ( id ) {
891
+ return $ ( this . options . panelTemplate )
892
+ . attr ( "id" , id )
893
+ . addClass ( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
894
+ . data ( "destroy.tabs" , true ) ;
875
895
} ;
876
896
} ( jQuery , jQuery . ui . tabs . prototype ) ) ;
877
897
}
0 commit comments