@@ -47,9 +47,7 @@ $.widget( "ui.tabs", {
47
47
48
48
_create : function ( ) {
49
49
var that = this ,
50
- options = this . options ,
51
- active = options . active ,
52
- locationHash = location . hash . substring ( 1 ) ;
50
+ options = this . options ;
53
51
54
52
this . running = false ;
55
53
@@ -75,6 +73,36 @@ $.widget( "ui.tabs", {
75
73
} ) ;
76
74
77
75
this . _processTabs ( ) ;
76
+ options . active = this . _initialActive ( ) ;
77
+
78
+ // Take disabling tabs via class attribute from HTML
79
+ // into account and update option properly.
80
+ if ( $ . isArray ( options . disabled ) ) {
81
+ options . disabled = $ . unique ( options . disabled . concat (
82
+ $ . map ( this . tabs . filter ( ".ui-state-disabled" ) , function ( li ) {
83
+ return that . tabs . index ( li ) ;
84
+ } )
85
+ ) ) . sort ( ) ;
86
+ }
87
+
88
+ // check for length avoids error when initializing empty list
89
+ if ( this . options . active !== false && this . anchors . length ) {
90
+ this . active = this . _findActive ( options . active ) ;
91
+ } else {
92
+ this . active = $ ( ) ;
93
+ }
94
+
95
+ this . _refresh ( ) ;
96
+
97
+ if ( this . active . length ) {
98
+ this . load ( options . active ) ;
99
+ }
100
+ } ,
101
+
102
+ _initialActive : function ( ) {
103
+ var active = this . options . active ,
104
+ collapsible = this . options . collapsible ,
105
+ locationHash = location . hash . substring ( 1 ) ;
78
106
79
107
if ( active === null ) {
80
108
// check the fragment identifier in the URL
@@ -102,38 +130,16 @@ $.widget( "ui.tabs", {
102
130
if ( active !== false ) {
103
131
active = this . tabs . index ( this . tabs . eq ( active ) ) ;
104
132
if ( active === - 1 ) {
105
- active = options . collapsible ? false : 0 ;
133
+ active = collapsible ? false : 0 ;
106
134
}
107
135
}
108
- options . active = active ;
109
136
110
137
// don't allow collapsible: false and active: false
111
- if ( ! options . collapsible && options . active === false && this . anchors . length ) {
112
- options . active = 0 ;
113
- }
114
-
115
- // Take disabling tabs via class attribute from HTML
116
- // into account and update option properly.
117
- if ( $ . isArray ( options . disabled ) ) {
118
- options . disabled = $ . unique ( options . disabled . concat (
119
- $ . map ( this . tabs . filter ( ".ui-state-disabled" ) , function ( li ) {
120
- return that . tabs . index ( li ) ;
121
- } )
122
- ) ) . sort ( ) ;
138
+ if ( ! collapsible && active === false && this . anchors . length ) {
139
+ active = 0 ;
123
140
}
124
141
125
- // check for length avoids error when initializing empty list
126
- if ( this . options . active !== false && this . anchors . length ) {
127
- this . active = this . _findActive ( this . options . active ) ;
128
- } else {
129
- this . active = $ ( ) ;
130
- }
131
-
132
- this . _refresh ( ) ;
133
-
134
- if ( this . active . length ) {
135
- this . load ( options . active ) ;
136
- }
142
+ return active ;
137
143
} ,
138
144
139
145
_getCreateEventData : function ( ) {
@@ -144,6 +150,7 @@ $.widget( "ui.tabs", {
144
150
} ,
145
151
146
152
_tabKeydown : function ( event ) {
153
+ /*jshint maxcomplexity:15*/
147
154
var focusedTab = $ ( this . document [ 0 ] . activeElement ) . closest ( "li" ) ,
148
155
selectedIndex = this . tabs . index ( focusedTab ) ,
149
156
goingForward = true ;
0 commit comments