nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jquery.event.drag-new / event.drop / test / live.js
1 module("Live Delegation");
2
3 $.each(["dropinit","dropstart","drop","dropend"],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                 $('.drop').live( type, function( event ){
16                         count += 1;
17                         equals( this, $drop[0], event.type+" target" );
18                 });
19                 // local refs
20                 var count = 0,
21                 // add a div to test the delegation
22                 $drop = $('<div class="drop" />')
23                         .css({
24                                 position: 'absolute',
25                                 top: 0, left: 0,
26                                 height: 100, width: 100
27                                 })
28                         .appendTo( document.body ),
29                 // add a dragger
30                 $drag = $('<div class="drag" />')
31                         .css({
32                                 position: 'absolute',
33                                 top: 0, left: 0,
34                                 height: 100, width: 100
35                                 })
36                         .appendTo( document.body )
37                         .drag(function(){ });
38                 
39                 // check triggering of the event handlers
40                 ok( $drop.trigger( type ), '.trigger("'+ type +'")');
41                 equals( count, 1, "event was triggered");
42                                 
43                 // simulate a complete drag
44                 $drag
45                         .fire("mousedown",{ pageX:50, pageY:50 })
46                         .fire("mousemove",{ pageX:51, pageY:51 })
47                         .fire("mouseup",{ pageX:51, pageY:51 })
48                         .fire("click",{ pageX:51, pageY:51 });
49                 
50                 // check the event handler counts
51                 equals( count, 2, "event was delegated");
52                                 
53                 // remove delegation
54                 $('.drop').die( type );
55                 $drag.remove();
56                 $drop.remove();
57                 
58         });
59
60 });