nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jquery.event.drag-new / fire / test / mouse.js
1 module("Mouse Events");
2
3 // test each of the following events
4 $.each([
5         "click","dblclick",
6         "mouseover","mouseout",
7         "mousedown","mouseup","mousemove"
8 ],function( i, type ){
9         // test each event type
10         test( '"'+ type +'"', function(){
11                 expect( 33 );
12                 
13                 // custom event properties
14                 var props = {
15                         pageX: Math.round( Math.random() * 500 ),
16                         pageY: Math.round( Math.random() * 500 ),
17                         ctrlKey: Math.round( Math.random() ) ? true : false, 
18                         altKey: Math.round( Math.random() ) ? true : false, 
19                         shiftKey: Math.round( Math.random() ) ? true : false, 
20                         button: Math.round( Math.random() * 2 )
21                 },
22                 // new test element
23                 $div = $('<div/>').appendTo( document.body );
24                 // test the document too for bubbling
25                 $div.add( document ).bind( type, function( ev ){
26                         
27                         equals( ev.currentTarget, this, "event.currentTarget");
28                         equals( ev.target, $div[0], "event.target" );
29                         equals( ev.type, type, "event.type" );
30                         equals( ev.pageX, props.pageX, "event.pageX" );
31                         equals( ev.pageY, props.pageY, "event.pageY" );
32                         equals( ev.ctrlKey, props.ctrlKey, "event.ctrlKey" );
33                         equals( ev.altKey, props.altKey, "event.altKey" );
34                         equals( ev.shiftKey, props.shiftKey, "event.shiftKey" );
35                         equals( ev.metaKey, props.metaKey, "event.metaKey" );
36                         equals( ev.button, props.button, "event.button" );
37                         equals( ev.bubbles, props.bubbles, "event.bubbles" );
38                 });
39                 
40                 // make sure that metaKey and ctrlKey are equal
41                 props.metaKey = props.ctrlKey;
42                 // fire the event with bubbling
43                 props.bubbles = true;
44                 $div.fire( type, props );
45                 
46                 // fire the event without bubbling
47                 props.bubbles = false;
48                 $div.fire( type, props );
49         
50                 // cleanup
51                 $( document ).unbind( type );
52                 $div.remove();
53         });
54 });