@@ -69,17 +69,40 @@ define( [ "jquery",
69
69
70
70
ui . screen . bind ( "vclick" , function ( e ) { eatEventAndClose ( e ) ; } ) ;
71
71
72
- $ ( window ) . bind ( "resize" , function ( e ) {
73
- if ( self . _isOpen ) {
74
- self . _resizeScreen ( ) ;
72
+ // St00pid browser, y u no tell me where focus go?
73
+ ui . container . bind ( "focusout focusin" , function ( e ) {
74
+ function maybeClearTimeout ( ) {
75
+ if ( self . _focusTimeout ) {
76
+ clearTimeout ( self . _focusTimeout ) ;
77
+ self . _focusTimeout = 0 ;
78
+ }
75
79
}
76
- } ) ;
77
80
78
- $ ( window ) . bind ( "keyup" , function ( e ) {
79
- if ( self . _isOpen && e . keyCode === $ . mobile . keyCode . ESCAPE ) {
80
- eatEventAndClose ( e ) ;
81
+ if ( self . _isOpen ) {
82
+ if ( e . type === "focusout" ) {
83
+ maybeClearTimeout ( ) ;
84
+ self . _focusTimeout = setTimeout ( function ( ) {
85
+ self . _ui . container . focus ( ) ;
86
+ } , 100 ) ;
87
+ }
88
+ else
89
+ if ( e . type === "focusin" ) {
90
+ maybeClearTimeout ( ) ;
91
+ }
81
92
}
82
93
} ) ;
94
+
95
+ $ ( window )
96
+ . bind ( "resize" , function ( e ) {
97
+ if ( self . _isOpen ) {
98
+ self . _resizeScreen ( ) ;
99
+ }
100
+ } )
101
+ . bind ( "keyup" , function ( e ) {
102
+ if ( self . _isOpen && e . keyCode === $ . mobile . keyCode . ESCAPE ) {
103
+ eatEventAndClose ( e ) ;
104
+ }
105
+ } ) ;
83
106
} ,
84
107
85
108
_resizeScreen : function ( ) {
@@ -290,6 +313,7 @@ define( [ "jquery",
290
313
} ,
291
314
function ( ) {
292
315
self . _isOpen = true ;
316
+ self . _ui . container . attr ( "tabindex" , "0" ) . focus ( ) ;
293
317
self . element . trigger ( "opened" ) ;
294
318
} ) ;
295
319
@@ -338,6 +362,7 @@ define( [ "jquery",
338
362
. removeAttr ( "style" ) ;
339
363
} ,
340
364
function ( ) {
365
+ self . _ui . container . removeAttr ( "tabindex" ) ;
341
366
self . element . trigger ( "closed" ) ;
342
367
} ) ;
343
368
0 commit comments