File tree Expand file tree Collapse file tree 4 files changed +50
-46
lines changed
Expand file tree Collapse file tree 4 files changed +50
-46
lines changed Original file line number Diff line number Diff line change @@ -4,34 +4,6 @@ module( "core - jQuery extensions" );
44
55TestHelpers . testJshint ( "core" ) ;
66
7- asyncTest ( "focus - original functionality" , function ( ) {
8- expect ( 1 ) ;
9- $ ( "#inputTabindex0" )
10- . one ( "focus" , function ( ) {
11- ok ( true , "event triggered" ) ;
12- start ( ) ;
13- } )
14- . focus ( ) ;
15- } ) ;
16-
17- asyncTest ( "focus" , function ( ) {
18- expect ( 2 ) ;
19-
20- // support: IE 8
21- // IE sometimes gets confused about what's focused if we don't explicitly
22- // focus a different element first
23- $ ( "body" ) . focus ( ) ;
24-
25- $ ( "#inputTabindex0" )
26- . one ( "focus" , function ( ) {
27- ok ( true , "event triggered" ) ;
28- start ( ) ;
29- } )
30- . focus ( 500 , function ( ) {
31- ok ( true , "callback triggered" ) ;
32- } ) ;
33- } ) ;
34-
357test ( "innerWidth - getter" , function ( ) {
368 expect ( 2 ) ;
379 var el = $ ( "#dimensions" ) ;
Original file line number Diff line number Diff line change 22
33module ( "core - deprecated" ) ;
44
5+ asyncTest ( "focus - original functionality" , function ( ) {
6+ expect ( 1 ) ;
7+ $ ( "#inputTabindex0" )
8+ . one ( "focus" , function ( ) {
9+ ok ( true , "event triggered" ) ;
10+ start ( ) ;
11+ } )
12+ . focus ( ) ;
13+ } ) ;
14+
15+ asyncTest ( "focus" , function ( ) {
16+ expect ( 2 ) ;
17+
18+ // support: IE 8
19+ // IE sometimes gets confused about what's focused if we don't explicitly
20+ // focus a different element first
21+ $ ( "body" ) . focus ( ) ;
22+
23+ $ ( "#inputTabindex0" )
24+ . one ( "focus" , function ( ) {
25+ ok ( true , "event triggered" ) ;
26+ start ( ) ;
27+ } )
28+ . focus ( 500 , function ( ) {
29+ ok ( true , "callback triggered" ) ;
30+ } ) ;
31+ } ) ;
32+
533test ( "zIndex" , function ( ) {
634 expect ( 7 ) ;
735 var el = $ ( "#zIndexAutoWithParent" ) ,
Original file line number Diff line number Diff line change @@ -48,22 +48,6 @@ $.extend( $.ui, {
4848
4949// plugins
5050$ . fn . extend ( {
51- focus : ( function ( orig ) {
52- return function ( delay , fn ) {
53- return typeof delay === "number" ?
54- this . each ( function ( ) {
55- var elem = this ;
56- setTimeout ( function ( ) {
57- $ ( elem ) . focus ( ) ;
58- if ( fn ) {
59- fn . call ( elem ) ;
60- }
61- } , delay ) ;
62- } ) :
63- orig . apply ( this , arguments ) ;
64- } ;
65- } ) ( $ . fn . focus ) ,
66-
6751 scrollParent : function ( ) {
6852 var position = this . css ( "position" ) ,
6953 excludeStaticParent = position === "absolute" ,
@@ -225,6 +209,22 @@ $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
225209
226210$ . support . selectstart = "onselectstart" in document . createElement ( "div" ) ;
227211$ . fn . extend ( {
212+ focus : ( function ( orig ) {
213+ return function ( delay , fn ) {
214+ return typeof delay === "number" ?
215+ this . each ( function ( ) {
216+ var elem = this ;
217+ setTimeout ( function ( ) {
218+ $ ( elem ) . focus ( ) ;
219+ if ( fn ) {
220+ fn . call ( elem ) ;
221+ }
222+ } , delay ) ;
223+ } ) :
224+ orig . apply ( this , arguments ) ;
225+ } ;
226+ } ) ( $ . fn . focus ) ,
227+
228228 disableSelection : function ( ) {
229229 return this . bind ( ( $ . support . selectstart ? "selectstart" : "mousedown" ) +
230230 ".ui-disableSelection" , function ( event ) {
Original file line number Diff line number Diff line change @@ -342,10 +342,14 @@ return $.widget( "ui.dialog", {
342342 last = tabbables . filter ( ":last" ) ;
343343
344344 if ( ( event . target === last [ 0 ] || event . target === this . uiDialog [ 0 ] ) && ! event . shiftKey ) {
345- first . focus ( 1 ) ;
345+ this . _delay ( function ( ) {
346+ first . focus ( ) ;
347+ } ) ;
346348 event . preventDefault ( ) ;
347349 } else if ( ( event . target === first [ 0 ] || event . target === this . uiDialog [ 0 ] ) && event . shiftKey ) {
348- last . focus ( 1 ) ;
350+ this . _delay ( function ( ) {
351+ first . focus ( ) ;
352+ } ) ;
349353 event . preventDefault ( ) ;
350354 }
351355 } ,
You can’t perform that action at this time.
0 commit comments