~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/event-simulate/event-simulate-debug.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('event-simulate', function(Y) {
 
8
 
 
9
(function() {
 
10
/**
 
11
 * Simulate user interaction by generating native DOM events.
 
12
 *
 
13
 * @module event-simulate
 
14
 * @requires event
 
15
 */
 
16
 
 
17
//shortcuts
 
18
var L   = Y.Lang,
 
19
    array       = Y.Array,
 
20
    isFunction  = L.isFunction,
 
21
    isString    = L.isString,
 
22
    isBoolean   = L.isBoolean,
 
23
    isObject    = L.isObject,
 
24
    isNumber    = L.isNumber,
 
25
    doc         = Y.config.doc,
 
26
 
 
27
    //mouse events supported
 
28
    mouseEvents = {
 
29
        click:      1,
 
30
        dblclick:   1,
 
31
        mouseover:  1,
 
32
        mouseout:   1,
 
33
        mousedown:  1,
 
34
        mouseup:    1,
 
35
        mousemove:  1,
 
36
        contextmenu:1
 
37
    },
 
38
 
 
39
    //key events supported
 
40
    keyEvents   = {
 
41
        keydown:    1,
 
42
        keyup:      1,
 
43
        keypress:   1
 
44
    },
 
45
 
 
46
    //HTML events supported
 
47
    uiEvents  = {
 
48
        blur:       1,
 
49
        change:     1,
 
50
        focus:      1,
 
51
        resize:     1,
 
52
        scroll:     1,
 
53
        select:     1
 
54
    },
 
55
 
 
56
    //events that bubble by default
 
57
    bubbleEvents = {
 
58
        scroll:     1,
 
59
        resize:     1,
 
60
        reset:      1,
 
61
        submit:     1,
 
62
        change:     1,
 
63
        select:     1,
 
64
        error:      1,
 
65
        abort:      1
 
66
    };
 
67
 
 
68
//all key and mouse events bubble
 
69
Y.mix(bubbleEvents, mouseEvents);
 
70
Y.mix(bubbleEvents, keyEvents);
 
71
 
 
72
/*
 
73
 * Note: Intentionally not for YUIDoc generation.
 
74
 * Simulates a key event using the given event information to populate
 
75
 * the generated event object. This method does browser-equalizing
 
76
 * calculations to account for differences in the DOM and IE event models
 
77
 * as well as different browser quirks. Note: keydown causes Safari 2.x to
 
78
 * crash.
 
79
 * @method simulateKeyEvent
 
80
 * @private
 
81
 * @static
 
82
 * @param {HTMLElement} target The target of the given event.
 
83
 * @param {String} type The type of event to fire. This can be any one of
 
84
 *      the following: keyup, keydown, and keypress.
 
85
 * @param {Boolean} bubbles (Optional) Indicates if the event can be
 
86
 *      bubbled up. DOM Level 3 specifies that all key events bubble by
 
87
 *      default. The default is true.
 
88
 * @param {Boolean} cancelable (Optional) Indicates if the event can be
 
89
 *      canceled using preventDefault(). DOM Level 3 specifies that all
 
90
 *      key events can be cancelled. The default
 
91
 *      is true.
 
92
 * @param {Window} view (Optional) The view containing the target. This is
 
93
 *      typically the window object. The default is window.
 
94
 * @param {Boolean} ctrlKey (Optional) Indicates if one of the CTRL keys
 
95
 *      is pressed while the event is firing. The default is false.
 
96
 * @param {Boolean} altKey (Optional) Indicates if one of the ALT keys
 
97
 *      is pressed while the event is firing. The default is false.
 
98
 * @param {Boolean} shiftKey (Optional) Indicates if one of the SHIFT keys
 
99
 *      is pressed while the event is firing. The default is false.
 
100
 * @param {Boolean} metaKey (Optional) Indicates if one of the META keys
 
101
 *      is pressed while the event is firing. The default is false.
 
102
 * @param {int} keyCode (Optional) The code for the key that is in use.
 
103
 *      The default is 0.
 
104
 * @param {int} charCode (Optional) The Unicode code for the character
 
105
 *      associated with the key being used. The default is 0.
 
106
 */
 
107
function simulateKeyEvent(target /*:HTMLElement*/, type /*:String*/,
 
108
                             bubbles /*:Boolean*/,  cancelable /*:Boolean*/,
 
109
                             view /*:Window*/,
 
110
                             ctrlKey /*:Boolean*/,    altKey /*:Boolean*/,
 
111
                             shiftKey /*:Boolean*/,   metaKey /*:Boolean*/,
 
112
                             keyCode /*:int*/,        charCode /*:int*/) /*:Void*/
 
113
{
 
114
    //check target
 
115
    if (!target){
 
116
        Y.error("simulateKeyEvent(): Invalid target.");
 
117
    }
 
118
 
 
119
    //check event type
 
120
    if (isString(type)){
 
121
        type = type.toLowerCase();
 
122
        switch(type){
 
123
            case "textevent": //DOM Level 3
 
124
                type = "keypress";
 
125
                break;
 
126
            case "keyup":
 
127
            case "keydown":
 
128
            case "keypress":
 
129
                break;
 
130
            default:
 
131
                Y.error("simulateKeyEvent(): Event type '" + type + "' not supported.");
 
132
        }
 
133
    } else {
 
134
        Y.error("simulateKeyEvent(): Event type must be a string.");
 
135
    }
 
136
 
 
137
    //setup default values
 
138
    if (!isBoolean(bubbles)){
 
139
        bubbles = true; //all key events bubble
 
140
    }
 
141
    if (!isBoolean(cancelable)){
 
142
        cancelable = true; //all key events can be cancelled
 
143
    }
 
144
    if (!isObject(view)){
 
145
        view = Y.config.win; //view is typically window
 
146
    }
 
147
    if (!isBoolean(ctrlKey)){
 
148
        ctrlKey = false;
 
149
    }
 
150
    if (!isBoolean(altKey)){
 
151
        altKey = false;
 
152
    }
 
153
    if (!isBoolean(shiftKey)){
 
154
        shiftKey = false;
 
155
    }
 
156
    if (!isBoolean(metaKey)){
 
157
        metaKey = false;
 
158
    }
 
159
    if (!isNumber(keyCode)){
 
160
        keyCode = 0;
 
161
    }
 
162
    if (!isNumber(charCode)){
 
163
        charCode = 0;
 
164
    }
 
165
 
 
166
    //try to create a mouse event
 
167
    var customEvent /*:MouseEvent*/ = null;
 
168
 
 
169
    //check for DOM-compliant browsers first
 
170
    if (isFunction(doc.createEvent)){
 
171
 
 
172
        try {
 
173
 
 
174
            //try to create key event
 
175
            customEvent = doc.createEvent("KeyEvents");
 
176
 
 
177
            /*
 
178
             * Interesting problem: Firefox implemented a non-standard
 
179
             * version of initKeyEvent() based on DOM Level 2 specs.
 
180
             * Key event was removed from DOM Level 2 and re-introduced
 
181
             * in DOM Level 3 with a different interface. Firefox is the
 
182
             * only browser with any implementation of Key Events, so for
 
183
             * now, assume it's Firefox if the above line doesn't error.
 
184
             */
 
185
            // @TODO: Decipher between Firefox's implementation and a correct one.
 
186
            customEvent.initKeyEvent(type, bubbles, cancelable, view, ctrlKey,
 
187
                altKey, shiftKey, metaKey, keyCode, charCode);
 
188
 
 
189
        } catch (ex /*:Error*/){
 
190
 
 
191
            /*
 
192
             * If it got here, that means key events aren't officially supported.
 
193
             * Safari/WebKit is a real problem now. WebKit 522 won't let you
 
194
             * set keyCode, charCode, or other properties if you use a
 
195
             * UIEvent, so we first must try to create a generic event. The
 
196
             * fun part is that this will throw an error on Safari 2.x. The
 
197
             * end result is that we need another try...catch statement just to
 
198
             * deal with this mess.
 
199
             */
 
200
            try {
 
201
 
 
202
                //try to create generic event - will fail in Safari 2.x
 
203
                customEvent = doc.createEvent("Events");
 
204
 
 
205
            } catch (uierror /*:Error*/){
 
206
 
 
207
                //the above failed, so create a UIEvent for Safari 2.x
 
208
                customEvent = doc.createEvent("UIEvents");
 
209
 
 
210
            } finally {
 
211
 
 
212
                customEvent.initEvent(type, bubbles, cancelable);
 
213
 
 
214
                //initialize
 
215
                customEvent.view = view;
 
216
                customEvent.altKey = altKey;
 
217
                customEvent.ctrlKey = ctrlKey;
 
218
                customEvent.shiftKey = shiftKey;
 
219
                customEvent.metaKey = metaKey;
 
220
                customEvent.keyCode = keyCode;
 
221
                customEvent.charCode = charCode;
 
222
 
 
223
            }
 
224
 
 
225
        }
 
226
 
 
227
        //fire the event
 
228
        target.dispatchEvent(customEvent);
 
229
 
 
230
    } else if (isObject(doc.createEventObject)){ //IE
 
231
 
 
232
        //create an IE event object
 
233
        customEvent = doc.createEventObject();
 
234
 
 
235
        //assign available properties
 
236
        customEvent.bubbles = bubbles;
 
237
        customEvent.cancelable = cancelable;
 
238
        customEvent.view = view;
 
239
        customEvent.ctrlKey = ctrlKey;
 
240
        customEvent.altKey = altKey;
 
241
        customEvent.shiftKey = shiftKey;
 
242
        customEvent.metaKey = metaKey;
 
243
 
 
244
        /*
 
245
         * IE doesn't support charCode explicitly. CharCode should
 
246
         * take precedence over any keyCode value for accurate
 
247
         * representation.
 
248
         */
 
249
        customEvent.keyCode = (charCode > 0) ? charCode : keyCode;
 
250
 
 
251
        //fire the event
 
252
        target.fireEvent("on" + type, customEvent);
 
253
 
 
254
    } else {
 
255
        Y.error("simulateKeyEvent(): No event simulation framework present.");
 
256
    }
 
257
}
 
258
 
 
259
/*
 
260
 * Note: Intentionally not for YUIDoc generation.
 
261
 * Simulates a mouse event using the given event information to populate
 
262
 * the generated event object. This method does browser-equalizing
 
263
 * calculations to account for differences in the DOM and IE event models
 
264
 * as well as different browser quirks.
 
265
 * @method simulateMouseEvent
 
266
 * @private
 
267
 * @static
 
268
 * @param {HTMLElement} target The target of the given event.
 
269
 * @param {String} type The type of event to fire. This can be any one of
 
270
 *      the following: click, dblclick, mousedown, mouseup, mouseout,
 
271
 *      mouseover, and mousemove.
 
272
 * @param {Boolean} bubbles (Optional) Indicates if the event can be
 
273
 *      bubbled up. DOM Level 2 specifies that all mouse events bubble by
 
274
 *      default. The default is true.
 
275
 * @param {Boolean} cancelable (Optional) Indicates if the event can be
 
276
 *      canceled using preventDefault(). DOM Level 2 specifies that all
 
277
 *      mouse events except mousemove can be cancelled. The default
 
278
 *      is true for all events except mousemove, for which the default
 
279
 *      is false.
 
280
 * @param {Window} view (Optional) The view containing the target. This is
 
281
 *      typically the window object. The default is window.
 
282
 * @param {int} detail (Optional) The number of times the mouse button has
 
283
 *      been used. The default value is 1.
 
284
 * @param {int} screenX (Optional) The x-coordinate on the screen at which
 
285
 *      point the event occured. The default is 0.
 
286
 * @param {int} screenY (Optional) The y-coordinate on the screen at which
 
287
 *      point the event occured. The default is 0.
 
288
 * @param {int} clientX (Optional) The x-coordinate on the client at which
 
289
 *      point the event occured. The default is 0.
 
290
 * @param {int} clientY (Optional) The y-coordinate on the client at which
 
291
 *      point the event occured. The default is 0.
 
292
 * @param {Boolean} ctrlKey (Optional) Indicates if one of the CTRL keys
 
293
 *      is pressed while the event is firing. The default is false.
 
294
 * @param {Boolean} altKey (Optional) Indicates if one of the ALT keys
 
295
 *      is pressed while the event is firing. The default is false.
 
296
 * @param {Boolean} shiftKey (Optional) Indicates if one of the SHIFT keys
 
297
 *      is pressed while the event is firing. The default is false.
 
298
 * @param {Boolean} metaKey (Optional) Indicates if one of the META keys
 
299
 *      is pressed while the event is firing. The default is false.
 
300
 * @param {int} button (Optional) The button being pressed while the event
 
301
 *      is executing. The value should be 0 for the primary mouse button
 
302
 *      (typically the left button), 1 for the terciary mouse button
 
303
 *      (typically the middle button), and 2 for the secondary mouse button
 
304
 *      (typically the right button). The default is 0.
 
305
 * @param {HTMLElement} relatedTarget (Optional) For mouseout events,
 
306
 *      this is the element that the mouse has moved to. For mouseover
 
307
 *      events, this is the element that the mouse has moved from. This
 
308
 *      argument is ignored for all other events. The default is null.
 
309
 */
 
310
function simulateMouseEvent(target /*:HTMLElement*/, type /*:String*/,
 
311
                               bubbles /*:Boolean*/,  cancelable /*:Boolean*/,
 
312
                               view /*:Window*/,        detail /*:int*/,
 
313
                               screenX /*:int*/,        screenY /*:int*/,
 
314
                               clientX /*:int*/,        clientY /*:int*/,
 
315
                               ctrlKey /*:Boolean*/,    altKey /*:Boolean*/,
 
316
                               shiftKey /*:Boolean*/,   metaKey /*:Boolean*/,
 
317
                               button /*:int*/,         relatedTarget /*:HTMLElement*/) /*:Void*/
 
318
{
 
319
 
 
320
    //check target
 
321
    if (!target){
 
322
        Y.error("simulateMouseEvent(): Invalid target.");
 
323
    }
 
324
 
 
325
    //check event type
 
326
    if (isString(type)){
 
327
        type = type.toLowerCase();
 
328
 
 
329
        //make sure it's a supported mouse event
 
330
        if (!mouseEvents[type]){
 
331
            Y.error("simulateMouseEvent(): Event type '" + type + "' not supported.");
 
332
        }
 
333
    } else {
 
334
        Y.error("simulateMouseEvent(): Event type must be a string.");
 
335
    }
 
336
 
 
337
    //setup default values
 
338
    if (!isBoolean(bubbles)){
 
339
        bubbles = true; //all mouse events bubble
 
340
    }
 
341
    if (!isBoolean(cancelable)){
 
342
        cancelable = (type != "mousemove"); //mousemove is the only one that can't be cancelled
 
343
    }
 
344
    if (!isObject(view)){
 
345
        view = Y.config.win; //view is typically window
 
346
    }
 
347
    if (!isNumber(detail)){
 
348
        detail = 1;  //number of mouse clicks must be at least one
 
349
    }
 
350
    if (!isNumber(screenX)){
 
351
        screenX = 0;
 
352
    }
 
353
    if (!isNumber(screenY)){
 
354
        screenY = 0;
 
355
    }
 
356
    if (!isNumber(clientX)){
 
357
        clientX = 0;
 
358
    }
 
359
    if (!isNumber(clientY)){
 
360
        clientY = 0;
 
361
    }
 
362
    if (!isBoolean(ctrlKey)){
 
363
        ctrlKey = false;
 
364
    }
 
365
    if (!isBoolean(altKey)){
 
366
        altKey = false;
 
367
    }
 
368
    if (!isBoolean(shiftKey)){
 
369
        shiftKey = false;
 
370
    }
 
371
    if (!isBoolean(metaKey)){
 
372
        metaKey = false;
 
373
    }
 
374
    if (!isNumber(button)){
 
375
        button = 0;
 
376
    }
 
377
 
 
378
    relatedTarget = relatedTarget || null;
 
379
 
 
380
    //try to create a mouse event
 
381
    var customEvent /*:MouseEvent*/ = null;
 
382
 
 
383
    //check for DOM-compliant browsers first
 
384
    if (isFunction(doc.createEvent)){
 
385
 
 
386
        customEvent = doc.createEvent("MouseEvents");
 
387
 
 
388
        //Safari 2.x (WebKit 418) still doesn't implement initMouseEvent()
 
389
        if (customEvent.initMouseEvent){
 
390
            customEvent.initMouseEvent(type, bubbles, cancelable, view, detail,
 
391
                                 screenX, screenY, clientX, clientY,
 
392
                                 ctrlKey, altKey, shiftKey, metaKey,
 
393
                                 button, relatedTarget);
 
394
        } else { //Safari
 
395
 
 
396
            //the closest thing available in Safari 2.x is UIEvents
 
397
            customEvent = doc.createEvent("UIEvents");
 
398
            customEvent.initEvent(type, bubbles, cancelable);
 
399
            customEvent.view = view;
 
400
            customEvent.detail = detail;
 
401
            customEvent.screenX = screenX;
 
402
            customEvent.screenY = screenY;
 
403
            customEvent.clientX = clientX;
 
404
            customEvent.clientY = clientY;
 
405
            customEvent.ctrlKey = ctrlKey;
 
406
            customEvent.altKey = altKey;
 
407
            customEvent.metaKey = metaKey;
 
408
            customEvent.shiftKey = shiftKey;
 
409
            customEvent.button = button;
 
410
            customEvent.relatedTarget = relatedTarget;
 
411
        }
 
412
 
 
413
        /*
 
414
         * Check to see if relatedTarget has been assigned. Firefox
 
415
         * versions less than 2.0 don't allow it to be assigned via
 
416
         * initMouseEvent() and the property is readonly after event
 
417
         * creation, so in order to keep YAHOO.util.getRelatedTarget()
 
418
         * working, assign to the IE proprietary toElement property
 
419
         * for mouseout event and fromElement property for mouseover
 
420
         * event.
 
421
         */
 
422
        if (relatedTarget && !customEvent.relatedTarget){
 
423
            if (type == "mouseout"){
 
424
                customEvent.toElement = relatedTarget;
 
425
            } else if (type == "mouseover"){
 
426
                customEvent.fromElement = relatedTarget;
 
427
            }
 
428
        }
 
429
 
 
430
        //fire the event
 
431
        target.dispatchEvent(customEvent);
 
432
 
 
433
    } else if (isObject(doc.createEventObject)){ //IE
 
434
 
 
435
        //create an IE event object
 
436
        customEvent = doc.createEventObject();
 
437
 
 
438
        //assign available properties
 
439
        customEvent.bubbles = bubbles;
 
440
        customEvent.cancelable = cancelable;
 
441
        customEvent.view = view;
 
442
        customEvent.detail = detail;
 
443
        customEvent.screenX = screenX;
 
444
        customEvent.screenY = screenY;
 
445
        customEvent.clientX = clientX;
 
446
        customEvent.clientY = clientY;
 
447
        customEvent.ctrlKey = ctrlKey;
 
448
        customEvent.altKey = altKey;
 
449
        customEvent.metaKey = metaKey;
 
450
        customEvent.shiftKey = shiftKey;
 
451
 
 
452
        //fix button property for IE's wacky implementation
 
453
        switch(button){
 
454
            case 0:
 
455
                customEvent.button = 1;
 
456
                break;
 
457
            case 1:
 
458
                customEvent.button = 4;
 
459
                break;
 
460
            case 2:
 
461
                //leave as is
 
462
                break;
 
463
            default:
 
464
                customEvent.button = 0;
 
465
        }
 
466
 
 
467
        /*
 
468
         * Have to use relatedTarget because IE won't allow assignment
 
469
         * to toElement or fromElement on generic events. This keeps
 
470
         * YAHOO.util.customEvent.getRelatedTarget() functional.
 
471
         */
 
472
        customEvent.relatedTarget = relatedTarget;
 
473
 
 
474
        //fire the event
 
475
        target.fireEvent("on" + type, customEvent);
 
476
 
 
477
    } else {
 
478
        Y.error("simulateMouseEvent(): No event simulation framework present.");
 
479
    }
 
480
}
 
481
 
 
482
/*
 
483
 * Note: Intentionally not for YUIDoc generation.
 
484
 * Simulates a UI event using the given event information to populate
 
485
 * the generated event object. This method does browser-equalizing
 
486
 * calculations to account for differences in the DOM and IE event models
 
487
 * as well as different browser quirks.
 
488
 * @method simulateHTMLEvent
 
489
 * @private
 
490
 * @static
 
491
 * @param {HTMLElement} target The target of the given event.
 
492
 * @param {String} type The type of event to fire. This can be any one of
 
493
 *      the following: click, dblclick, mousedown, mouseup, mouseout,
 
494
 *      mouseover, and mousemove.
 
495
 * @param {Boolean} bubbles (Optional) Indicates if the event can be
 
496
 *      bubbled up. DOM Level 2 specifies that all mouse events bubble by
 
497
 *      default. The default is true.
 
498
 * @param {Boolean} cancelable (Optional) Indicates if the event can be
 
499
 *      canceled using preventDefault(). DOM Level 2 specifies that all
 
500
 *      mouse events except mousemove can be cancelled. The default
 
501
 *      is true for all events except mousemove, for which the default
 
502
 *      is false.
 
503
 * @param {Window} view (Optional) The view containing the target. This is
 
504
 *      typically the window object. The default is window.
 
505
 * @param {int} detail (Optional) The number of times the mouse button has
 
506
 *      been used. The default value is 1.
 
507
 */
 
508
function simulateUIEvent(target /*:HTMLElement*/, type /*:String*/,
 
509
                               bubbles /*:Boolean*/,  cancelable /*:Boolean*/,
 
510
                               view /*:Window*/,        detail /*:int*/) /*:Void*/
 
511
{
 
512
 
 
513
    //check target
 
514
    if (!target){
 
515
        Y.error("simulateUIEvent(): Invalid target.");
 
516
    }
 
517
 
 
518
    //check event type
 
519
    if (isString(type)){
 
520
        type = type.toLowerCase();
 
521
 
 
522
        //make sure it's a supported mouse event
 
523
        if (!uiEvents[type]){
 
524
            Y.error("simulateUIEvent(): Event type '" + type + "' not supported.");
 
525
        }
 
526
    } else {
 
527
        Y.error("simulateUIEvent(): Event type must be a string.");
 
528
    }
 
529
 
 
530
    //try to create a mouse event
 
531
    var customEvent = null;
 
532
 
 
533
 
 
534
    //setup default values
 
535
    if (!isBoolean(bubbles)){
 
536
        bubbles = (type in bubbleEvents);  //not all events bubble
 
537
    }
 
538
    if (!isBoolean(cancelable)){
 
539
        cancelable = (type == "submit"); //submit is the only one that can be cancelled
 
540
    }
 
541
    if (!isObject(view)){
 
542
        view = Y.config.win; //view is typically window
 
543
    }
 
544
    if (!isNumber(detail)){
 
545
        detail = 1;  //usually not used but defaulted to this
 
546
    }
 
547
 
 
548
    //check for DOM-compliant browsers first
 
549
    if (isFunction(doc.createEvent)){
 
550
 
 
551
        //just a generic UI Event object is needed
 
552
        customEvent = doc.createEvent("UIEvents");
 
553
        customEvent.initUIEvent(type, bubbles, cancelable, view, detail);
 
554
 
 
555
        //fire the event
 
556
        target.dispatchEvent(customEvent);
 
557
 
 
558
    } else if (isObject(doc.createEventObject)){ //IE
 
559
 
 
560
        //create an IE event object
 
561
        customEvent = doc.createEventObject();
 
562
 
 
563
        //assign available properties
 
564
        customEvent.bubbles = bubbles;
 
565
        customEvent.cancelable = cancelable;
 
566
        customEvent.view = view;
 
567
        customEvent.detail = detail;
 
568
 
 
569
        //fire the event
 
570
        target.fireEvent("on" + type, customEvent);
 
571
 
 
572
    } else {
 
573
        Y.error("simulateUIEvent(): No event simulation framework present.");
 
574
    }
 
575
}
 
576
 
 
577
/**
 
578
 * Simulates the event with the given name on a target.
 
579
 * @param {HTMLElement} target The DOM element that's the target of the event.
 
580
 * @param {String} type The type of event to simulate (i.e., "click").
 
581
 * @param {Object} options (Optional) Extra options to copy onto the event object.
 
582
 * @return {void}
 
583
 * @for Event
 
584
 * @method simulate
 
585
 * @static
 
586
 */
 
587
Y.Event.simulate = function(target, type, options){
 
588
 
 
589
    options = options || {};
 
590
 
 
591
    if (mouseEvents[type]){
 
592
        simulateMouseEvent(target, type, options.bubbles,
 
593
            options.cancelable, options.view, options.detail, options.screenX,
 
594
            options.screenY, options.clientX, options.clientY, options.ctrlKey,
 
595
            options.altKey, options.shiftKey, options.metaKey, options.button,
 
596
            options.relatedTarget);
 
597
    } else if (keyEvents[type]){
 
598
        simulateKeyEvent(target, type, options.bubbles,
 
599
            options.cancelable, options.view, options.ctrlKey,
 
600
            options.altKey, options.shiftKey, options.metaKey,
 
601
            options.keyCode, options.charCode);
 
602
    } else if (uiEvents[type]){
 
603
        simulateUIEvent(target, type, options.bubbles,
 
604
            options.cancelable, options.view, options.detail);
 
605
     } else {
 
606
        Y.error("simulate(): Event '" + type + "' can't be simulated.");
 
607
    }
 
608
};
 
609
 
 
610
 
 
611
})();
 
612
 
 
613
 
 
614
 
 
615
}, '3.5.1' ,{requires:['event-base']});