File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1040,4 +1040,28 @@ test( "redefine", function() {
1040
1040
equal ( $ . ui . testWidget . foo , "bar" , "static properties remain" ) ;
1041
1041
} ) ;
1042
1042
1043
+ asyncTest ( "_delay" , function ( ) {
1044
+ expect ( 4 ) ;
1045
+ var order = 0 ,
1046
+ that ;
1047
+ $ . widget ( "ui.testWidget" , {
1048
+ defaultElement : null ,
1049
+ _create : function ( ) {
1050
+ that = this ;
1051
+ this . _delay ( function ( ) {
1052
+ strictEqual ( this , that ) ;
1053
+ equal ( order , 1 ) ;
1054
+ start ( ) ;
1055
+ } , 500 ) ;
1056
+ this . _delay ( "callback" ) ;
1057
+ } ,
1058
+ callback : function ( ) {
1059
+ strictEqual ( this , that ) ;
1060
+ equal ( order , 0 ) ;
1061
+ order += 1 ;
1062
+ }
1063
+ } ) ;
1064
+ $ ( "#widget" ) . testWidget ( ) ;
1065
+ } ) ;
1066
+
1043
1067
} ( jQuery ) ) ;
Original file line number Diff line number Diff line change @@ -333,6 +333,15 @@ $.Widget.prototype = {
333
333
} ) ;
334
334
} ,
335
335
336
+ _delay : function ( handler , delay ) {
337
+ function handlerProxy ( ) {
338
+ return ( typeof handler === "string" ? instance [ handler ] : handler )
339
+ . apply ( instance , arguments ) ;
340
+ }
341
+ var instance = this ;
342
+ setTimeout ( handlerProxy , delay || 0 ) ;
343
+ } ,
344
+
336
345
_hoverable : function ( element ) {
337
346
this . hoverable = this . hoverable . add ( element ) ;
338
347
this . _bind ( element , {
You can’t perform that action at this time.
0 commit comments