-
Notifications
You must be signed in to change notification settings - Fork 0
/
Event.js.html
1745 lines (1537 loc) · 188 KB
/
Event.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>API: event Event.js (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
<link rel="stylesheet" type="text/css" href="assets/api.css" />
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
<h3>Event Utility <span class="subtitle">2.8.2r1</span></h3>
<a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a>
> <a href="./module_event.html" title="event">event</a>
> Event.js (source view)
<form onsubmit="return false">
<div id="propertysearch">
Search: <input autocomplete="off" id="searchinput" />
<div id="searchresults">
</div>
</div>
</form>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
<fieldset>
<legend>Filters</legend>
<span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
<span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
<span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
</fieldset>
</form>
<div id="srcout">
<style>
#doc3 .classopts { display:none; }
</style>
<div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * The Event Utility provides utilities for managing DOM Events and tools</span>
<span class="cm"> * for building event systems</span>
<span class="cm"> *</span>
<span class="cm"> * @module event</span>
<span class="cm"> * @title Event Utility</span>
<span class="cm"> * @namespace YAHOO.util</span>
<span class="cm"> * @requires yahoo</span>
<span class="cm"> */</span>
<span class="c1">// The first instance of Event will win if it is loaded more than once.</span>
<span class="c1">// @TODO this needs to be changed so that only the state data that needs to</span>
<span class="c1">// be preserved is kept, while methods are overwritten/added as needed.</span>
<span class="c1">// This means that the module pattern can't be used.</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Event</span><span class="p">)</span> <span class="p">{</span>
<span class="cm">/**</span>
<span class="cm"> * The event utility provides functions to add and remove event listeners,</span>
<span class="cm"> * event cleansing. It also tries to automatically remove listeners it</span>
<span class="cm"> * registers during the unload event.</span>
<span class="cm"> *</span>
<span class="cm"> * @class Event</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Event</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="cm">/**</span>
<span class="cm"> * True after the onload event has fired</span>
<span class="cm"> * @property loadComplete</span>
<span class="cm"> * @type boolean</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="kd">var</span> <span class="nx">loadComplete</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Cache of wrapped listeners</span>
<span class="cm"> * @property listeners</span>
<span class="cm"> * @type array</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">listeners</span> <span class="o">=</span> <span class="p">[],</span>
<span class="cm">/**</span>
<span class="cm"> * User-defined unload function that will be fired before all events</span>
<span class="cm"> * are detached</span>
<span class="cm"> * @property unloadListeners</span>
<span class="cm"> * @type array</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">unloadListeners</span> <span class="o">=</span> <span class="p">[],</span>
<span class="cm">/**</span>
<span class="cm"> * The number of times to poll after window.onload. This number is</span>
<span class="cm"> * increased if additional late-bound handlers are requested after</span>
<span class="cm"> * the page load.</span>
<span class="cm"> * @property retryCount</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">retryCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * onAvailable listeners</span>
<span class="cm"> * @property onAvailStack</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">onAvailStack</span> <span class="o">=</span> <span class="p">[],</span>
<span class="cm">/**</span>
<span class="cm"> * Counter for auto id generation</span>
<span class="cm"> * @property counter</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">counter</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Normalized keycodes for webkit/safari</span>
<span class="cm"> * @property webkitKeymap</span>
<span class="cm"> * @type {int: int}</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">webkitKeymap</span> <span class="o">=</span> <span class="p">{</span>
<span class="mi">63232</span><span class="o">:</span> <span class="mi">38</span><span class="p">,</span> <span class="c1">// up</span>
<span class="mi">63233</span><span class="o">:</span> <span class="mi">40</span><span class="p">,</span> <span class="c1">// down</span>
<span class="mi">63234</span><span class="o">:</span> <span class="mi">37</span><span class="p">,</span> <span class="c1">// left</span>
<span class="mi">63235</span><span class="o">:</span> <span class="mi">39</span><span class="p">,</span> <span class="c1">// right</span>
<span class="mi">63276</span><span class="o">:</span> <span class="mi">33</span><span class="p">,</span> <span class="c1">// page up</span>
<span class="mi">63277</span><span class="o">:</span> <span class="mi">34</span><span class="p">,</span> <span class="c1">// page down</span>
<span class="mi">25</span><span class="o">:</span> <span class="mi">9</span> <span class="c1">// SHIFT-TAB (Safari provides a different key code in</span>
<span class="c1">// this case, even though the shiftKey modifier is set)</span>
<span class="p">},</span>
<span class="nx">isIE</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ua</span><span class="p">.</span><span class="nx">ie</span><span class="p">,</span>
<span class="c1">// String constants used by the addFocusListener and removeFocusListener methods</span>
<span class="nx">FOCUSIN</span> <span class="o">=</span> <span class="s2">"focusin"</span><span class="p">,</span>
<span class="nx">FOCUSOUT</span> <span class="o">=</span> <span class="s2">"focusout"</span><span class="p">;</span>
<span class="k">return</span> <span class="p">{</span>
<span class="cm">/**</span>
<span class="cm"> * The number of times we should look for elements that are not</span>
<span class="cm"> * in the DOM at the time the event is requested after the document</span>
<span class="cm"> * has been loaded. The default is 500@amp;40 ms, so it will poll</span>
<span class="cm"> * for 20 seconds or until all outstanding handlers are bound</span>
<span class="cm"> * (whichever comes first).</span>
<span class="cm"> * @property POLL_RETRYS</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">POLL_RETRYS</span><span class="o">:</span> <span class="mi">500</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * The poll interval in milliseconds</span>
<span class="cm"> * @property POLL_INTERVAL</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">POLL_INTERVAL</span><span class="o">:</span> <span class="mi">40</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Element to bind, int constant</span>
<span class="cm"> * @property EL</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">EL</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Type of event, int constant</span>
<span class="cm"> * @property TYPE</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">TYPE</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Function to execute, int constant</span>
<span class="cm"> * @property FN</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">FN</span><span class="o">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Function wrapped for context correction and cleanup, int constant</span>
<span class="cm"> * @property WFN</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">WFN</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Object passed in by the user that will be returned as a </span>
<span class="cm"> * parameter to the callback, int constant. Specific to</span>
<span class="cm"> * unload listeners</span>
<span class="cm"> * @property OBJ</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">UNLOAD_OBJ</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Adjusted context, either the element we are registering the event</span>
<span class="cm"> * on or the custom object passed in by the listener, int constant</span>
<span class="cm"> * @property ADJ_SCOPE</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">ADJ_SCOPE</span><span class="o">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * The original obj passed into addListener</span>
<span class="cm"> * @property OBJ</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">OBJ</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * The original context parameter passed into addListener</span>
<span class="cm"> * @property OVERRIDE</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">OVERRIDE</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * The original capture parameter passed into addListener</span>
<span class="cm"> * @property CAPTURE</span>
<span class="cm"> * @type int</span>
<span class="cm"> * @static</span>
<span class="cm"> * @final</span>
<span class="cm"> */</span>
<span class="nx">CAPTURE</span><span class="o">:</span> <span class="mi">7</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * addListener/removeListener can throw errors in unexpected scenarios.</span>
<span class="cm"> * These errors are suppressed, the method returns false, and this property</span>
<span class="cm"> * is set</span>
<span class="cm"> * @property lastError</span>
<span class="cm"> * @static</span>
<span class="cm"> * @type Error</span>
<span class="cm"> */</span>
<span class="nx">lastError</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Safari detection</span>
<span class="cm"> * @property isSafari</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> * @deprecated use YAHOO.env.ua.webkit</span>
<span class="cm"> */</span>
<span class="nx">isSafari</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ua</span><span class="p">.</span><span class="nx">webkit</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * webkit version</span>
<span class="cm"> * @property webkit</span>
<span class="cm"> * @type string</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> * @deprecated use YAHOO.env.ua.webkit</span>
<span class="cm"> */</span>
<span class="nx">webkit</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ua</span><span class="p">.</span><span class="nx">webkit</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * IE detection </span>
<span class="cm"> * @property isIE</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> * @deprecated use YAHOO.env.ua.ie</span>
<span class="cm"> */</span>
<span class="nx">isIE</span><span class="o">:</span> <span class="nx">isIE</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * poll handle</span>
<span class="cm"> * @property _interval</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_interval</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * document readystate poll handle</span>
<span class="cm"> * @property _dri</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_dri</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Map of special event types</span>
<span class="cm"> * @property _specialTypes</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_specialTypes</span><span class="o">:</span> <span class="p">{</span>
<span class="nx">focusin</span><span class="o">:</span> <span class="p">(</span><span class="nx">isIE</span> <span class="o">?</span> <span class="s2">"focusin"</span> <span class="o">:</span> <span class="s2">"focus"</span><span class="p">),</span>
<span class="nx">focusout</span><span class="o">:</span> <span class="p">(</span><span class="nx">isIE</span> <span class="o">?</span> <span class="s2">"focusout"</span> <span class="o">:</span> <span class="s2">"blur"</span><span class="p">)</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * True when the document is initially usable</span>
<span class="cm"> * @property DOMReady</span>
<span class="cm"> * @type boolean</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">DOMReady</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * Errors thrown by subscribers of custom events are caught</span>
<span class="cm"> * and the error message is written to the debug console. If</span>
<span class="cm"> * this property is set to true, it will also re-throw the</span>
<span class="cm"> * error.</span>
<span class="cm"> * @property throwErrors</span>
<span class="cm"> * @type boolean</span>
<span class="cm"> * @default false</span>
<span class="cm"> */</span>
<span class="nx">throwErrors</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="cm">/**</span>
<span class="cm"> * @method startInterval</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">startInterval</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_interval</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// var self = this;</span>
<span class="c1">// var callback = function() { self._tryPreloadAttach(); };</span>
<span class="c1">// this._interval = setInterval(callback, this.POLL_INTERVAL);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_interval</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">later</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">POLL_INTERVAL</span><span class="p">,</span> <span class="k">this</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_tryPreloadAttach</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Executes the supplied callback when the item with the supplied</span>
<span class="cm"> * id is found. This is meant to be used to execute behavior as</span>
<span class="cm"> * soon as possible as the page loads. If you use this after the</span>
<span class="cm"> * initial page load it will poll for a fixed time for the element.</span>
<span class="cm"> * The number of times it will poll and the frequency are</span>
<span class="cm"> * configurable. By default it will poll for 10 seconds.</span>
<span class="cm"> *</span>
<span class="cm"> * <p>The callback is executed with a single parameter:</span>
<span class="cm"> * the custom object parameter, if provided.</p></span>
<span class="cm"> *</span>
<span class="cm"> * @method onAvailable</span>
<span class="cm"> *</span>
<span class="cm"> * @param {string||string[]} id the id of the element, or an array</span>
<span class="cm"> * of ids to look for.</span>
<span class="cm"> * @param {function} fn what to execute when the element is found.</span>
<span class="cm"> * @param {object} obj an optional object to be passed back as</span>
<span class="cm"> * a parameter to fn.</span>
<span class="cm"> * @param {boolean|object} overrideContext If set to true, fn will execute</span>
<span class="cm"> * in the context of obj, if set to an object it</span>
<span class="cm"> * will execute in the context of that object</span>
<span class="cm"> * @param checkContent {boolean} check child node readiness (onContentReady)</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">onAvailable</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">,</span> <span class="nx">checkContent</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">id</span><span class="p">))</span> <span class="o">?</span> <span class="p">[</span><span class="nx">id</span><span class="p">]</span> <span class="o">:</span> <span class="nx">id</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span><span class="nx">a</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">=</span><span class="nx">i</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">onAvailStack</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span><span class="nx">id</span><span class="o">:</span> <span class="nx">a</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span>
<span class="nx">fn</span><span class="o">:</span> <span class="nx">fn</span><span class="p">,</span>
<span class="nx">obj</span><span class="o">:</span> <span class="nx">obj</span><span class="p">,</span>
<span class="nx">overrideContext</span><span class="o">:</span> <span class="nx">overrideContext</span><span class="p">,</span>
<span class="nx">checkReady</span><span class="o">:</span> <span class="nx">checkContent</span> <span class="p">});</span>
<span class="p">}</span>
<span class="nx">retryCount</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">POLL_RETRYS</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">startInterval</span><span class="p">();</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Works the same way as onAvailable, but additionally checks the</span>
<span class="cm"> * state of sibling elements to determine if the content of the</span>
<span class="cm"> * available element is safe to modify.</span>
<span class="cm"> *</span>
<span class="cm"> * <p>The callback is executed with a single parameter:</span>
<span class="cm"> * the custom object parameter, if provided.</p></span>
<span class="cm"> *</span>
<span class="cm"> * @method onContentReady</span>
<span class="cm"> *</span>
<span class="cm"> * @param {string} id the id of the element to look for.</span>
<span class="cm"> * @param {function} fn what to execute when the element is ready.</span>
<span class="cm"> * @param {object} obj an optional object to be passed back as</span>
<span class="cm"> * a parameter to fn.</span>
<span class="cm"> * @param {boolean|object} overrideContext If set to true, fn will execute</span>
<span class="cm"> * in the context of obj. If an object, fn will</span>
<span class="cm"> * exectute in the context of that object</span>
<span class="cm"> *</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">onContentReady</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">onAvailable</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Executes the supplied callback when the DOM is first usable. This</span>
<span class="cm"> * will execute immediately if called after the DOMReady event has</span>
<span class="cm"> * fired. @todo the DOMContentReady event does not fire when the</span>
<span class="cm"> * script is dynamically injected into the page. This means the</span>
<span class="cm"> * DOMReady custom event will never fire in FireFox or Opera when the</span>
<span class="cm"> * library is injected. It _will_ fire in Safari, and the IE </span>
<span class="cm"> * implementation would allow for us to fire it if the defered script</span>
<span class="cm"> * is not available. We want this to behave the same in all browsers.</span>
<span class="cm"> * Is there a way to identify when the script has been injected </span>
<span class="cm"> * instead of included inline? Is there a way to know whether the </span>
<span class="cm"> * window onload event has fired without having had a listener attached </span>
<span class="cm"> * to it when it did so?</span>
<span class="cm"> *</span>
<span class="cm"> * <p>The callback is a CustomEvent, so the signature is:</p></span>
<span class="cm"> * <p>type &lt;string&gt;, args &lt;array&gt;, customobject &lt;object&gt;</p></span>
<span class="cm"> * <p>For DOMReady events, there are no fire argments, so the</span>
<span class="cm"> * signature is:</p></span>
<span class="cm"> * <p>"DOMReady", [], obj</p></span>
<span class="cm"> *</span>
<span class="cm"> *</span>
<span class="cm"> * @method onDOMReady</span>
<span class="cm"> *</span>
<span class="cm"> * @param {function} fn what to execute when the element is found.</span>
<span class="cm"> * @param {object} obj an optional object to be passed back as</span>
<span class="cm"> * a parameter to fn.</span>
<span class="cm"> * @param {boolean|object} overrideContext If set to true, fn will execute</span>
<span class="cm"> * in the context of obj, if set to an object it</span>
<span class="cm"> * will execute in the context of that object</span>
<span class="cm"> *</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="c1">// onDOMReady: function(fn, obj, overrideContext) {</span>
<span class="nx">onDOMReady</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">DOMReadyEvent</span><span class="p">.</span><span class="nx">subscribe</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">DOMReadyEvent</span><span class="p">,</span> <span class="nx">arguments</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Appends an event handler</span>
<span class="cm"> *</span>
<span class="cm"> * @method _addListener</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="cm"> * reference, or a collection of ids and/or elements to assign the </span>
<span class="cm"> * listener to.</span>
<span class="cm"> * @param {String} sType The type of event to append</span>
<span class="cm"> * @param {Function} fn The method the event invokes</span>
<span class="cm"> * @param {Object} obj An arbitrary object that will be </span>
<span class="cm"> * passed as a parameter to the handler</span>
<span class="cm"> * @param {Boolean|object} overrideContext If true, the obj passed in becomes</span>
<span class="cm"> * the execution context of the listener. If an</span>
<span class="cm"> * object, this object becomes the execution</span>
<span class="cm"> * context.</span>
<span class="cm"> * @param {boolen} capture capture or bubble phase</span>
<span class="cm"> * @return {Boolean} True if the action was successful or defered,</span>
<span class="cm"> * false if one or more of the elements </span>
<span class="cm"> * could not have the listener attached,</span>
<span class="cm"> * or if the operation throws an exception.</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">_addListener</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">,</span> <span class="nx">bCapture</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">fn</span> <span class="o">||</span> <span class="o">!</span><span class="nx">fn</span><span class="p">.</span><span class="nx">call</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">sType</span> <span class="o">+</span> <span class="s2">" addListener failed, invalid callback"</span><span class="p">,</span> <span class="s2">"error"</span><span class="p">,</span> <span class="s2">"Event"</span><span class="p">);</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// The el argument can be an array of elements or element ids.</span>
<span class="k">if</span> <span class="p">(</span> <span class="k">this</span><span class="p">.</span><span class="nx">_isValidCollection</span><span class="p">(</span><span class="nx">el</span><span class="p">))</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">el</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span><span class="nx">len</span><span class="p">;</span> <span class="o">++</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="nx">el</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span>
<span class="nx">sType</span><span class="p">,</span>
<span class="nx">fn</span><span class="p">,</span>
<span class="nx">obj</span><span class="p">,</span>
<span class="nx">overrideContext</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">ok</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">ok</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">el</span><span class="p">))</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">oEl</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getEl</span><span class="p">(</span><span class="nx">el</span><span class="p">);</span>
<span class="c1">// If the el argument is a string, we assume it is </span>
<span class="c1">// actually the id of the element. If the page is loaded</span>
<span class="c1">// we convert el to the actual element, otherwise we </span>
<span class="c1">// defer attaching the event until onload event fires</span>
<span class="c1">// check to see if we need to delay hooking up the event </span>
<span class="c1">// until after the page loads.</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">oEl</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">el</span> <span class="o">=</span> <span class="nx">oEl</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="c1">// defer adding the event until the element is available</span>
<span class="k">this</span><span class="p">.</span><span class="nx">onAvailable</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Event</span><span class="p">.</span><span class="nx">_addListener</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">,</span> <span class="nx">bCapture</span><span class="p">);</span>
<span class="p">});</span>
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// Element should be an html element or an array if we get </span>
<span class="c1">// here.</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">el</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// this.logger.debug("unable to attach event " + sType);</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// we need to make sure we fire registered unload events </span>
<span class="c1">// prior to automatically unhooking them. So we hang on to </span>
<span class="c1">// these instead of attaching them to the window and fire the</span>
<span class="c1">// handles explicitly during our one unload event.</span>
<span class="k">if</span> <span class="p">(</span><span class="s2">"unload"</span> <span class="o">==</span> <span class="nx">sType</span> <span class="o">&&</span> <span class="nx">obj</span> <span class="o">!==</span> <span class="k">this</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">unloadListeners</span><span class="p">[</span><span class="nx">unloadListeners</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">=</span>
<span class="p">[</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">];</span>
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// this.logger.debug("Adding handler: " + el + ", " + sType);</span>
<span class="c1">// if the user chooses to override the context, we use the custom</span>
<span class="c1">// object passed in, otherwise the executing context will be the</span>
<span class="c1">// HTML element that the event is registered on</span>
<span class="kd">var</span> <span class="nx">context</span> <span class="o">=</span> <span class="nx">el</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">overrideContext</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">overrideContext</span> <span class="o">===</span> <span class="kc">true</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">context</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">context</span> <span class="o">=</span> <span class="nx">overrideContext</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// wrap the function so we can return the obj object when</span>
<span class="c1">// the event fires;</span>
<span class="kd">var</span> <span class="nx">wrappedFn</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">fn</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">context</span><span class="p">,</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Event</span><span class="p">.</span><span class="nx">getEvent</span><span class="p">(</span><span class="nx">e</span><span class="p">,</span> <span class="nx">el</span><span class="p">),</span>
<span class="nx">obj</span><span class="p">);</span>
<span class="p">};</span>
<span class="kd">var</span> <span class="nx">li</span> <span class="o">=</span> <span class="p">[</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">wrappedFn</span><span class="p">,</span> <span class="nx">context</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">,</span> <span class="nx">bCapture</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">listeners</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
<span class="c1">// cache the listener so we can try to automatically unload</span>
<span class="nx">listeners</span><span class="p">[</span><span class="nx">index</span><span class="p">]</span> <span class="o">=</span> <span class="nx">li</span><span class="p">;</span>
<span class="k">try</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_simpleAdd</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">wrappedFn</span><span class="p">,</span> <span class="nx">bCapture</span><span class="p">);</span>
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// handle an error trying to attach an event. If it fails</span>
<span class="c1">// we need to clean up the cache</span>
<span class="k">this</span><span class="p">.</span><span class="nx">lastError</span> <span class="o">=</span> <span class="nx">ex</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">removeListener</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Checks to see if the type requested is a special type </span>
<span class="cm"> * (as defined by the _specialTypes hash), and (if so) returns </span>
<span class="cm"> * the special type name.</span>
<span class="cm"> *</span>
<span class="cm"> * @method _getType</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String} sType The type to look up</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_getType</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_specialTypes</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span> <span class="o">||</span> <span class="nx">type</span><span class="p">;</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Appends an event handler</span>
<span class="cm"> *</span>
<span class="cm"> * @method addListener</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="cm"> * reference, or a collection of ids and/or elements to assign the </span>
<span class="cm"> * listener to.</span>
<span class="cm"> * @param {String} sType The type of event to append</span>
<span class="cm"> * @param {Function} fn The method the event invokes</span>
<span class="cm"> * @param {Object} obj An arbitrary object that will be </span>
<span class="cm"> * passed as a parameter to the handler</span>
<span class="cm"> * @param {Boolean|object} overrideContext If true, the obj passed in becomes</span>
<span class="cm"> * the execution context of the listener. If an</span>
<span class="cm"> * object, this object becomes the execution</span>
<span class="cm"> * context.</span>
<span class="cm"> * @return {Boolean} True if the action was successful or defered,</span>
<span class="cm"> * false if one or more of the elements </span>
<span class="cm"> * could not have the listener attached,</span>
<span class="cm"> * or if the operation throws an exception.</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">addListener</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">capture</span> <span class="o">=</span> <span class="p">((</span><span class="nx">sType</span> <span class="o">==</span> <span class="nx">FOCUSIN</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="nx">FOCUSOUT</span><span class="p">)</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ua</span><span class="p">.</span><span class="nx">ie</span><span class="p">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="p">;</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addListener</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getType</span><span class="p">(</span><span class="nx">sType</span><span class="p">),</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">,</span> <span class="nx">capture</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Attaches a focusin event listener to the specified element for </span>
<span class="cm"> * the purpose of listening for the focus event on the element's </span>
<span class="cm"> * descendants.</span>
<span class="cm"> * @method addFocusListener</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="cm"> * reference, or a collection of ids and/or elements to assign the </span>
<span class="cm"> * listener to.</span>
<span class="cm"> * @param {Function} fn The method the event invokes</span>
<span class="cm"> * @param {Object} obj An arbitrary object that will be </span>
<span class="cm"> * passed as a parameter to the handler</span>
<span class="cm"> * @param {Boolean|object} overrideContext If true, the obj passed in becomes</span>
<span class="cm"> * the execution context of the listener. If an</span>
<span class="cm"> * object, this object becomes the execution</span>
<span class="cm"> * context.</span>
<span class="cm"> * @return {Boolean} True if the action was successful or defered,</span>
<span class="cm"> * false if one or more of the elements </span>
<span class="cm"> * could not have the listener attached,</span>
<span class="cm"> * or if the operation throws an exception.</span>
<span class="cm"> * @static</span>
<span class="cm"> * @deprecated use YAHOO.util.Event.on and specify "focusin" as the event type.</span>
<span class="cm"> */</span>
<span class="nx">addFocusListener</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">FOCUSIN</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Removes a focusin event listener to the specified element for </span>
<span class="cm"> * the purpose of listening for the focus event on the element's </span>
<span class="cm"> * descendants.</span>
<span class="cm"> *</span>
<span class="cm"> * @method removeFocusListener</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="cm"> * reference, or a collection of ids and/or elements to remove</span>
<span class="cm"> * the listener from.</span>
<span class="cm"> * @param {Function} fn the method the event invokes. If fn is</span>
<span class="cm"> * undefined, then all event handlers for the type of event are </span>
<span class="cm"> * removed.</span>
<span class="cm"> * @return {boolean} true if the unbind was successful, false </span>
<span class="cm"> * otherwise.</span>
<span class="cm"> * @static</span>
<span class="cm"> * @deprecated use YAHOO.util.Event.removeListener and specify "focusin" as the event type.</span>
<span class="cm"> */</span>
<span class="nx">removeFocusListener</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">removeListener</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">FOCUSIN</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Attaches a focusout event listener to the specified element for </span>
<span class="cm"> * the purpose of listening for the blur event on the element's </span>
<span class="cm"> * descendants.</span>
<span class="cm"> *</span>
<span class="cm"> * @method addBlurListener</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="cm"> * reference, or a collection of ids and/or elements to assign the </span>
<span class="cm"> * listener to.</span>
<span class="cm"> * @param {Function} fn The method the event invokes</span>
<span class="cm"> * @param {Object} obj An arbitrary object that will be </span>
<span class="cm"> * passed as a parameter to the handler</span>
<span class="cm"> * @param {Boolean|object} overrideContext If true, the obj passed in becomes</span>
<span class="cm"> * the execution context of the listener. If an</span>
<span class="cm"> * object, this object becomes the execution</span>
<span class="cm"> * context.</span>
<span class="cm"> * @return {Boolean} True if the action was successful or defered,</span>
<span class="cm"> * false if one or more of the elements </span>
<span class="cm"> * could not have the listener attached,</span>
<span class="cm"> * or if the operation throws an exception.</span>
<span class="cm"> * @static</span>
<span class="cm"> * @deprecated use YAHOO.util.Event.on and specify "focusout" as the event type.</span>
<span class="cm"> */</span>
<span class="nx">addBlurListener</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">FOCUSOUT</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">overrideContext</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Removes a focusout event listener to the specified element for </span>
<span class="cm"> * the purpose of listening for the blur event on the element's </span>
<span class="cm"> * descendants.</span>
<span class="cm"> *</span>
<span class="cm"> * @method removeBlurListener</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="cm"> * reference, or a collection of ids and/or elements to remove</span>
<span class="cm"> * the listener from.</span>
<span class="cm"> * @param {Function} fn the method the event invokes. If fn is</span>
<span class="cm"> * undefined, then all event handlers for the type of event are </span>
<span class="cm"> * removed.</span>
<span class="cm"> * @return {boolean} true if the unbind was successful, false </span>
<span class="cm"> * otherwise.</span>
<span class="cm"> * @static</span>
<span class="cm"> * @deprecated use YAHOO.util.Event.removeListener and specify "focusout" as the event type.</span>
<span class="cm"> */</span>
<span class="nx">removeBlurListener</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">removeListener</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">FOCUSOUT</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Removes an event listener</span>
<span class="cm"> *</span>
<span class="cm"> * @method removeListener</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="cm"> * reference, or a collection of ids and/or elements to remove</span>
<span class="cm"> * the listener from.</span>
<span class="cm"> * @param {String} sType the type of event to remove.</span>
<span class="cm"> * @param {Function} fn the method the event invokes. If fn is</span>
<span class="cm"> * undefined, then all event handlers for the type of event are </span>
<span class="cm"> * removed.</span>
<span class="cm"> * @return {boolean} true if the unbind was successful, false </span>
<span class="cm"> * otherwise.</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">removeListener</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">len</span><span class="p">,</span> <span class="nx">li</span><span class="p">;</span>
<span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getType</span><span class="p">(</span><span class="nx">sType</span><span class="p">);</span>
<span class="c1">// The el argument can be a string</span>
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">el</span> <span class="o">==</span> <span class="s2">"string"</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">el</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getEl</span><span class="p">(</span><span class="nx">el</span><span class="p">);</span>
<span class="c1">// The el argument can be an array of elements or element ids.</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="k">this</span><span class="p">.</span><span class="nx">_isValidCollection</span><span class="p">(</span><span class="nx">el</span><span class="p">))</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">el</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">>-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">ok</span> <span class="o">=</span> <span class="p">(</span> <span class="k">this</span><span class="p">.</span><span class="nx">removeListener</span><span class="p">(</span><span class="nx">el</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">ok</span> <span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">ok</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">fn</span> <span class="o">||</span> <span class="o">!</span><span class="nx">fn</span><span class="p">.</span><span class="nx">call</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// this.logger.debug("Error, function is not valid " + fn);</span>
<span class="c1">//return false;</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">purgeElement</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">sType</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="s2">"unload"</span> <span class="o">==</span> <span class="nx">sType</span><span class="p">)</span> <span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">unloadListeners</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">>-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">li</span> <span class="o">=</span> <span class="nx">unloadListeners</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">li</span> <span class="o">&&</span>
<span class="nx">li</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="nx">el</span> <span class="o">&&</span>
<span class="nx">li</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="nx">sType</span> <span class="o">&&</span>
<span class="nx">li</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">unloadListeners</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="c1">// unloadListeners[i]=null;</span>
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">cacheItem</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">// The index is a hidden parameter; needed to remove it from</span>
<span class="c1">// the method signature because it was tempting users to</span>
<span class="c1">// try and take advantage of it, which is not possible.</span>
<span class="kd">var</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">arguments</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="s2">"undefined"</span> <span class="o">===</span> <span class="k">typeof</span> <span class="nx">index</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">index</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getCacheIndex</span><span class="p">(</span><span class="nx">listeners</span><span class="p">,</span> <span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">index</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">cacheItem</span> <span class="o">=</span> <span class="nx">listeners</span><span class="p">[</span><span class="nx">index</span><span class="p">];</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">el</span> <span class="o">||</span> <span class="o">!</span><span class="nx">cacheItem</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// this.logger.debug("cached listener not found");</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// this.logger.debug("Removing handler: " + el + ", " + sType);</span>
<span class="kd">var</span> <span class="nx">bCapture</span> <span class="o">=</span> <span class="nx">cacheItem</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">CAPTURE</span><span class="p">]</span> <span class="o">===</span> <span class="kc">true</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="p">;</span>
<span class="k">try</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_simpleRemove</span><span class="p">(</span><span class="nx">el</span><span class="p">,</span> <span class="nx">sType</span><span class="p">,</span> <span class="nx">cacheItem</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">WFN</span><span class="p">],</span> <span class="nx">bCapture</span><span class="p">);</span>
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">lastError</span> <span class="o">=</span> <span class="nx">ex</span><span class="p">;</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// removed the wrapped handler</span>
<span class="k">delete</span> <span class="nx">listeners</span><span class="p">[</span><span class="nx">index</span><span class="p">][</span><span class="k">this</span><span class="p">.</span><span class="nx">WFN</span><span class="p">];</span>
<span class="k">delete</span> <span class="nx">listeners</span><span class="p">[</span><span class="nx">index</span><span class="p">][</span><span class="k">this</span><span class="p">.</span><span class="nx">FN</span><span class="p">];</span>
<span class="nx">listeners</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">index</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="c1">// listeners[index]=null;</span>
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Returns the event's target element. Safari sometimes provides</span>
<span class="cm"> * a text node, and this is automatically resolved to the text</span>
<span class="cm"> * node's parent so that it behaves like other browsers.</span>
<span class="cm"> * @method getTarget</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @param {boolean} resolveTextNode when set to true the target's</span>
<span class="cm"> * parent will be returned if the target is a </span>
<span class="cm"> * text node. @deprecated, the text node is</span>
<span class="cm"> * now resolved automatically</span>
<span class="cm"> * @return {HTMLElement} the event's target</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">getTarget</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">,</span> <span class="nx">resolveTextNode</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">target</span> <span class="o">||</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">srcElement</span><span class="p">;</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">resolveTextNode</span><span class="p">(</span><span class="nx">t</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * In some cases, some browsers will return a text node inside</span>
<span class="cm"> * the actual element that was targeted. This normalizes the</span>
<span class="cm"> * return value for getTarget and getRelatedTarget.</span>
<span class="cm"> * @method resolveTextNode</span>
<span class="cm"> * @param {HTMLElement} node node to resolve</span>
<span class="cm"> * @return {HTMLElement} the normized node</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">resolveTextNode</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">n</span><span class="p">)</span> <span class="p">{</span>
<span class="k">try</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">n</span> <span class="o">&&</span> <span class="mi">3</span> <span class="o">==</span> <span class="nx">n</span><span class="p">.</span><span class="nx">nodeType</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">n</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span>
<span class="k">return</span> <span class="nx">n</span><span class="p">;</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Returns the event's pageX</span>
<span class="cm"> * @method getPageX</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @return {int} the event's pageX</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">getPageX</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">pageX</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">x</span> <span class="o">&&</span> <span class="mi">0</span> <span class="o">!==</span> <span class="nx">x</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">x</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">clientX</span> <span class="o">||</span> <span class="mi">0</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span> <span class="k">this</span><span class="p">.</span><span class="nx">isIE</span> <span class="p">)</span> <span class="p">{</span>
<span class="nx">x</span> <span class="o">+=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getScrollLeft</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">x</span><span class="p">;</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Returns the event's pageY</span>
<span class="cm"> * @method getPageY</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @return {int} the event's pageY</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">getPageY</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">y</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">pageY</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">y</span> <span class="o">&&</span> <span class="mi">0</span> <span class="o">!==</span> <span class="nx">y</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">y</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">clientY</span> <span class="o">||</span> <span class="mi">0</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span> <span class="k">this</span><span class="p">.</span><span class="nx">isIE</span> <span class="p">)</span> <span class="p">{</span>
<span class="nx">y</span> <span class="o">+=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getScrollTop</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">y</span><span class="p">;</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Returns the pageX and pageY properties as an indexed array.</span>
<span class="cm"> * @method getXY</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @return {[x, y]} the pageX and pageY properties of the event</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">getXY</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">getPageX</span><span class="p">(</span><span class="nx">ev</span><span class="p">),</span> <span class="k">this</span><span class="p">.</span><span class="nx">getPageY</span><span class="p">(</span><span class="nx">ev</span><span class="p">)];</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Returns the event's related target </span>
<span class="cm"> * @method getRelatedTarget</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @return {HTMLElement} the event's relatedTarget</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">getRelatedTarget</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">relatedTarget</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">t</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">ev</span><span class="p">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">"mouseout"</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">t</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">toElement</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">ev</span><span class="p">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">"mouseover"</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">t</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">fromElement</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">resolveTextNode</span><span class="p">(</span><span class="nx">t</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Returns the time of the event. If the time is not included, the</span>
<span class="cm"> * event is modified using the current time.</span>
<span class="cm"> * @method getTime</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @return {Date} the time of the event</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">getTime</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">ev</span><span class="p">.</span><span class="nx">time</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">().</span><span class="nx">getTime</span><span class="p">();</span>
<span class="k">try</span> <span class="p">{</span>
<span class="nx">ev</span><span class="p">.</span><span class="nx">time</span> <span class="o">=</span> <span class="nx">t</span><span class="p">;</span>
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">lastError</span> <span class="o">=</span> <span class="nx">ex</span><span class="p">;</span>
<span class="k">return</span> <span class="nx">t</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">time</span><span class="p">;</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Convenience method for stopPropagation + preventDefault</span>
<span class="cm"> * @method stopEvent</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">stopEvent</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">stopPropagation</span><span class="p">(</span><span class="nx">ev</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">(</span><span class="nx">ev</span><span class="p">);</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Stops event propagation</span>
<span class="cm"> * @method stopPropagation</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">stopPropagation</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">ev</span><span class="p">.</span><span class="nx">stopPropagation</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">ev</span><span class="p">.</span><span class="nx">stopPropagation</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">ev</span><span class="p">.</span><span class="nx">cancelBubble</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="cm">/**</span>
<span class="cm"> * Prevents the default behavior of the event</span>
<span class="cm"> * @method preventDefault</span>
<span class="cm"> * @param {Event} ev the event</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">preventDefault</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">ev</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">ev</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>