@@ -244,23 +244,15 @@ test( "cancelement, default, switching after initialization", function() {
244
244
TestHelpers . draggable . shouldNotDrag ( element , "cancel: input, input dragged" , input ) ;
245
245
} ) ;
246
246
247
- /*
248
- test( "{ connectToSortable: selector }, default", function() {
249
- expect( 1 );
250
-
251
- ok(false, "missing test - untested code is broken code" );
252
- });
253
- */
254
-
255
247
test ( "connectToSortable, dragging out of a sortable" , function ( ) {
256
- expect ( 3 ) ;
248
+ expect ( 4 ) ;
257
249
258
250
var sortItem , dragHelper ,
259
251
element = $ ( "#draggableSortable" ) . draggable ( {
260
252
scroll : false ,
261
253
connectToSortable : "#sortable"
262
254
} ) ,
263
- sortable = $ ( "#sortable" ) . sortable ( ) ,
255
+ sortable = $ ( "#sortable" ) . sortable ( { revert : 100 } ) ,
264
256
dx = 50 ,
265
257
dy = 50 ,
266
258
offsetBefore = element . offset ( ) ,
@@ -286,6 +278,10 @@ test( "connectToSortable, dragging out of a sortable", function() {
286
278
// HTML IDs are removed when dragging to a Sortable
287
279
equal ( sortItem [ 0 ] , dragHelper [ 0 ] , "both have the same helper" ) ;
288
280
equal ( sortItem . attr ( "id" ) , dragHelper . attr ( "id" ) , "both have the same id" ) ;
281
+
282
+ // http://bugs.jqueryui.com/ticket/9481
283
+ // connectToSortable causes sortable revert to fail on second attempt
284
+ equal ( sortable . sortable ( "option" , "revert" ) , 100 , "sortable revert behavior is preserved" ) ;
289
285
} ) ;
290
286
291
287
element . simulate ( "drag" , {
@@ -294,21 +290,31 @@ test( "connectToSortable, dragging out of a sortable", function() {
294
290
} ) ;
295
291
} ) ;
296
292
297
- test ( "connectToSortable, dragging clone into sortable" , function ( ) {
298
- expect ( 1 ) ;
293
+ asyncTest ( "connectToSortable, dragging clone into sortable" , function ( ) {
294
+ expect ( 3 ) ;
299
295
300
- var element = $ ( "#draggableSortableClone" ) . draggable ( {
296
+ var offsetPlaceholder ,
297
+ element = $ ( "#draggableSortableClone" ) . draggable ( {
301
298
scroll : false ,
302
299
connectToSortable : "#sortable" ,
303
300
helper : "clone"
304
301
} ) ,
305
- sortable = $ ( "#sortable" ) . sortable ( ) ,
302
+ sortable = $ ( "#sortable" ) . sortable ( { revert : 100 } ) ,
306
303
offsetSortable = sortable . offset ( ) ;
307
304
308
305
$ ( sortable ) . one ( "sort" , function ( event , ui ) {
306
+ offsetPlaceholder = ui . placeholder . offset ( ) ;
309
307
// http://bugs.jqueryui.com/ticket/8809
310
308
// Position issue when connected to sortable
311
309
deepEqual ( ui . helper . offset ( ) , offsetSortable , "sortable offset is correct" ) ;
310
+ notDeepEqual ( ui . helper . offset ( ) , offsetPlaceholder , "offset not equal to placeholder" ) ;
311
+ } ) ;
312
+
313
+ $ ( sortable ) . one ( "sortstop" , function ( event , ui ) {
314
+ // http://bugs.jqueryui.com/ticket/9675
315
+ // Animation issue with revert and connectToSortable
316
+ deepEqual ( ui . item . offset ( ) , offsetPlaceholder , "offset eventually equals placeholder" ) ;
317
+ start ( ) ;
312
318
} ) ;
313
319
314
320
element . simulate ( "drag" , {
@@ -318,6 +324,87 @@ test( "connectToSortable, dragging clone into sortable", function() {
318
324
} ) ;
319
325
} ) ;
320
326
327
+ test ( "connectToSortable, dragging multiple elements in and out of sortable" , function ( ) {
328
+ expect ( 1 ) ;
329
+
330
+ var element = $ ( "#draggableSortableClone" ) . draggable ( {
331
+ scroll : false ,
332
+ connectToSortable : "#sortable" ,
333
+ helper : "clone"
334
+ } ) ,
335
+ element2 = $ ( "#draggableSortable" ) . draggable ( {
336
+ scroll : false ,
337
+ connectToSortable : "#sortable"
338
+ } ) ,
339
+ sortable = $ ( "#sortable" ) . sortable ( { revert : false } ) ,
340
+ sortableOffset = sortable . offset ( ) ;
341
+
342
+ // Move element into sortable
343
+ element . simulate ( "drag" , {
344
+ x : sortableOffset . left + 1 ,
345
+ y : sortableOffset . top + 1 ,
346
+ moves : 10
347
+ } ) ;
348
+
349
+ // Move element in sortable out
350
+ element2 . simulate ( "drag" , {
351
+ dx : 200 ,
352
+ dy : 200 ,
353
+ moves : 10
354
+ } ) ;
355
+
356
+ // http://bugs.jqueryui.com/ticket/9675
357
+ // Animation issue with revert and connectToSortable
358
+ sortable . one ( "sortstop" , function ( event , ui ) {
359
+ ok ( ! $ . contains ( document , ui . placeholder [ 0 ] ) , "placeholder was removed" ) ;
360
+ } ) ;
361
+
362
+ // Move the clone of the first element back out
363
+ $ ( "#sortable .sortable2Item" ) . simulate ( "drag" , {
364
+ dx : 200 ,
365
+ dy : 200 ,
366
+ moves : 10
367
+ } ) ;
368
+ } ) ;
369
+
370
+ test ( "connectToSortable, dragging through one sortable to a second" , function ( ) {
371
+ expect ( 2 ) ;
372
+
373
+ var overCount = 0 ,
374
+ element = $ ( "#draggableSortable" ) . draggable ( {
375
+ scroll : false ,
376
+ connectToSortable : ".sortable"
377
+ } ) ,
378
+ delta = 200 ,
379
+ sortable = $ ( "#sortable" ) . sortable ( { revert : false } ) ,
380
+ sortable2 = $ ( "#sortable2" ) . sortable ( { revert : false } ) ,
381
+ sortable2Offset = sortable2 . offset ( ) ,
382
+ dragParams = {
383
+ x : sortable2Offset . left + 25 ,
384
+ y : sortable2Offset . top + sortable . outerHeight ( ) + delta ,
385
+ moves : 10
386
+ } ;
387
+
388
+ $ ( sortable ) . one ( "sortover" , function ( ) {
389
+ overCount ++ ;
390
+ sortable2 . css ( "top" , "+=" + delta ) ;
391
+ } ) ;
392
+
393
+ $ ( sortable2 ) . on ( "sortupdate" , function ( ) {
394
+ ok ( true , "second sortable is updated" ) ;
395
+ } ) ;
396
+
397
+ $ ( sortable2 ) . one ( "sortover" , function ( ) {
398
+ overCount ++ ;
399
+ } ) ;
400
+
401
+ $ ( sortable2 ) . one ( "sortstop" , function ( ) {
402
+ equal ( overCount , 2 , "went over both sortables" ) ;
403
+ } ) ;
404
+
405
+ element . simulate ( "drag" , dragParams ) ;
406
+ } ) ;
407
+
321
408
test ( "{ containment: Element }" , function ( ) {
322
409
expect ( 1 ) ;
323
410
@@ -456,8 +543,8 @@ test( "containment, element cant be pulled out of container", function() {
456
543
} )
457
544
. draggable ( { containment : "parent" } )
458
545
. simulate ( "drag" , {
459
- dx : 200 ,
460
- dy : 200
546
+ dx : 500 ,
547
+ dy : 500
461
548
} ) ;
462
549
463
550
offsetBefore = element . offset ( ) ;
0 commit comments