1
1
( function ( $ ) {
2
2
3
3
function present ( value , array , message ) {
4
- QUnit . push ( jQuery . inArray ( value , array ) !== - 1 , value , array , message ) ;
4
+ QUnit . push ( jQuery . inArray ( value , array ) !== - 1 , value , array , message ) ;
5
5
}
6
6
7
7
function notPresent ( value , array , message ) {
8
- QUnit . push ( jQuery . inArray ( value , array ) === - 1 , value , array , message ) ;
8
+ QUnit . push ( jQuery . inArray ( value , array ) === - 1 , value , array , message ) ;
9
9
}
10
10
11
11
// minDuration is used for "short" animate tests where we are only concerned about the final
@@ -75,20 +75,6 @@ test( "removeClass", function() {
75
75
equal ( "" , element [ 0 ] . className ) ;
76
76
} ) ;
77
77
78
-
79
- /* TODO: Disabled - Can't figure out why this is failing in IE 6/7
80
- test( "createWrapper and removeWrapper retain focused elements (#7595)", function() {
81
- expect( 2 );
82
- var test = $( "div.hidden" ).show(),
83
- input = $( "<input type='text'>" ).appendTo( test ).focus();
84
-
85
- $.effects.createWrapper( test );
86
- equal( document.activeElement, input[ 0 ], "Active element is still input after createWrapper" );
87
- $.effects.removeWrapper( test );
88
- equal( document.activeElement, input[ 0 ], "Active element is still input after removeWrapper" );
89
- });
90
- */
91
-
92
78
module ( "effects.core: animateClass" ) ;
93
79
94
80
asyncTest ( "animateClass works with borderStyle" , function ( ) {
@@ -213,6 +199,44 @@ asyncTest( "animateClass: css and class changes during animation are not lost (#
213
199
. height ( 100 ) ;
214
200
} ) ;
215
201
202
+ test ( "createPlaceholder: only created for static or relative elements" , function ( ) {
203
+ expect ( 4 ) ;
204
+
205
+ ok ( $ . effects . createPlaceholder ( $ ( ".relative" ) ) . length , "placeholder created for relative element" ) ;
206
+ ok ( $ . effects . createPlaceholder ( $ ( ".static" ) ) . length , "placeholder created for static element" ) ;
207
+ ok ( ! $ . effects . createPlaceholder ( $ ( ".absolute" ) ) , "placeholder not created for absolute element" ) ;
208
+ ok ( ! $ . effects . createPlaceholder ( $ ( ".fixed" ) ) , "placeholder not created for fixed element" ) ;
209
+ } ) ;
210
+
211
+ test ( "createPlaceholder: preserves layout affecting properties" , function ( ) {
212
+ expect ( 7 ) ;
213
+
214
+ var position = 5 ,
215
+ element = $ ( ".relative" ) . css ( {
216
+ top : position ,
217
+ left : position
218
+ } ) ,
219
+ before = {
220
+ offset : element . offset ( ) ,
221
+ outerWidth : element . outerWidth ( true ) ,
222
+ outerHeight : element . outerHeight ( true ) ,
223
+ "float" : element . css ( "float" ) ,
224
+ position : element . position ( )
225
+ } ,
226
+ placeholder = $ . effects . createPlaceholder ( element ) ;
227
+
228
+ // Placeholders are only placed to preserve the effect on layout. Considering
229
+ // top and left do not change layout, they are not preserved, which makes some
230
+ // of the math simpler in the implementation.
231
+ deepEqual ( before . offset . top - position , placeholder . offset ( ) . top , "offset top preserved" ) ;
232
+ deepEqual ( before . offset . left - position , placeholder . offset ( ) . left , "offset left preserved" ) ;
233
+ deepEqual ( before . position . top - position , placeholder . position ( ) . top , "position top preserved" ) ;
234
+ deepEqual ( before . position . left - position , placeholder . position ( ) . left , "position left preserved" ) ;
235
+
236
+ deepEqual ( before [ "float" ] , placeholder . css ( "float" ) , "float preserved" ) ;
237
+ deepEqual ( before . outerWidth , placeholder . outerWidth ( true ) , "width preserved" ) ;
238
+ deepEqual ( before . outerHeight , placeholder . outerHeight ( true ) , "height preserved" ) ;
239
+ } ) ;
216
240
217
241
$ . each ( $ . effects . effect , function ( effect ) {
218
242
module ( "effects." + effect ) ;
@@ -223,7 +247,7 @@ $.each( $.effects.effect, function( effect ) {
223
247
return ;
224
248
}
225
249
asyncTest ( "show/hide" , function ( ) {
226
- expect ( 8 ) ;
250
+ expect ( 12 ) ;
227
251
var hidden = $ ( "div.hidden" ) ,
228
252
count = 0 ,
229
253
test = 0 ;
@@ -242,14 +266,40 @@ $.each( $.effects.effect, function( effect ) {
242
266
} ;
243
267
}
244
268
245
- hidden . queue ( queueTest ( ) ) . show ( effect , minDuration , queueTest ( function ( ) {
246
- equal ( hidden . css ( "display" ) , "block" , "Hidden is shown after .show(\"" + effect + "\", time)" ) ;
247
- } ) ) . queue ( queueTest ( ) ) . hide ( effect , minDuration , queueTest ( function ( ) {
248
- equal ( hidden . css ( "display" ) , "none" , "Back to hidden after .hide(\"" + effect + "\", time)" ) ;
249
- } ) ) . queue ( queueTest ( function ( ) {
250
- deepEqual ( hidden . queue ( ) , [ "inprogress" ] , "Only the inprogress sentinel remains" ) ;
251
- start ( ) ;
252
- } ) ) ;
269
+ function duringTest ( fn ) {
270
+ return function ( next ) {
271
+ setTimeout ( fn ) ;
272
+ next ( ) ;
273
+ } ;
274
+ }
275
+
276
+ hidden
277
+ . queue ( queueTest ( ) )
278
+ . queue ( duringTest ( function ( ) {
279
+ ok ( hidden . is ( ":animated" ) ,
280
+ "Hidden is seen as animated during .show(\"" + effect + "\", time)" ) ;
281
+ } ) )
282
+ . show ( effect , minDuration , queueTest ( function ( ) {
283
+ equal ( hidden . css ( "display" ) , "block" ,
284
+ "Hidden is shown after .show(\"" + effect + "\", time)" ) ;
285
+ ok ( ! $ ( ".ui-effects-placeholder" ) . length ,
286
+ "No placeholder remains after .show(\"" + effect + "\", time)" ) ;
287
+ } ) )
288
+ . queue ( queueTest ( ) )
289
+ . queue ( duringTest ( function ( ) {
290
+ ok ( hidden . is ( ":animated" ) ,
291
+ "Hidden is seen as animated during .hide(\"" + effect + "\", time)" ) ;
292
+ } ) )
293
+ . hide ( effect , minDuration , queueTest ( function ( ) {
294
+ equal ( hidden . css ( "display" ) , "none" ,
295
+ "Back to hidden after .hide(\"" + effect + "\", time)" ) ;
296
+ ok ( ! $ ( ".ui-effects-placeholder" ) . length ,
297
+ "No placeholder remains after .hide(\"" + effect + "\", time)" ) ;
298
+ } ) )
299
+ . queue ( queueTest ( function ( ) {
300
+ deepEqual ( hidden . queue ( ) , [ "inprogress" ] , "Only the inprogress sentinel remains" ) ;
301
+ start ( ) ;
302
+ } ) ) ;
253
303
} ) ;
254
304
255
305
asyncTest ( "relative width & height - properties are preserved" , function ( ) {
0 commit comments