nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jquery.event.drag-new / event.drag / test / live.js
1 module("Live Delegation");
2
3 $.each(["draginit","dragstart","drag","dragend"],function( i, type ){
4         
5         test('"'+ type+'"',function(){
6                 
7                 expect( i ? 5 : 1 );
8                 
9                 if ( !i ){
10                         ok( true, 'Not supported for this event type.');
11                         return;
12                 }
13                 
14                 // set up the delegation
15                 $('.drag').live( type, function( event ){
16                         count += 1;
17                         equals( this, $drag[0], event.type+" target" );
18                 });
19                 // local refs
20                 var count = 0,
21                 // add a div to test the delegation
22                 $drag = $('<div class="drag" />').appendTo( document.body );
23                 
24                 // manual triggering
25                 ok( $drag.trigger( type ), '.trigger("'+ type +'")');
26                 equals( count, 1, "event was triggered");
27         
28                 // simulate a complete drag
29                 $drag
30                         .fire("mousedown",{ pageX:50, pageY:50 })
31                         .fire("mousemove",{ pageX:51, pageY:51 })
32                         .fire("mouseup",{ pageX:51, pageY:51 })
33                         .fire("click",{ pageX:51, pageY:51 });
34                 
35                 equals( count, 2, "event was delegated");
36
37                 // remove delegation
38                 $('.drag').die( type );
39                 $drag.remove();
40         });
41 });