Revision 1374
Added by Dietmar over 13 years ago
event.js | ||
---|---|---|
32 | 32 |
|
33 | 33 |
/** |
34 | 34 |
* The type of event, returned to subscribers when the event fires |
35 |
* @property type
|
|
36 |
* @type string
|
|
35 |
* @property type |
|
36 |
* @type string |
|
37 | 37 |
*/ |
38 | 38 |
this.type = type; |
39 | 39 |
|
40 | 40 |
/** |
41 | 41 |
* The context the event will fire from by default. Defaults to the window obj. |
42 |
* @property scope
|
|
43 |
* @type object
|
|
42 |
* @property scope |
|
43 |
* @type object |
|
44 | 44 |
*/ |
45 | 45 |
this.scope = context || window; |
46 | 46 |
|
47 | 47 |
/** |
48 | 48 |
* By default all custom events are logged in the debug build. Set silent to true |
49 | 49 |
* to disable debug output for this event. |
50 |
* @property silent
|
|
51 |
* @type boolean
|
|
50 |
* @property silent |
|
51 |
* @type boolean |
|
52 | 52 |
*/ |
53 | 53 |
this.silent = silent; |
54 | 54 |
|
... | ... | |
57 | 57 |
* a single time regardless of how many times the event is fired. In addition, |
58 | 58 |
* new subscribers will be notified immediately if the event has already been |
59 | 59 |
* fired. |
60 |
* @property fireOnce
|
|
61 |
* @type boolean
|
|
62 |
* @default false
|
|
60 |
* @property fireOnce |
|
61 |
* @type boolean |
|
62 |
* @default false |
|
63 | 63 |
*/ |
64 | 64 |
this.fireOnce = fireOnce; |
65 | 65 |
|
66 | 66 |
/** |
67 | 67 |
* Indicates whether or not this event has ever been fired. |
68 |
* @property fired
|
|
69 |
* @type boolean
|
|
70 |
* @default false
|
|
68 |
* @property fired |
|
69 |
* @type boolean |
|
70 |
* @default false |
|
71 | 71 |
*/ |
72 | 72 |
this.fired = false; |
73 | 73 |
|
74 | 74 |
/** |
75 | 75 |
* For fireOnce events the arguments the event was fired with are stored |
76 | 76 |
* so that new subscribers get the proper payload. |
77 |
* @property firedWith
|
|
78 |
* @type Array
|
|
77 |
* @property firedWith |
|
78 |
* @type Array |
|
79 | 79 |
*/ |
80 | 80 |
this.firedWith = null; |
81 | 81 |
|
... | ... | |
105 | 105 |
|
106 | 106 |
/** |
107 | 107 |
* The subscribers to this event |
108 |
* @property subscribers
|
|
109 |
* @type Subscriber[]
|
|
108 |
* @property subscribers |
|
109 |
* @type Subscriber[] |
|
110 | 110 |
*/ |
111 | 111 |
this.subscribers = []; |
112 | 112 |
|
... | ... | |
125 | 125 |
* handle the case where there is a non-repeating event that has |
126 | 126 |
* already fired has a new subscriber. |
127 | 127 |
* |
128 |
* @event subscribeEvent
|
|
129 |
* @type YAHOO.util.CustomEvent
|
|
130 |
* @param fn {Function} The function to execute
|
|
131 |
* @param obj <Object> An object to be passed along when the event fires.
|
|
128 |
* @event subscribeEvent |
|
129 |
* @type YAHOO.util.CustomEvent |
|
130 |
* @param fn {Function} The function to execute |
|
131 |
* @param obj <Object> An object to be passed along when the event fires. |
|
132 | 132 |
* Defaults to the custom event. |
133 |
* @param override <boolean|Object> If true, the obj passed in becomes the
|
|
133 |
* @param override <boolean|Object> If true, the obj passed in becomes the |
|
134 | 134 |
* execution context of the listener. If an object, that object becomes |
135 | 135 |
* the execution context. Defaults to the custom event. |
136 | 136 |
*/ |
... | ... | |
144 | 144 |
* In order to make it possible to execute the rest of the subscriber |
145 | 145 |
* stack when one thows an exception, the subscribers exceptions are |
146 | 146 |
* caught. The most recent exception is stored in this property |
147 |
* @property lastError
|
|
148 |
* @type Error
|
|
147 |
* @property lastError |
|
148 |
* @type Error |
|
149 | 149 |
*/ |
150 | 150 |
this.lastError = null; |
151 | 151 |
}; |
... | ... | |
174 | 174 |
|
175 | 175 |
/** |
176 | 176 |
* Subscribes the caller to this event |
177 |
* @method subscribe
|
|
178 |
* @param {Function} fn The function to execute
|
|
179 |
* @param {Object} obj An object to be passed along when the event fires.
|
|
177 |
* @method subscribe |
|
178 |
* @param {Function} fn The function to execute |
|
179 |
* @param {Object} obj An object to be passed along when the event fires. |
|
180 | 180 |
* overrideContext <boolean|Object> If true, the obj passed in becomes the execution |
181 | 181 |
* context of the listener. If an object, that object becomes the execution context. |
182 | 182 |
*/ |
... | ... | |
201 | 201 |
|
202 | 202 |
/** |
203 | 203 |
* Unsubscribes subscribers. |
204 |
* @method unsubscribe
|
|
205 |
* @param {Function} fn The subscribed function to remove, if not supplied
|
|
204 |
* @method unsubscribe |
|
205 |
* @param {Function} fn The subscribed function to remove, if not supplied |
|
206 | 206 |
* all will be removed |
207 |
* @param {Object} obj The custom object passed to subscribe. This is
|
|
207 |
* @param {Object} obj The custom object passed to subscribe. This is |
|
208 | 208 |
* optional, but if supplied will be used to |
209 | 209 |
* disambiguate multiple listeners that are the same |
210 | 210 |
* (e.g., you subscribe many object using a function |
211 | 211 |
* that lives on the prototype) |
212 |
* @return {boolean} True if the subscriber was found and detached.
|
|
212 |
* @return {boolean} True if the subscriber was found and detached. |
|
213 | 213 |
*/ |
214 | 214 |
unsubscribe: function(fn, obj) { |
215 | 215 |
|
... | ... | |
239 | 239 |
* <li>The custom object (if any) that was passed into the subscribe() |
240 | 240 |
* method</li> |
241 | 241 |
* </ul> |
242 |
* @method fire
|
|
243 |
* @param {Object*} arguments an arbitrary set of parameters to pass to
|
|
242 |
* @method fire |
|
243 |
* @param {Object*} arguments an arbitrary set of parameters to pass to |
|
244 | 244 |
* the handler. |
245 |
* @return {boolean} false if one of the subscribers returned false,
|
|
245 |
* @return {boolean} false if one of the subscribers returned false, |
|
246 | 246 |
* true otherwise |
247 | 247 |
*/ |
248 | 248 |
fire: function() { |
... | ... | |
335 | 335 |
|
336 | 336 |
/** |
337 | 337 |
* Removes all listeners |
338 |
* @method unsubscribeAll
|
|
339 |
* @return {int} The number of listeners unsubscribed
|
|
338 |
* @method unsubscribeAll |
|
339 |
* @return {int} The number of listeners unsubscribed |
|
340 | 340 |
*/ |
341 | 341 |
unsubscribeAll: function() { |
342 | 342 |
var l = this.subscribers.length, i; |
... | ... | |
350 | 350 |
}, |
351 | 351 |
|
352 | 352 |
/** |
353 |
* @method _delete
|
|
354 |
* @private
|
|
353 |
* @method _delete |
|
354 |
* @private |
|
355 | 355 |
*/ |
356 | 356 |
_delete: function(index) { |
357 | 357 |
var s = this.subscribers[index]; |
... | ... | |
365 | 365 |
}, |
366 | 366 |
|
367 | 367 |
/** |
368 |
* @method toString
|
|
368 |
* @method toString |
|
369 | 369 |
*/ |
370 | 370 |
toString: function() { |
371 | 371 |
return "CustomEvent: " + "'" + this.type + "', " + |
... | ... | |
389 | 389 |
|
390 | 390 |
/** |
391 | 391 |
* The callback that will be execute when the event fires |
392 |
* @property fn
|
|
393 |
* @type function
|
|
392 |
* @property fn |
|
393 |
* @type function |
|
394 | 394 |
*/ |
395 | 395 |
this.fn = fn; |
396 | 396 |
|
397 | 397 |
/** |
398 | 398 |
* An optional custom object that will passed to the callback when |
399 | 399 |
* the event fires |
400 |
* @property obj
|
|
401 |
* @type object
|
|
400 |
* @property obj |
|
401 |
* @type object |
|
402 | 402 |
*/ |
403 | 403 |
this.obj = YAHOO.lang.isUndefined(obj) ? null : obj; |
404 | 404 |
|
... | ... | |
408 | 408 |
* By setting overrideContext to true, the execution context becomes the custom |
409 | 409 |
* object passed in by the subscriber. If overrideContext is an object, that |
410 | 410 |
* object becomes the context. |
411 |
* @property overrideContext
|
|
412 |
* @type boolean|object
|
|
411 |
* @property overrideContext |
|
412 |
* @type boolean|object |
|
413 | 413 |
*/ |
414 | 414 |
this.overrideContext = overrideContext; |
415 | 415 |
|
... | ... | |
488 | 488 |
|
489 | 489 |
/** |
490 | 490 |
* True after the onload event has fired |
491 |
* @property loadComplete
|
|
492 |
* @type boolean
|
|
493 |
* @static
|
|
494 |
* @private
|
|
491 |
* @property loadComplete |
|
492 |
* @type boolean |
|
493 |
* @static |
|
494 |
* @private |
|
495 | 495 |
*/ |
496 | 496 |
var loadComplete = false, |
497 | 497 |
|
498 | 498 |
/** |
499 | 499 |
* Cache of wrapped listeners |
500 |
* @property listeners
|
|
501 |
* @type array
|
|
502 |
* @static
|
|
503 |
* @private
|
|
500 |
* @property listeners |
|
501 |
* @type array |
|
502 |
* @static |
|
503 |
* @private |
|
504 | 504 |
*/ |
505 | 505 |
listeners = [], |
506 | 506 |
|
... | ... | |
508 | 508 |
/** |
509 | 509 |
* User-defined unload function that will be fired before all events |
510 | 510 |
* are detached |
511 |
* @property unloadListeners
|
|
512 |
* @type array
|
|
513 |
* @static
|
|
514 |
* @private
|
|
511 |
* @property unloadListeners |
|
512 |
* @type array |
|
513 |
* @static |
|
514 |
* @private |
|
515 | 515 |
*/ |
516 | 516 |
unloadListeners = [], |
517 | 517 |
|
... | ... | |
519 | 519 |
* The number of times to poll after window.onload. This number is |
520 | 520 |
* increased if additional late-bound handlers are requested after |
521 | 521 |
* the page load. |
522 |
* @property retryCount
|
|
523 |
* @static
|
|
524 |
* @private
|
|
522 |
* @property retryCount |
|
523 |
* @static |
|
524 |
* @private |
|
525 | 525 |
*/ |
526 | 526 |
retryCount = 0, |
527 | 527 |
|
528 | 528 |
/** |
529 | 529 |
* onAvailable listeners |
530 |
* @property onAvailStack
|
|
531 |
* @static
|
|
532 |
* @private
|
|
530 |
* @property onAvailStack |
|
531 |
* @static |
|
532 |
* @private |
|
533 | 533 |
*/ |
534 | 534 |
onAvailStack = [], |
535 | 535 |
|
536 | 536 |
/** |
537 | 537 |
* Counter for auto id generation |
538 |
* @property counter
|
|
539 |
* @static
|
|
540 |
* @private
|
|
538 |
* @property counter |
|
539 |
* @static |
|
540 |
* @private |
|
541 | 541 |
*/ |
542 | 542 |
counter = 0, |
543 | 543 |
|
544 | 544 |
/** |
545 | 545 |
* Normalized keycodes for webkit/safari |
546 |
* @property webkitKeymap
|
|
547 |
* @type {int: int}
|
|
548 |
* @private
|
|
549 |
* @static
|
|
550 |
* @final
|
|
546 |
* @property webkitKeymap |
|
547 |
* @type {int: int} |
|
548 |
* @private |
|
549 |
* @static |
|
550 |
* @final |
|
551 | 551 |
*/ |
552 | 552 |
webkitKeymap = { |
553 | 553 |
63232: 38, // up |
... | ... | |
575 | 575 |
* has been loaded. The default is 500@amp;40 ms, so it will poll |
576 | 576 |
* for 20 seconds or until all outstanding handlers are bound |
577 | 577 |
* (whichever comes first). |
578 |
* @property POLL_RETRYS
|
|
579 |
* @type int
|
|
580 |
* @static
|
|
581 |
* @final
|
|
578 |
* @property POLL_RETRYS |
|
579 |
* @type int |
|
580 |
* @static |
|
581 |
* @final |
|
582 | 582 |
*/ |
583 | 583 |
POLL_RETRYS: 500, |
584 | 584 |
|
585 | 585 |
/** |
586 | 586 |
* The poll interval in milliseconds |
587 |
* @property POLL_INTERVAL
|
|
588 |
* @type int
|
|
589 |
* @static
|
|
590 |
* @final
|
|
587 |
* @property POLL_INTERVAL |
|
588 |
* @type int |
|
589 |
* @static |
|
590 |
* @final |
|
591 | 591 |
*/ |
592 | 592 |
POLL_INTERVAL: 40, |
593 | 593 |
|
594 | 594 |
/** |
595 | 595 |
* Element to bind, int constant |
596 |
* @property EL
|
|
597 |
* @type int
|
|
598 |
* @static
|
|
599 |
* @final
|
|
596 |
* @property EL |
|
597 |
* @type int |
|
598 |
* @static |
|
599 |
* @final |
|
600 | 600 |
*/ |
601 | 601 |
EL: 0, |
602 | 602 |
|
603 | 603 |
/** |
604 | 604 |
* Type of event, int constant |
605 |
* @property TYPE
|
|
606 |
* @type int
|
|
607 |
* @static
|
|
608 |
* @final
|
|
605 |
* @property TYPE |
|
606 |
* @type int |
|
607 |
* @static |
|
608 |
* @final |
|
609 | 609 |
*/ |
610 | 610 |
TYPE: 1, |
611 | 611 |
|
612 | 612 |
/** |
613 | 613 |
* Function to execute, int constant |
614 |
* @property FN
|
|
615 |
* @type int
|
|
616 |
* @static
|
|
617 |
* @final
|
|
614 |
* @property FN |
|
615 |
* @type int |
|
616 |
* @static |
|
617 |
* @final |
|
618 | 618 |
*/ |
619 | 619 |
FN: 2, |
620 | 620 |
|
621 | 621 |
/** |
622 | 622 |
* Function wrapped for context correction and cleanup, int constant |
623 |
* @property WFN
|
|
624 |
* @type int
|
|
625 |
* @static
|
|
626 |
* @final
|
|
623 |
* @property WFN |
|
624 |
* @type int |
|
625 |
* @static |
|
626 |
* @final |
|
627 | 627 |
*/ |
628 | 628 |
WFN: 3, |
629 | 629 |
|
... | ... | |
631 | 631 |
* Object passed in by the user that will be returned as a |
632 | 632 |
* parameter to the callback, int constant. Specific to |
633 | 633 |
* unload listeners |
634 |
* @property OBJ
|
|
635 |
* @type int
|
|
636 |
* @static
|
|
637 |
* @final
|
|
634 |
* @property OBJ |
|
635 |
* @type int |
|
636 |
* @static |
|
637 |
* @final |
|
638 | 638 |
*/ |
639 | 639 |
UNLOAD_OBJ: 3, |
640 | 640 |
|
641 | 641 |
/** |
642 | 642 |
* Adjusted context, either the element we are registering the event |
643 | 643 |
* on or the custom object passed in by the listener, int constant |
644 |
* @property ADJ_SCOPE
|
|
645 |
* @type int
|
|
646 |
* @static
|
|
647 |
* @final
|
|
644 |
* @property ADJ_SCOPE |
|
645 |
* @type int |
|
646 |
* @static |
|
647 |
* @final |
|
648 | 648 |
*/ |
649 | 649 |
ADJ_SCOPE: 4, |
650 | 650 |
|
651 | 651 |
/** |
652 | 652 |
* The original obj passed into addListener |
653 |
* @property OBJ
|
|
654 |
* @type int
|
|
655 |
* @static
|
|
656 |
* @final
|
|
653 |
* @property OBJ |
|
654 |
* @type int |
|
655 |
* @static |
|
656 |
* @final |
|
657 | 657 |
*/ |
658 | 658 |
OBJ: 5, |
659 | 659 |
|
660 | 660 |
/** |
661 | 661 |
* The original context parameter passed into addListener |
662 |
* @property OVERRIDE
|
|
663 |
* @type int
|
|
664 |
* @static
|
|
665 |
* @final
|
|
662 |
* @property OVERRIDE |
|
663 |
* @type int |
|
664 |
* @static |
|
665 |
* @final |
|
666 | 666 |
*/ |
667 | 667 |
OVERRIDE: 6, |
668 | 668 |
|
669 | 669 |
/** |
670 | 670 |
* The original capture parameter passed into addListener |
671 |
* @property CAPTURE
|
|
672 |
* @type int
|
|
673 |
* @static
|
|
674 |
* @final
|
|
671 |
* @property CAPTURE |
|
672 |
* @type int |
|
673 |
* @static |
|
674 |
* @final |
|
675 | 675 |
*/ |
676 | 676 |
CAPTURE: 7, |
677 | 677 |
|
... | ... | |
679 | 679 |
* addListener/removeListener can throw errors in unexpected scenarios. |
680 | 680 |
* These errors are suppressed, the method returns false, and this property |
681 | 681 |
* is set |
682 |
* @property lastError
|
|
683 |
* @static
|
|
684 |
* @type Error
|
|
682 |
* @property lastError |
|
683 |
* @static |
|
684 |
* @type Error |
|
685 | 685 |
*/ |
686 | 686 |
lastError: null, |
687 | 687 |
|
688 | 688 |
/** |
689 | 689 |
* Safari detection |
690 |
* @property isSafari
|
|
691 |
* @private
|
|
692 |
* @static
|
|
693 |
* @deprecated use YAHOO.env.ua.webkit
|
|
690 |
* @property isSafari |
|
691 |
* @private |
|
692 |
* @static |
|
693 |
* @deprecated use YAHOO.env.ua.webkit |
|
694 | 694 |
*/ |
695 | 695 |
isSafari: YAHOO.env.ua.webkit, |
696 | 696 |
|
697 | 697 |
/** |
698 | 698 |
* webkit version |
699 |
* @property webkit
|
|
700 |
* @type string
|
|
701 |
* @private
|
|
702 |
* @static
|
|
703 |
* @deprecated use YAHOO.env.ua.webkit
|
|
699 |
* @property webkit |
|
700 |
* @type string |
|
701 |
* @private |
|
702 |
* @static |
|
703 |
* @deprecated use YAHOO.env.ua.webkit |
|
704 | 704 |
*/ |
705 | 705 |
webkit: YAHOO.env.ua.webkit, |
706 | 706 |
|
707 | 707 |
/** |
708 | 708 |
* IE detection |
709 |
* @property isIE
|
|
710 |
* @private
|
|
711 |
* @static
|
|
712 |
* @deprecated use YAHOO.env.ua.ie
|
|
709 |
* @property isIE |
|
710 |
* @private |
|
711 |
* @static |
|
712 |
* @deprecated use YAHOO.env.ua.ie |
|
713 | 713 |
*/ |
714 | 714 |
isIE: isIE, |
715 | 715 |
|
716 | 716 |
/** |
717 | 717 |
* poll handle |
718 |
* @property _interval
|
|
719 |
* @static
|
|
720 |
* @private
|
|
718 |
* @property _interval |
|
719 |
* @static |
|
720 |
* @private |
|
721 | 721 |
*/ |
722 | 722 |
_interval: null, |
723 | 723 |
|
724 | 724 |
/** |
725 | 725 |
* document readystate poll handle |
726 |
* @property _dri
|
|
727 |
* @static
|
|
728 |
* @private
|
|
726 |
* @property _dri |
|
727 |
* @static |
|
728 |
* @private |
|
729 | 729 |
*/ |
730 | 730 |
_dri: null, |
731 | 731 |
|
732 | 732 |
|
733 | 733 |
/** |
734 | 734 |
* Map of special event types |
735 |
* @property _specialTypes
|
|
736 |
* @static
|
|
737 |
* @private
|
|
735 |
* @property _specialTypes |
|
736 |
* @static |
|
737 |
* @private |
|
738 | 738 |
*/ |
739 | 739 |
_specialTypes: { |
740 | 740 |
focusin: (isIE ? "focusin" : "focus"), |
... | ... | |
744 | 744 |
|
745 | 745 |
/** |
746 | 746 |
* True when the document is initially usable |
747 |
* @property DOMReady
|
|
748 |
* @type boolean
|
|
749 |
* @static
|
|
747 |
* @property DOMReady |
|
748 |
* @type boolean |
|
749 |
* @static |
|
750 | 750 |
*/ |
751 | 751 |
DOMReady: false, |
752 | 752 |
|
... | ... | |
755 | 755 |
* and the error message is written to the debug console. If |
756 | 756 |
* this property is set to true, it will also re-throw the |
757 | 757 |
* error. |
758 |
* @property throwErrors
|
|
759 |
* @type boolean
|
|
760 |
* @default false
|
|
758 |
* @property throwErrors |
|
759 |
* @type boolean |
|
760 |
* @default false |
|
761 | 761 |
*/ |
762 | 762 |
throwErrors: false, |
763 | 763 |
|
764 | 764 |
|
765 | 765 |
/** |
766 |
* @method startInterval
|
|
767 |
* @static
|
|
768 |
* @private
|
|
766 |
* @method startInterval |
|
767 |
* @static |
|
768 |
* @private |
|
769 | 769 |
*/ |
770 | 770 |
startInterval: function() { |
771 | 771 |
if (!this._interval) { |
... | ... | |
787 | 787 |
* <p>The callback is executed with a single parameter: |
788 | 788 |
* the custom object parameter, if provided.</p> |
789 | 789 |
* |
790 |
* @method onAvailable
|
|
790 |
* @method onAvailable |
|
791 | 791 |
* |
792 |
* @param {string||string[]} id the id of the element, or an array
|
|
792 |
* @param {string||string[]} id the id of the element, or an array |
|
793 | 793 |
* of ids to look for. |
794 |
* @param {function} fn what to execute when the element is found.
|
|
795 |
* @param {object} obj an optional object to be passed back as
|
|
794 |
* @param {function} fn what to execute when the element is found. |
|
795 |
* @param {object} obj an optional object to be passed back as |
|
796 | 796 |
* a parameter to fn. |
797 |
* @param {boolean|object} overrideContext If set to true, fn will execute
|
|
797 |
* @param {boolean|object} overrideContext If set to true, fn will execute |
|
798 | 798 |
* in the context of obj, if set to an object it |
799 | 799 |
* will execute in the context of that object |
800 |
* @param checkContent {boolean} check child node readiness (onContentReady)
|
|
801 |
* @static
|
|
800 |
* @param checkContent {boolean} check child node readiness (onContentReady) |
|
801 |
* @static |
|
802 | 802 |
*/ |
803 | 803 |
onAvailable: function(id, fn, obj, overrideContext, checkContent) { |
804 | 804 |
|
... | ... | |
825 | 825 |
* <p>The callback is executed with a single parameter: |
826 | 826 |
* the custom object parameter, if provided.</p> |
827 | 827 |
* |
828 |
* @method onContentReady
|
|
828 |
* @method onContentReady |
|
829 | 829 |
* |
830 |
* @param {string} id the id of the element to look for.
|
|
831 |
* @param {function} fn what to execute when the element is ready.
|
|
832 |
* @param {object} obj an optional object to be passed back as
|
|
830 |
* @param {string} id the id of the element to look for. |
|
831 |
* @param {function} fn what to execute when the element is ready. |
|
832 |
* @param {object} obj an optional object to be passed back as |
|
833 | 833 |
* a parameter to fn. |
834 |
* @param {boolean|object} overrideContext If set to true, fn will execute
|
|
834 |
* @param {boolean|object} overrideContext If set to true, fn will execute |
|
835 | 835 |
* in the context of obj. If an object, fn will |
836 | 836 |
* exectute in the context of that object |
837 | 837 |
* |
838 |
* @static
|
|
838 |
* @static |
|
839 | 839 |
*/ |
840 | 840 |
onContentReady: function(id, fn, obj, overrideContext) { |
841 | 841 |
this.onAvailable(id, fn, obj, overrideContext, true); |
... | ... | |
862 | 862 |
* <p>"DOMReady", [], obj</p> |
863 | 863 |
* |
864 | 864 |
* |
865 |
* @method onDOMReady
|
|
865 |
* @method onDOMReady |
|
866 | 866 |
* |
867 |
* @param {function} fn what to execute when the element is found.
|
|
868 |
* @param {object} obj an optional object to be passed back as
|
|
867 |
* @param {function} fn what to execute when the element is found. |
|
868 |
* @param {object} obj an optional object to be passed back as |
|
869 | 869 |
* a parameter to fn. |
870 |
* @param {boolean|object} overrideContext If set to true, fn will execute
|
|
870 |
* @param {boolean|object} overrideContext If set to true, fn will execute |
|
871 | 871 |
* in the context of obj, if set to an object it |
872 | 872 |
* will execute in the context of that object |
873 | 873 |
* |
874 |
* @static
|
|
874 |
* @static |
|
875 | 875 |
*/ |
876 | 876 |
// onDOMReady: function(fn, obj, overrideContext) { |
877 | 877 |
onDOMReady: function() { |
... | ... | |
882 | 882 |
/** |
883 | 883 |
* Appends an event handler |
884 | 884 |
* |
885 |
* @method _addListener
|
|
885 |
* @method _addListener |
|
886 | 886 |
* |
887 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
887 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
888 | 888 |
* reference, or a collection of ids and/or elements to assign the |
889 | 889 |
* listener to. |
890 |
* @param {String} sType The type of event to append
|
|
891 |
* @param {Function} fn The method the event invokes
|
|
892 |
* @param {Object} obj An arbitrary object that will be
|
|
890 |
* @param {String} sType The type of event to append |
|
891 |
* @param {Function} fn The method the event invokes |
|
892 |
* @param {Object} obj An arbitrary object that will be |
|
893 | 893 |
* passed as a parameter to the handler |
894 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
894 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
895 | 895 |
* the execution context of the listener. If an |
896 | 896 |
* object, this object becomes the execution |
897 | 897 |
* context. |
898 |
* @param {boolen} capture capture or bubble phase
|
|
899 |
* @return {Boolean} True if the action was successful or defered,
|
|
898 |
* @param {boolen} capture capture or bubble phase |
|
899 |
* @return {Boolean} True if the action was successful or defered, |
|
900 | 900 |
* false if one or more of the elements |
901 | 901 |
* could not have the listener attached, |
902 | 902 |
* or if the operation throws an exception. |
903 |
* @private
|
|
904 |
* @static
|
|
903 |
* @private |
|
904 |
* @static |
|
905 | 905 |
*/ |
906 | 906 |
_addListener: function(el, sType, fn, obj, overrideContext, bCapture) { |
907 | 907 |
|
... | ... | |
1002 | 1002 |
* (as defined by the _specialTypes hash), and (if so) returns |
1003 | 1003 |
* the special type name. |
1004 | 1004 |
* |
1005 |
* @method _getType
|
|
1005 |
* @method _getType |
|
1006 | 1006 |
* |
1007 |
* @param {String} sType The type to look up
|
|
1008 |
* @private
|
|
1007 |
* @param {String} sType The type to look up |
|
1008 |
* @private |
|
1009 | 1009 |
*/ |
1010 | 1010 |
_getType: function (type) { |
1011 | 1011 |
|
... | ... | |
1017 | 1017 |
/** |
1018 | 1018 |
* Appends an event handler |
1019 | 1019 |
* |
1020 |
* @method addListener
|
|
1020 |
* @method addListener |
|
1021 | 1021 |
* |
1022 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1022 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1023 | 1023 |
* reference, or a collection of ids and/or elements to assign the |
1024 | 1024 |
* listener to. |
1025 |
* @param {String} sType The type of event to append
|
|
1026 |
* @param {Function} fn The method the event invokes
|
|
1027 |
* @param {Object} obj An arbitrary object that will be
|
|
1025 |
* @param {String} sType The type of event to append |
|
1026 |
* @param {Function} fn The method the event invokes |
|
1027 |
* @param {Object} obj An arbitrary object that will be |
|
1028 | 1028 |
* passed as a parameter to the handler |
1029 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
1029 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
1030 | 1030 |
* the execution context of the listener. If an |
1031 | 1031 |
* object, this object becomes the execution |
1032 | 1032 |
* context. |
1033 |
* @return {Boolean} True if the action was successful or defered,
|
|
1033 |
* @return {Boolean} True if the action was successful or defered, |
|
1034 | 1034 |
* false if one or more of the elements |
1035 | 1035 |
* could not have the listener attached, |
1036 | 1036 |
* or if the operation throws an exception. |
1037 |
* @static
|
|
1037 |
* @static |
|
1038 | 1038 |
*/ |
1039 | 1039 |
addListener: function (el, sType, fn, obj, overrideContext) { |
1040 | 1040 |
|
... | ... | |
1049 | 1049 |
* Attaches a focusin event listener to the specified element for |
1050 | 1050 |
* the purpose of listening for the focus event on the element's |
1051 | 1051 |
* descendants. |
1052 |
* @method addFocusListener
|
|
1052 |
* @method addFocusListener |
|
1053 | 1053 |
* |
1054 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1054 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1055 | 1055 |
* reference, or a collection of ids and/or elements to assign the |
1056 | 1056 |
* listener to. |
1057 |
* @param {Function} fn The method the event invokes
|
|
1058 |
* @param {Object} obj An arbitrary object that will be
|
|
1057 |
* @param {Function} fn The method the event invokes |
|
1058 |
* @param {Object} obj An arbitrary object that will be |
|
1059 | 1059 |
* passed as a parameter to the handler |
1060 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
1060 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
1061 | 1061 |
* the execution context of the listener. If an |
1062 | 1062 |
* object, this object becomes the execution |
1063 | 1063 |
* context. |
1064 |
* @return {Boolean} True if the action was successful or defered,
|
|
1064 |
* @return {Boolean} True if the action was successful or defered, |
|
1065 | 1065 |
* false if one or more of the elements |
1066 | 1066 |
* could not have the listener attached, |
1067 | 1067 |
* or if the operation throws an exception. |
1068 |
* @static
|
|
1068 |
* @static |
|
1069 | 1069 |
* @deprecated use YAHOO.util.Event.on and specify "focusin" as the event type. |
1070 | 1070 |
*/ |
1071 | 1071 |
addFocusListener: function (el, fn, obj, overrideContext) { |
... | ... | |
1078 | 1078 |
* the purpose of listening for the focus event on the element's |
1079 | 1079 |
* descendants. |
1080 | 1080 |
* |
1081 |
* @method removeFocusListener
|
|
1081 |
* @method removeFocusListener |
|
1082 | 1082 |
* |
1083 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1083 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1084 | 1084 |
* reference, or a collection of ids and/or elements to remove |
1085 | 1085 |
* the listener from. |
1086 |
* @param {Function} fn the method the event invokes. If fn is
|
|
1086 |
* @param {Function} fn the method the event invokes. If fn is |
|
1087 | 1087 |
* undefined, then all event handlers for the type of event are |
1088 | 1088 |
* removed. |
1089 |
* @return {boolean} true if the unbind was successful, false
|
|
1089 |
* @return {boolean} true if the unbind was successful, false |
|
1090 | 1090 |
* otherwise. |
1091 |
* @static
|
|
1091 |
* @static |
|
1092 | 1092 |
* @deprecated use YAHOO.util.Event.removeListener and specify "focusin" as the event type. |
1093 | 1093 |
*/ |
1094 | 1094 |
removeFocusListener: function (el, fn) { |
... | ... | |
1100 | 1100 |
* the purpose of listening for the blur event on the element's |
1101 | 1101 |
* descendants. |
1102 | 1102 |
* |
1103 |
* @method addBlurListener
|
|
1103 |
* @method addBlurListener |
|
1104 | 1104 |
* |
1105 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1105 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1106 | 1106 |
* reference, or a collection of ids and/or elements to assign the |
1107 | 1107 |
* listener to. |
1108 |
* @param {Function} fn The method the event invokes
|
|
1109 |
* @param {Object} obj An arbitrary object that will be
|
|
1108 |
* @param {Function} fn The method the event invokes |
|
1109 |
* @param {Object} obj An arbitrary object that will be |
|
1110 | 1110 |
* passed as a parameter to the handler |
1111 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
1111 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
1112 | 1112 |
* the execution context of the listener. If an |
1113 | 1113 |
* object, this object becomes the execution |
1114 | 1114 |
* context. |
1115 |
* @return {Boolean} True if the action was successful or defered,
|
|
1115 |
* @return {Boolean} True if the action was successful or defered, |
|
1116 | 1116 |
* false if one or more of the elements |
1117 | 1117 |
* could not have the listener attached, |
1118 | 1118 |
* or if the operation throws an exception. |
1119 |
* @static
|
|
1119 |
* @static |
|
1120 | 1120 |
* @deprecated use YAHOO.util.Event.on and specify "focusout" as the event type. |
1121 | 1121 |
*/ |
1122 | 1122 |
addBlurListener: function (el, fn, obj, overrideContext) { |
... | ... | |
1128 | 1128 |
* the purpose of listening for the blur event on the element's |
1129 | 1129 |
* descendants. |
1130 | 1130 |
* |
1131 |
* @method removeBlurListener
|
|
1131 |
* @method removeBlurListener |
|
1132 | 1132 |
* |
1133 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1133 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1134 | 1134 |
* reference, or a collection of ids and/or elements to remove |
1135 | 1135 |
* the listener from. |
1136 |
* @param {Function} fn the method the event invokes. If fn is
|
|
1136 |
* @param {Function} fn the method the event invokes. If fn is |
|
1137 | 1137 |
* undefined, then all event handlers for the type of event are |
1138 | 1138 |
* removed. |
1139 |
* @return {boolean} true if the unbind was successful, false
|
|
1139 |
* @return {boolean} true if the unbind was successful, false |
|
1140 | 1140 |
* otherwise. |
1141 |
* @static
|
|
1141 |
* @static |
|
1142 | 1142 |
* @deprecated use YAHOO.util.Event.removeListener and specify "focusout" as the event type. |
1143 | 1143 |
*/ |
1144 | 1144 |
removeBlurListener: function (el, fn) { |
... | ... | |
1148 | 1148 |
/** |
1149 | 1149 |
* Removes an event listener |
1150 | 1150 |
* |
1151 |
* @method removeListener
|
|
1151 |
* @method removeListener |
|
1152 | 1152 |
* |
1153 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1153 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1154 | 1154 |
* reference, or a collection of ids and/or elements to remove |
1155 | 1155 |
* the listener from. |
1156 |
* @param {String} sType the type of event to remove.
|
|
1157 |
* @param {Function} fn the method the event invokes. If fn is
|
|
1156 |
* @param {String} sType the type of event to remove. |
|
1157 |
* @param {Function} fn the method the event invokes. If fn is |
|
1158 | 1158 |
* undefined, then all event handlers for the type of event are |
1159 | 1159 |
* removed. |
1160 |
* @return {boolean} true if the unbind was successful, false
|
|
1160 |
* @return {boolean} true if the unbind was successful, false |
|
1161 | 1161 |
* otherwise. |
1162 |
* @static
|
|
1162 |
* @static |
|
1163 | 1163 |
*/ |
1164 | 1164 |
removeListener: function(el, sType, fn) { |
1165 | 1165 |
var i, len, li; |
... | ... | |
1243 | 1243 |
* Returns the event's target element. Safari sometimes provides |
1244 | 1244 |
* a text node, and this is automatically resolved to the text |
1245 | 1245 |
* node's parent so that it behaves like other browsers. |
1246 |
* @method getTarget
|
|
1247 |
* @param {Event} ev the event
|
|
1248 |
* @param {boolean} resolveTextNode when set to true the target's
|
|
1246 |
* @method getTarget |
|
1247 |
* @param {Event} ev the event |
|
1248 |
* @param {boolean} resolveTextNode when set to true the target's |
|
1249 | 1249 |
* parent will be returned if the target is a |
1250 | 1250 |
* text node. @deprecated, the text node is |
1251 | 1251 |
* now resolved automatically |
1252 |
* @return {HTMLElement} the event's target
|
|
1253 |
* @static
|
|
1252 |
* @return {HTMLElement} the event's target |
|
1253 |
* @static |
|
1254 | 1254 |
*/ |
1255 | 1255 |
getTarget: function(ev, resolveTextNode) { |
1256 | 1256 |
var t = ev.target || ev.srcElement; |
... | ... | |
1261 | 1261 |
* In some cases, some browsers will return a text node inside |
1262 | 1262 |
* the actual element that was targeted. This normalizes the |
1263 | 1263 |
* return value for getTarget and getRelatedTarget. |
1264 |
* @method resolveTextNode
|
|
1265 |
* @param {HTMLElement} node node to resolve
|
|
1266 |
* @return {HTMLElement} the normized node
|
|
1267 |
* @static
|
|
1264 |
* @method resolveTextNode |
|
1265 |
* @param {HTMLElement} node node to resolve |
|
1266 |
* @return {HTMLElement} the normized node |
|
1267 |
* @static |
|
1268 | 1268 |
*/ |
1269 | 1269 |
resolveTextNode: function(n) { |
1270 | 1270 |
try { |
... | ... | |
1278 | 1278 |
|
1279 | 1279 |
/** |
1280 | 1280 |
* Returns the event's pageX |
1281 |
* @method getPageX
|
|
1282 |
* @param {Event} ev the event
|
|
1283 |
* @return {int} the event's pageX
|
|
1284 |
* @static
|
|
1281 |
* @method getPageX |
|
1282 |
* @param {Event} ev the event |
|
1283 |
* @return {int} the event's pageX |
|
1284 |
* @static |
|
1285 | 1285 |
*/ |
1286 | 1286 |
getPageX: function(ev) { |
1287 | 1287 |
var x = ev.pageX; |
... | ... | |
1298 | 1298 |
|
1299 | 1299 |
/** |
1300 | 1300 |
* Returns the event's pageY |
1301 |
* @method getPageY
|
|
1302 |
* @param {Event} ev the event
|
|
1303 |
* @return {int} the event's pageY
|
|
1304 |
* @static
|
|
1301 |
* @method getPageY |
|
1302 |
* @param {Event} ev the event |
|
1303 |
* @return {int} the event's pageY |
|
1304 |
* @static |
|
1305 | 1305 |
*/ |
1306 | 1306 |
getPageY: function(ev) { |
1307 | 1307 |
var y = ev.pageY; |
... | ... | |
1319 | 1319 |
|
1320 | 1320 |
/** |
1321 | 1321 |
* Returns the pageX and pageY properties as an indexed array. |
1322 |
* @method getXY
|
|
1323 |
* @param {Event} ev the event
|
|
1324 |
* @return {[x, y]} the pageX and pageY properties of the event
|
|
1325 |
* @static
|
|
1322 |
* @method getXY |
|
1323 |
* @param {Event} ev the event |
|
1324 |
* @return {[x, y]} the pageX and pageY properties of the event |
|
1325 |
* @static |
|
1326 | 1326 |
*/ |
1327 | 1327 |
getXY: function(ev) { |
1328 | 1328 |
return [this.getPageX(ev), this.getPageY(ev)]; |
... | ... | |
1330 | 1330 |
|
1331 | 1331 |
/** |
1332 | 1332 |
* Returns the event's related target |
1333 |
* @method getRelatedTarget
|
|
1334 |
* @param {Event} ev the event
|
|
1335 |
* @return {HTMLElement} the event's relatedTarget
|
|
1336 |
* @static
|
|
1333 |
* @method getRelatedTarget |
|
1334 |
* @param {Event} ev the event |
|
1335 |
* @return {HTMLElement} the event's relatedTarget |
|
1336 |
* @static |
|
1337 | 1337 |
*/ |
1338 | 1338 |
getRelatedTarget: function(ev) { |
1339 | 1339 |
var t = ev.relatedTarget; |
... | ... | |
1351 | 1351 |
/** |
1352 | 1352 |
* Returns the time of the event. If the time is not included, the |
1353 | 1353 |
* event is modified using the current time. |
1354 |
* @method getTime
|
|
1355 |
* @param {Event} ev the event
|
|
1356 |
* @return {Date} the time of the event
|
|
1357 |
* @static
|
|
1354 |
* @method getTime |
|
1355 |
* @param {Event} ev the event |
|
1356 |
* @return {Date} the time of the event |
|
1357 |
* @static |
|
1358 | 1358 |
*/ |
1359 | 1359 |
getTime: function(ev) { |
1360 | 1360 |
if (!ev.time) { |
... | ... | |
1372 | 1372 |
|
1373 | 1373 |
/** |
1374 | 1374 |
* Convenience method for stopPropagation + preventDefault |
1375 |
* @method stopEvent
|
|
1376 |
* @param {Event} ev the event
|
|
1377 |
* @static
|
|
1375 |
* @method stopEvent |
|
1376 |
* @param {Event} ev the event |
|
1377 |
* @static |
|
1378 | 1378 |
*/ |
1379 | 1379 |
stopEvent: function(ev) { |
1380 | 1380 |
this.stopPropagation(ev); |
... | ... | |
1383 | 1383 |
|
1384 | 1384 |
/** |
1385 | 1385 |
* Stops event propagation |
1386 |
* @method stopPropagation
|
|
1387 |
* @param {Event} ev the event
|
|
1388 |
* @static
|
|
1386 |
* @method stopPropagation |
|
1387 |
* @param {Event} ev the event |
|
1388 |
* @static |
|
1389 | 1389 |
*/ |
1390 | 1390 |
stopPropagation: function(ev) { |
1391 | 1391 |
if (ev.stopPropagation) { |
... | ... | |
1397 | 1397 |
|
1398 | 1398 |
/** |
1399 | 1399 |
* Prevents the default behavior of the event |
1400 |
* @method preventDefault
|
|
1401 |
* @param {Event} ev the event
|
|
1402 |
* @static
|
|
1400 |
* @method preventDefault |
|
1401 |
* @param {Event} ev the event |
|
1402 |
* @static |
|
1403 | 1403 |
*/ |
1404 | 1404 |
preventDefault: function(ev) { |
1405 | 1405 |
if (ev.preventDefault) { |
... | ... | |
1415 | 1415 |
* executed automatically for events registered through the event |
1416 | 1416 |
* manager, so the implementer should not normally need to execute |
1417 | 1417 |
* this function at all. |
1418 |
* @method getEvent
|
|
1419 |
* @param {Event} e the event parameter from the handler
|
|
1420 |
* @param {HTMLElement} boundEl the element the listener is attached to
|
|
1421 |
* @return {Event} the event
|
|
1422 |
* @static
|
|
1418 |
* @method getEvent |
|
1419 |
* @param {Event} e the event parameter from the handler |
|
1420 |
* @param {HTMLElement} boundEl the element the listener is attached to |
|
1421 |
* @return {Event} the event |
|
1422 |
* @static |
|
1423 | 1423 |
*/ |
1424 | 1424 |
getEvent: function(e, boundEl) { |
1425 | 1425 |
var ev = e || window.event; |
... | ... | |
1440 | 1440 |
|
1441 | 1441 |
/** |
1442 | 1442 |
* Returns the charcode for an event |
1443 |
* @method getCharCode
|
|
1444 |
* @param {Event} ev the event
|
|
1445 |
* @return {int} the event's charCode
|
|
1446 |
* @static
|
|
1443 |
* @method getCharCode |
|
1444 |
* @param {Event} ev the event |
|
1445 |
* @return {int} the event's charCode |
|
1446 |
* @static |
|
1447 | 1447 |
*/ |
1448 | 1448 |
getCharCode: function(ev) { |
1449 | 1449 |
var code = ev.keyCode || ev.charCode || 0; |
... | ... | |
1458 | 1458 |
/** |
1459 | 1459 |
* Locating the saved event handler data by function ref |
1460 | 1460 |
* |
1461 |
* @method _getCacheIndex
|
|
1462 |
* @static
|
|
1463 |
* @private
|
|
1461 |
* @method _getCacheIndex |
|
1462 |
* @static |
|
1463 |
* @private |
|
1464 | 1464 |
*/ |
1465 | 1465 |
_getCacheIndex: function(a, el, sType, fn) { |
1466 | 1466 |
for (var i=0, l=a.length; i<l; i=i+1) { |
... | ... | |
1479 | 1479 |
/** |
1480 | 1480 |
* Generates an unique ID for the element if it does not already |
1481 | 1481 |
* have one. |
1482 |
* @method generateId
|
|
1483 |
* @param el the element to create the id for
|
|
1484 |
* @return {string} the resulting id of the element
|
|
1485 |
* @static
|
|
1482 |
* @method generateId |
|
1483 |
* @param el the element to create the id for |
|
1484 |
* @return {string} the resulting id of the element |
|
1485 |
* @static |
|
1486 | 1486 |
*/ |
1487 | 1487 |
generateId: function(el) { |
1488 | 1488 |
var id = el.id; |
... | ... | |
1503 | 1503 |
* browsers return different types of collections. This function |
1504 | 1504 |
* tests to determine if the object is array-like. It will also |
1505 | 1505 |
* fail if the object is an array, but is empty. |
1506 |
* @method _isValidCollection
|
|
1507 |
* @param o the object to test
|
|
1508 |
* @return {boolean} true if the object is array-like and populated
|
|
1509 |
* @static
|
|
1510 |
* @private
|
|
1506 |
* @method _isValidCollection |
|
1507 |
* @param o the object to test |
|
1508 |
* @return {boolean} true if the object is array-like and populated |
|
1509 |
* @static |
|
1510 |
* @private |
|
1511 | 1511 |
*/ |
1512 | 1512 |
_isValidCollection: function(o) { |
1513 | 1513 |
try { |
... | ... | |
1524 | 1524 |
}, |
1525 | 1525 |
|
1526 | 1526 |
/** |
1527 |
* @private
|
|
1528 |
* @property elCache
|
|
1527 |
* @private |
|
1528 |
* @property elCache |
|
1529 | 1529 |
* DOM element cache |
1530 |
* @static
|
|
1531 |
* @deprecated Elements are not cached due to issues that arise when
|
|
1530 |
* @static |
|
1531 |
* @deprecated Elements are not cached due to issues that arise when |
|
1532 | 1532 |
* elements are removed and re-added |
1533 | 1533 |
*/ |
1534 | 1534 |
elCache: {}, |
... | ... | |
1536 | 1536 |
/** |
1537 | 1537 |
* We cache elements bound by id because when the unload event |
1538 | 1538 |
* fires, we can no longer use document.getElementById |
1539 |
* @method getEl
|
|
1540 |
* @static
|
|
1541 |
* @private
|
|
1542 |
* @deprecated Elements are not cached any longer
|
|
1539 |
* @method getEl |
|
1540 |
* @static |
|
1541 |
* @private |
|
1542 |
* @deprecated Elements are not cached any longer |
|
1543 | 1543 |
*/ |
1544 | 1544 |
getEl: function(id) { |
1545 | 1545 |
return (typeof id === "string") ? document.getElementById(id) : id; |
... | ... | |
1547 | 1547 |
|
1548 | 1548 |
/** |
1549 | 1549 |
* Clears the element cache |
1550 |
* @deprecated Elements are not cached any longer
|
|
1551 |
* @method clearCache
|
|
1552 |
* @static
|
|
1553 |
* @private
|
|
1550 |
* @deprecated Elements are not cached any longer |
|
1551 |
* @method clearCache |
|
1552 |
* @static |
|
1553 |
* @private |
|
1554 | 1554 |
*/ |
1555 | 1555 |
clearCache: function() { }, |
1556 | 1556 |
|
1557 | 1557 |
/** |
1558 | 1558 |
* Custom event the fires when the dom is initially usable |
1559 |
* @event DOMReadyEvent
|
|
1559 |
* @event DOMReadyEvent |
|
1560 | 1560 |
*/ |
1561 | 1561 |
DOMReadyEvent: new YAHOO.util.CustomEvent("DOMReady", YAHOO, 0, 0, 1), |
1562 | 1562 |
|
1563 | 1563 |
/** |
1564 | 1564 |
* hook up any deferred listeners |
1565 |
* @method _load
|
|
1566 |
* @static
|
|
1567 |
* @private
|
|
1565 |
* @method _load |
|
1566 |
* @static |
|
1567 |
* @private |
|
1568 | 1568 |
*/ |
1569 | 1569 |
_load: function(e) { |
1570 | 1570 |
|
... | ... | |
1587 | 1587 |
/** |
1588 | 1588 |
* Fires the DOMReady event listeners the first time the document is |
1589 | 1589 |
* usable. |
1590 |
* @method _ready
|
|
1591 |
* @static
|
|
1592 |
* @private
|
|
1590 |
* @method _ready |
|
1591 |
* @static |
|
1592 |
* @private |
|
1593 | 1593 |
*/ |
1594 | 1594 |
_ready: function(e) { |
1595 | 1595 |
var EU = YAHOO.util.Event; |
... | ... | |
1608 | 1608 |
* Polling function that runs before the onload event fires, |
1609 | 1609 |
* attempting to attach to DOM Nodes as soon as they are |
1610 | 1610 |
* available |
1611 |
* @method _tryPreloadAttach
|
|
1612 |
* @static
|
|
1613 |
* @private
|
|
1611 |
* @method _tryPreloadAttach |
|
1612 |
* @static |
|
1613 |
* @private |
|
1614 | 1614 |
*/ |
1615 | 1615 |
_tryPreloadAttach: function() { |
1616 | 1616 |
|
... | ... | |
1722 | 1722 |
* Removes all listeners attached to the given element via addListener. |
1723 | 1723 |
* Optionally, the node's children can also be purged. |
1724 | 1724 |
* Optionally, you can specify a specific type of event to remove. |
1725 |
* @method purgeElement
|
|
1726 |
* @param {HTMLElement} el the element to purge
|
|
1727 |
* @param {boolean} recurse recursively purge this element's children
|
|
1725 |
* @method purgeElement |
|
1726 |
* @param {HTMLElement} el the element to purge |
|
1727 |
* @param {boolean} recurse recursively purge this element's children |
|
1728 | 1728 |
* as well. Use with caution. |
1729 |
* @param {string} sType optional type of listener to purge. If
|
|
1729 |
* @param {string} sType optional type of listener to purge. If |
|
1730 | 1730 |
* left out, all listeners will be removed |
1731 |
* @static
|
|
1731 |
* @static |
|
1732 | 1732 |
*/ |
1733 | 1733 |
purgeElement: function(el, recurse, sType) { |
1734 | 1734 |
var oEl = (YAHOO.lang.isString(el)) ? this.getEl(el) : el; |
... | ... | |
1750 | 1750 |
/** |
1751 | 1751 |
* Returns all listeners attached to the given element via addListener. |
1752 | 1752 |
* Optionally, you can specify a specific type of event to return. |
1753 |
* @method getListeners
|
|
1754 |
* @param el {HTMLElement|string} the element or element id to inspect
|
|
1755 |
* @param sType {string} optional type of listener to return. If
|
|
1753 |
* @method getListeners |
|
1754 |
* @param el {HTMLElement|string} the element or element id to inspect |
|
1755 |
* @param sType {string} optional type of listener to return. If |
|
1756 | 1756 |
* left out, all listeners will be returned |
1757 |
* @return {Object} the listener. Contains the following fields:
|
|
1757 |
* @return {Object} the listener. Contains the following fields: |
|
1758 | 1758 |
* type: (string) the type of event |
1759 | 1759 |
* fn: (function) the callback supplied to addListener |
1760 | 1760 |
* obj: (object) the custom object supplied to addListener |
1761 | 1761 |
* adjust: (boolean|object) whether or not to adjust the default context |
1762 | 1762 |
* scope: (boolean) the derived context based on the adjust parameter |
1763 | 1763 |
* index: (int) its position in the Event util listener cache |
1764 |
* @static
|
|
1764 |
* @static |
|
1765 | 1765 |
*/ |
1766 | 1766 |
getListeners: function(el, sType) { |
1767 | 1767 |
var results=[], searchLists; |
... | ... | |
1802 | 1802 |
/** |
1803 | 1803 |
* Removes all listeners registered by pe.event. Called |
1804 | 1804 |
* automatically during the unload event. |
1805 |
* @method _unload
|
|
1806 |
* @static
|
|
1807 |
* @private
|
|
1805 |
* @method _unload |
|
1806 |
* @static |
|
1807 |
* @private |
|
1808 | 1808 |
*/ |
1809 | 1809 |
_unload: function(e) { |
1810 | 1810 |
|
... | ... | |
1853 | 1853 |
|
1854 | 1854 |
/** |
1855 | 1855 |
* Returns scrollLeft |
1856 |
* @method _getScrollLeft
|
|
1857 |
* @static
|
|
1858 |
* @private
|
|
1856 |
* @method _getScrollLeft |
|
1857 |
* @static |
|
1858 |
* @private |
|
1859 | 1859 |
*/ |
1860 | 1860 |
_getScrollLeft: function() { |
1861 | 1861 |
return this._getScroll()[1]; |
... | ... | |
1863 | 1863 |
|
1864 | 1864 |
/** |
1865 | 1865 |
* Returns scrollTop |
1866 |
* @method _getScrollTop
|
|
1867 |
* @static
|
|
1868 |
* @private
|
|
1866 |
* @method _getScrollTop |
|
1867 |
* @static |
|
1868 |
* @private |
|
1869 | 1869 |
*/ |
1870 | 1870 |
_getScrollTop: function() { |
1871 | 1871 |
return this._getScroll()[0]; |
... | ... | |
1874 | 1874 |
/** |
1875 | 1875 |
* Returns the scrollTop and scrollLeft. Used to calculate the |
1876 | 1876 |
* pageX and pageY in Internet Explorer |
1877 |
* @method _getScroll
|
|
1878 |
* @static
|
|
1879 |
* @private
|
|
1877 |
* @method _getScroll |
|
1878 |
* @static |
|
1879 |
* @private |
|
1880 | 1880 |
*/ |
1881 | 1881 |
_getScroll: function() { |
1882 | 1882 |
var dd = document.documentElement, db = document.body; |
... | ... | |
1892 | 1892 |
/** |
1893 | 1893 |
* Used by old versions of CustomEvent, restored for backwards |
1894 | 1894 |
* compatibility |
1895 |
* @method regCE
|
|
1896 |
* @private
|
|
1897 |
* @static
|
|
1898 |
* @deprecated still here for backwards compatibility
|
|
1895 |
* @method regCE |
|
1896 |
* @private |
|
1897 |
* @static |
|
1898 |
* @deprecated still here for backwards compatibility |
|
1899 | 1899 |
*/ |
1900 | 1900 |
regCE: function() {}, |
1901 | 1901 |
|
1902 | 1902 |
/** |
1903 | 1903 |
* Adds a DOM event directly without the caching, cleanup, context adj, etc |
1904 | 1904 |
* |
1905 |
* @method _simpleAdd
|
|
1906 |
* @param {HTMLElement} el the element to bind the handler to
|
|
1907 |
* @param {string} sType the type of event handler
|
|
1908 |
* @param {function} fn the callback to invoke
|
|
1909 |
* @param {boolen} capture capture or bubble phase
|
|
1910 |
* @static
|
|
1911 |
* @private
|
|
1905 |
* @method _simpleAdd |
|
1906 |
* @param {HTMLElement} el the element to bind the handler to |
|
1907 |
* @param {string} sType the type of event handler |
|
1908 |
* @param {function} fn the callback to invoke |
|
1909 |
* @param {boolen} capture capture or bubble phase |
|
1910 |
* @static |
|
1911 |
* @private |
|
1912 | 1912 |
*/ |
1913 | 1913 |
_simpleAdd: function () { |
1914 | 1914 |
if (window.addEventListener) { |
... | ... | |
1927 | 1927 |
/** |
1928 | 1928 |
* Basic remove listener |
1929 | 1929 |
* |
1930 |
* @method _simpleRemove
|
|
1931 |
* @param {HTMLElement} el the element to bind the handler to
|
|
1932 |
* @param {string} sType the type of event handler
|
|
1933 |
* @param {function} fn the callback to invoke
|
|
1934 |
* @param {boolen} capture capture or bubble phase
|
|
1935 |
* @static
|
|
1936 |
* @private
|
|
1930 |
* @method _simpleRemove |
|
1931 |
* @param {HTMLElement} el the element to bind the handler to |
|
1932 |
* @param {string} sType the type of event handler |
|
1933 |
* @param {function} fn the callback to invoke |
|
1934 |
* @param {boolen} capture capture or bubble phase |
|
1935 |
* @static |
|
1936 |
* @private |
|
1937 | 1937 |
*/ |
1938 | 1938 |
_simpleRemove: function() { |
1939 | 1939 |
if (window.removeEventListener) { |
... | ... | |
1957 | 1957 |
|
1958 | 1958 |
/** |
1959 | 1959 |
* YAHOO.util.Event.on is an alias for addListener |
1960 |
* @method on
|
|
1961 |
* @see addListener
|
|
1962 |
* @static
|
|
1960 |
* @method on |
|
1961 |
* @see addListener |
|
1962 |
* @static |
|
1963 | 1963 |
*/ |
1964 | 1964 |
EU.on = EU.addListener; |
1965 | 1965 |
|
1966 | 1966 |
/** |
1967 | 1967 |
* YAHOO.util.Event.onFocus is an alias for addFocusListener |
1968 |
* @method onFocus
|
|
1969 |
* @see addFocusListener
|
|
1970 |
* @static
|
|
1968 |
* @method onFocus |
|
1969 |
* @see addFocusListener |
|
1970 |
* @static |
|
1971 | 1971 |
* @deprecated use YAHOO.util.Event.on and specify "focusin" as the event type. |
1972 | 1972 |
*/ |
1973 | 1973 |
EU.onFocus = EU.addFocusListener; |
1974 | 1974 |
|
1975 | 1975 |
/** |
1976 | 1976 |
* YAHOO.util.Event.onBlur is an alias for addBlurListener |
1977 |
* @method onBlur
|
|
1978 |
* @see addBlurListener
|
|
1979 |
* @static
|
|
1977 |
* @method onBlur |
|
1978 |
* @see addBlurListener |
|
1979 |
* @static |
|
1980 | 1980 |
* @deprecated use YAHOO.util.Event.on and specify "focusout" as the event type. |
1981 | 1981 |
*/ |
1982 | 1982 |
EU.onBlur = EU.addBlurListener; |
... | ... | |
2062 | 2062 |
|
2063 | 2063 |
/** |
2064 | 2064 |
* Private storage of custom events |
2065 |
* @property __yui_events
|
|
2066 |
* @type Object[]
|
|
2067 |
* @private
|
|
2065 |
* @property __yui_events |
|
2066 |
* @type Object[] |
|
2067 |
* @private |
|
2068 | 2068 |
*/ |
2069 | 2069 |
__yui_events: null, |
2070 | 2070 |
|
2071 | 2071 |
/** |
2072 | 2072 |
* Private storage of custom event subscribers |
2073 |
* @property __yui_subscribers
|
|
2074 |
* @type Object[]
|
|
2075 |
* @private
|
|
2073 |
* @property __yui_subscribers |
|
2074 |
* @type Object[] |
|
2075 |
* @private |
|
2076 | 2076 |
*/ |
2077 | 2077 |
__yui_subscribers: null, |
2078 | 2078 |
|
2079 | 2079 |
/** |
2080 | 2080 |
* Subscribe to a CustomEvent by event type |
2081 | 2081 |
* |
2082 |
* @method subscribe
|
|
2083 |
* @param p_type {string} the type, or name of the event
|
|
2084 |
* @param p_fn {function} the function to exectute when the event fires
|
|
2085 |
* @param p_obj {Object} An object to be passed along when the event
|
|
2082 |
* @method subscribe |
|
2083 |
* @param p_type {string} the type, or name of the event |
|
2084 |
* @param p_fn {function} the function to exectute when the event fires |
|
2085 |
* @param p_obj {Object} An object to be passed along when the event |
|
2086 | 2086 |
* fires |
2087 |
* @param overrideContext {boolean} If true, the obj passed in becomes the
|
|
2087 |
* @param overrideContext {boolean} If true, the obj passed in becomes the |
|
2088 | 2088 |
* execution scope of the listener |
2089 | 2089 |
*/ |
2090 | 2090 |
subscribe: function(p_type, p_fn, p_obj, overrideContext) { |
... | ... | |
2107 | 2107 |
|
2108 | 2108 |
/** |
2109 | 2109 |
* Unsubscribes one or more listeners the from the specified event |
2110 |
* @method unsubscribe
|
|
2111 |
* @param p_type {string} The type, or name of the event. If the type
|
|
2110 |
* @method unsubscribe |
|
2111 |
* @param p_type {string} The type, or name of the event. If the type |
|
2112 | 2112 |
* is not specified, it will attempt to remove |
2113 | 2113 |
* the listener from all hosted events. |
2114 |
* @param p_fn {Function} The subscribed function to unsubscribe, if not
|
|
2114 |
* @param p_fn {Function} The subscribed function to unsubscribe, if not |
|
2115 | 2115 |
* supplied, all subscribers will be removed. |
2116 |
* @param p_obj {Object} The custom object passed to subscribe. This is
|
|
2116 |
* @param p_obj {Object} The custom object passed to subscribe. This is |
|
2117 | 2117 |
* optional, but if supplied will be used to |
2118 | 2118 |
* disambiguate multiple listeners that are the same |
2119 | 2119 |
* (e.g., you subscribe many object using a function |
2120 | 2120 |
* that lives on the prototype) |
2121 |
* @return {boolean} true if the subscriber was found and detached.
|
|
2121 |
* @return {boolean} true if the subscriber was found and detached. |
|
2122 | 2122 |
*/ |
2123 | 2123 |
unsubscribe: function(p_type, p_fn, p_obj) { |
2124 | 2124 |
this.__yui_events = this.__yui_events || {}; |
... | ... | |
2145 | 2145 |
* Removes all listeners from the specified event. If the event type |
2146 | 2146 |
* is not specified, all listeners from all hosted custom events will |
2147 | 2147 |
* be removed. |
2148 |
* @method unsubscribeAll
|
|
2149 |
* @param p_type {string} The type, or name of the event
|
|
2148 |
* @method unsubscribeAll |
|
2149 |
* @param p_type {string} The type, or name of the event |
|
2150 | 2150 |
*/ |
2151 | 2151 |
unsubscribeAll: function(p_type) { |
2152 | 2152 |
return this.unsubscribe(p_type); |
... | ... | |
2157 | 2157 |
* by that name already exists, it will not be re-created. In either |
2158 | 2158 |
* case the custom event is returned. |
2159 | 2159 |
* |
2160 |
* @method createEvent
|
|
2160 |
* @method createEvent |
|
2161 | 2161 |
* |
2162 |
* @param p_type {string} the type, or name of the event
|
|
2163 |
* @param p_config {object} optional config params. Valid properties are:
|
|
2162 |
* @param p_type {string} the type, or name of the event |
|
2163 |
* @param p_config {object} optional config params. Valid properties are: |
|
2164 | 2164 |
* |
2165 | 2165 |
* <ul> |
2166 | 2166 |
* <li> |
... | ... | |
2230 | 2230 |
* <li>The custom object (if any) that was passed into the subscribe() |
2231 | 2231 |
* method</li> |
2232 | 2232 |
* </ul> |
2233 |
* @method fireEvent
|
|
2234 |
* @param p_type {string} the type, or name of the event
|
|
2235 |
* @param arguments {Object*} an arbitrary set of parameters to pass to
|
|
2233 |
* @method fireEvent |
|
2234 |
* @param p_type {string} the type, or name of the event |
|
2235 |
* @param arguments {Object*} an arbitrary set of parameters to pass to |
|
2236 | 2236 |
* the handler. |
2237 |
* @return {boolean} the return value from CustomEvent.fire
|
|
2237 |
* @return {boolean} the return value from CustomEvent.fire |
|
2238 | 2238 |
* |
2239 | 2239 |
*/ |
2240 | 2240 |
fireEvent: function(p_type) { |
... | ... | |
2256 | 2256 |
/** |
2257 | 2257 |
* Returns true if the custom event of the provided type has been created |
2258 | 2258 |
* with createEvent. |
2259 |
* @method hasEvent
|
|
2260 |
* @param type {string} the type, or name of the event
|
|
2259 |
* @method hasEvent |
|
2260 |
* @param type {string} the type, or name of the event |
|
2261 | 2261 |
*/ |
2262 | 2262 |
hasEvent: function(type) { |
Also available in: Unified diff
fixed headerinfos