@@ -129,18 +129,7 @@ $.widget( "ui.tabs", {
129
129
_tabKeydown : function ( event ) {
130
130
var focusedTab = $ ( this . document [ 0 ] . activeElement ) . closest ( "li" ) ,
131
131
selectedIndex = this . lis . index ( focusedTab ) ,
132
- goingForward = true ,
133
- lastTabIndex = this . anchors . length - 1 ;
134
-
135
- function normalizeIndex ( index ) {
136
- if ( index > lastTabIndex ) {
137
- index = 0 ;
138
- }
139
- if ( index < 0 ) {
140
- index = lastTabIndex ;
141
- }
142
- return index ;
143
- }
132
+ goingForward = true ;
144
133
145
134
switch ( event . keyCode ) {
146
135
case $ . ui . keyCode . RIGHT :
@@ -153,7 +142,7 @@ $.widget( "ui.tabs", {
153
142
selectedIndex -- ;
154
143
break ;
155
144
case $ . ui . keyCode . END :
156
- selectedIndex = lastTabIndex ;
145
+ selectedIndex = this . anchors . length - 1 ;
157
146
break ;
158
147
case $ . ui . keyCode . HOME :
159
148
selectedIndex = 0 ;
@@ -176,14 +165,8 @@ $.widget( "ui.tabs", {
176
165
}
177
166
178
167
event . preventDefault ( ) ;
179
-
180
- while ( $ . inArray ( selectedIndex , this . options . disabled ) !== - 1 ) {
181
- selectedIndex = goingForward ? selectedIndex + 1 : selectedIndex - 1 ;
182
- selectedIndex = normalizeIndex ( selectedIndex ) ;
183
- }
184
-
185
- this . lis . eq ( selectedIndex ) . focus ( ) ;
186
168
clearTimeout ( this . activating ) ;
169
+ selectedIndex = this . _focusNextTab ( selectedIndex , goingForward ) ;
187
170
188
171
// Navigating with control key will prevent automatic activation
189
172
if ( ! event . ctrlKey ) {
@@ -194,10 +177,37 @@ $.widget( "ui.tabs", {
194
177
} ,
195
178
196
179
_panelKeydown : function ( event ) {
197
- if ( event . keyCode === $ . ui . keyCode . UP && event . ctrlKey ) {
180
+ // ctrl+up moves focus to the current tab
181
+ if ( event . ctrlKey && event . keyCode === $ . ui . keyCode . UP ) {
198
182
event . preventDefault ( ) ;
199
183
this . active . focus ( ) ;
184
+ return ;
185
+ }
186
+
187
+ // alt+page up/down moves focus to the previous/next tab (and activates)
188
+ if ( event . altKey && event . keyCode === $ . ui . keyCode . PAGE_UP ) {
189
+ this . _activate ( this . _focusNextTab ( this . options . active - 1 , false ) ) ;
200
190
}
191
+ if ( event . altKey && event . keyCode === $ . ui . keyCode . PAGE_DOWN ) {
192
+ this . _activate ( this . _focusNextTab ( this . options . active + 1 , true ) ) ;
193
+ }
194
+ } ,
195
+
196
+ _focusNextTab : function ( index , goingForward ) {
197
+ var lastTabIndex = this . anchors . length - 1 ;
198
+
199
+ while ( $ . inArray ( index , this . options . disabled ) !== - 1 ) {
200
+ index = goingForward ? index + 1 : index - 1 ;
201
+ if ( index > lastTabIndex ) {
202
+ index = 0 ;
203
+ }
204
+ if ( index < 0 ) {
205
+ index = lastTabIndex ;
206
+ }
207
+ }
208
+
209
+ this . lis . eq ( index ) . focus ( ) ;
210
+ return index ;
201
211
} ,
202
212
203
213
_setOption : function ( key , value ) {
0 commit comments