@@ -258,11 +258,114 @@ test( "over", function() {
258
258
equal ( overCount , 1 , "over fires only once" ) ;
259
259
} ) ;
260
260
261
+ // http://bugs.jqueryui.com/ticket/9335
262
+ // Sortable: over & out events does not consistently fire
263
+ test ( "over, fires with draggable connected to sortable" , function ( ) {
264
+ expect ( 3 ) ;
265
+
266
+ var hash ,
267
+ overCount = 0 ,
268
+ item = $ ( "<div></div>" ) . text ( "6" ) . insertAfter ( "#sortable" ) ;
269
+
270
+ item . draggable ( {
271
+ connectToSortable : "#sortable"
272
+ } ) ;
273
+ $ ( ".connectWith" ) . sortable ( {
274
+ connectWith : ".connectWith" ,
275
+ over : function ( event , ui ) {
276
+ hash = ui ;
277
+ overCount ++ ;
278
+ }
279
+ } ) ;
280
+
281
+ item . simulate ( "drag" , {
282
+ dy : - 20
283
+ } ) ;
284
+
285
+ ok ( hash , "over event triggered" ) ;
286
+ ok ( ! hash . sender , "UI should not include: sender" ) ;
287
+ equal ( overCount , 1 , "over fires only once" ) ;
288
+ } ) ;
289
+
290
+ test ( "over, with connected sortable" , function ( ) {
291
+ expect ( 3 ) ;
292
+
293
+ var hash ,
294
+ overCount = 0 ;
295
+
296
+ $ ( ".connectWith" ) . sortable ( {
297
+ connectWith : ".connectWith"
298
+ } ) ;
299
+ $ ( "#sortable2" ) . on ( "sortover" , function ( event , ui ) {
300
+ hash = ui ;
301
+ overCount ++ ;
302
+ } ) ;
303
+ $ ( "#sortable" ) . find ( "li:eq(0)" ) . simulate ( "drag" , {
304
+ dy : 102
305
+ } ) ;
306
+
307
+ ok ( hash , "over event triggered" ) ;
308
+ equal ( hash . sender [ 0 ] , $ ( " #sortable" ) [ 0 ] , "UI includes: sender" ) ;
309
+ equal ( overCount , 1 , "over fires only once" ) ;
310
+ } ) ;
311
+
261
312
/*
262
313
test("out", function() {
263
314
ok(false, "missing test - untested code is broken code.");
264
315
});
316
+ */
317
+
318
+ test ( "out, with connected sortable" , function ( ) {
319
+ expect ( 2 ) ;
320
+
321
+ var hash ,
322
+ outCount = 0 ;
323
+
324
+ $ ( ".connectWith" ) . sortable ( {
325
+ connectWith : ".connectWith"
326
+ } ) ;
327
+ $ ( "#sortable" ) . on ( "sortout" , function ( event , ui ) {
328
+ hash = ui ;
329
+ outCount ++ ;
330
+ } ) ;
331
+ $ ( "#sortable" ) . find ( "li:last" ) . simulate ( "drag" , {
332
+ dy : 40
333
+ } ) ;
334
+
335
+ ok ( hash , "out event triggered" ) ;
336
+ equal ( outCount , 1 , "out fires only once" ) ;
337
+ } ) ;
338
+
339
+ test ( "repeated out & over between connected sortables" , function ( ) {
340
+ expect ( 2 ) ;
265
341
342
+ var outCount = 0 ,
343
+ overCount = 0 ;
344
+
345
+ $ ( ".connectWith" ) . sortable ( {
346
+ connectWith : ".connectWith" ,
347
+ over : function ( ) {
348
+ overCount ++ ;
349
+ } ,
350
+ out : function ( event , ui ) {
351
+ // Ignore events that trigger when an item has dropped
352
+ // checking for the presence of the helper.
353
+ if ( ! ui . helper ) {
354
+ outCount ++ ;
355
+ }
356
+ }
357
+ } ) ;
358
+ $ ( "#sortable" ) . find ( "li:last" ) . simulate ( "drag" , {
359
+ dy : 40
360
+ } ) . simulate ( "drag" , {
361
+ dy : - 40
362
+ } ) ;
363
+
364
+ equal ( outCount , 2 , "out fires twice" ) ;
365
+ equal ( overCount , 4 , "over fires four times" ) ;
366
+ } ) ;
367
+
368
+ /*
266
369
test("activate", function() {
267
370
ok(false, "missing test - untested code is broken code.");
268
371
});
0 commit comments