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