Revision 1374
Added by Dietmar over 13 years ago
event-debug.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 |
|
... | ... | |
126 | 126 |
* handle the case where there is a non-repeating event that has |
127 | 127 |
* already fired has a new subscriber. |
128 | 128 |
* |
129 |
* @event subscribeEvent
|
|
130 |
* @type YAHOO.util.CustomEvent
|
|
131 |
* @param fn {Function} The function to execute
|
|
132 |
* @param obj <Object> An object to be passed along when the event fires.
|
|
129 |
* @event subscribeEvent |
|
130 |
* @type YAHOO.util.CustomEvent |
|
131 |
* @param fn {Function} The function to execute |
|
132 |
* @param obj <Object> An object to be passed along when the event fires. |
|
133 | 133 |
* Defaults to the custom event. |
134 |
* @param override <boolean|Object> If true, the obj passed in becomes the
|
|
134 |
* @param override <boolean|Object> If true, the obj passed in becomes the |
|
135 | 135 |
* execution context of the listener. If an object, that object becomes |
136 | 136 |
* the execution context. Defaults to the custom event. |
137 | 137 |
*/ |
... | ... | |
145 | 145 |
* In order to make it possible to execute the rest of the subscriber |
146 | 146 |
* stack when one thows an exception, the subscribers exceptions are |
147 | 147 |
* caught. The most recent exception is stored in this property |
148 |
* @property lastError
|
|
149 |
* @type Error
|
|
148 |
* @property lastError |
|
149 |
* @type Error |
|
150 | 150 |
*/ |
151 | 151 |
this.lastError = null; |
152 | 152 |
}; |
... | ... | |
175 | 175 |
|
176 | 176 |
/** |
177 | 177 |
* Subscribes the caller to this event |
178 |
* @method subscribe
|
|
179 |
* @param {Function} fn The function to execute
|
|
180 |
* @param {Object} obj An object to be passed along when the event fires.
|
|
178 |
* @method subscribe |
|
179 |
* @param {Function} fn The function to execute |
|
180 |
* @param {Object} obj An object to be passed along when the event fires. |
|
181 | 181 |
* overrideContext <boolean|Object> If true, the obj passed in becomes the execution |
182 | 182 |
* context of the listener. If an object, that object becomes the execution context. |
183 | 183 |
*/ |
... | ... | |
202 | 202 |
|
203 | 203 |
/** |
204 | 204 |
* Unsubscribes subscribers. |
205 |
* @method unsubscribe
|
|
206 |
* @param {Function} fn The subscribed function to remove, if not supplied
|
|
205 |
* @method unsubscribe |
|
206 |
* @param {Function} fn The subscribed function to remove, if not supplied |
|
207 | 207 |
* all will be removed |
208 |
* @param {Object} obj The custom object passed to subscribe. This is
|
|
208 |
* @param {Object} obj The custom object passed to subscribe. This is |
|
209 | 209 |
* optional, but if supplied will be used to |
210 | 210 |
* disambiguate multiple listeners that are the same |
211 | 211 |
* (e.g., you subscribe many object using a function |
212 | 212 |
* that lives on the prototype) |
213 |
* @return {boolean} True if the subscriber was found and detached.
|
|
213 |
* @return {boolean} True if the subscriber was found and detached. |
|
214 | 214 |
*/ |
215 | 215 |
unsubscribe: function(fn, obj) { |
216 | 216 |
|
... | ... | |
240 | 240 |
* <li>The custom object (if any) that was passed into the subscribe() |
241 | 241 |
* method</li> |
242 | 242 |
* </ul> |
243 |
* @method fire
|
|
244 |
* @param {Object*} arguments an arbitrary set of parameters to pass to
|
|
243 |
* @method fire |
|
244 |
* @param {Object*} arguments an arbitrary set of parameters to pass to |
|
245 | 245 |
* the handler. |
246 |
* @return {boolean} false if one of the subscribers returned false,
|
|
246 |
* @return {boolean} false if one of the subscribers returned false, |
|
247 | 247 |
* true otherwise |
248 | 248 |
*/ |
249 | 249 |
fire: function() { |
... | ... | |
346 | 346 |
|
347 | 347 |
/** |
348 | 348 |
* Removes all listeners |
349 |
* @method unsubscribeAll
|
|
350 |
* @return {int} The number of listeners unsubscribed
|
|
349 |
* @method unsubscribeAll |
|
350 |
* @return {int} The number of listeners unsubscribed |
|
351 | 351 |
*/ |
352 | 352 |
unsubscribeAll: function() { |
353 | 353 |
var l = this.subscribers.length, i; |
... | ... | |
361 | 361 |
}, |
362 | 362 |
|
363 | 363 |
/** |
364 |
* @method _delete
|
|
365 |
* @private
|
|
364 |
* @method _delete |
|
365 |
* @private |
|
366 | 366 |
*/ |
367 | 367 |
_delete: function(index) { |
368 | 368 |
var s = this.subscribers[index]; |
... | ... | |
376 | 376 |
}, |
377 | 377 |
|
378 | 378 |
/** |
379 |
* @method toString
|
|
379 |
* @method toString |
|
380 | 380 |
*/ |
381 | 381 |
toString: function() { |
382 | 382 |
return "CustomEvent: " + "'" + this.type + "', " + |
... | ... | |
400 | 400 |
|
401 | 401 |
/** |
402 | 402 |
* The callback that will be execute when the event fires |
403 |
* @property fn
|
|
404 |
* @type function
|
|
403 |
* @property fn |
|
404 |
* @type function |
|
405 | 405 |
*/ |
406 | 406 |
this.fn = fn; |
407 | 407 |
|
408 | 408 |
/** |
409 | 409 |
* An optional custom object that will passed to the callback when |
410 | 410 |
* the event fires |
411 |
* @property obj
|
|
412 |
* @type object
|
|
411 |
* @property obj |
|
412 |
* @type object |
|
413 | 413 |
*/ |
414 | 414 |
this.obj = YAHOO.lang.isUndefined(obj) ? null : obj; |
415 | 415 |
|
... | ... | |
419 | 419 |
* By setting overrideContext to true, the execution context becomes the custom |
420 | 420 |
* object passed in by the subscriber. If overrideContext is an object, that |
421 | 421 |
* object becomes the context. |
422 |
* @property overrideContext
|
|
423 |
* @type boolean|object
|
|
422 |
* @property overrideContext |
|
423 |
* @type boolean|object |
|
424 | 424 |
*/ |
425 | 425 |
this.overrideContext = overrideContext; |
426 | 426 |
|
... | ... | |
499 | 499 |
|
500 | 500 |
/** |
501 | 501 |
* True after the onload event has fired |
502 |
* @property loadComplete
|
|
503 |
* @type boolean
|
|
504 |
* @static
|
|
505 |
* @private
|
|
502 |
* @property loadComplete |
|
503 |
* @type boolean |
|
504 |
* @static |
|
505 |
* @private |
|
506 | 506 |
*/ |
507 | 507 |
var loadComplete = false, |
508 | 508 |
|
509 | 509 |
/** |
510 | 510 |
* Cache of wrapped listeners |
511 |
* @property listeners
|
|
512 |
* @type array
|
|
513 |
* @static
|
|
514 |
* @private
|
|
511 |
* @property listeners |
|
512 |
* @type array |
|
513 |
* @static |
|
514 |
* @private |
|
515 | 515 |
*/ |
516 | 516 |
listeners = [], |
517 | 517 |
|
... | ... | |
519 | 519 |
/** |
520 | 520 |
* User-defined unload function that will be fired before all events |
521 | 521 |
* are detached |
522 |
* @property unloadListeners
|
|
523 |
* @type array
|
|
524 |
* @static
|
|
525 |
* @private
|
|
522 |
* @property unloadListeners |
|
523 |
* @type array |
|
524 |
* @static |
|
525 |
* @private |
|
526 | 526 |
*/ |
527 | 527 |
unloadListeners = [], |
528 | 528 |
|
... | ... | |
530 | 530 |
* The number of times to poll after window.onload. This number is |
531 | 531 |
* increased if additional late-bound handlers are requested after |
532 | 532 |
* the page load. |
533 |
* @property retryCount
|
|
534 |
* @static
|
|
535 |
* @private
|
|
533 |
* @property retryCount |
|
534 |
* @static |
|
535 |
* @private |
|
536 | 536 |
*/ |
537 | 537 |
retryCount = 0, |
538 | 538 |
|
539 | 539 |
/** |
540 | 540 |
* onAvailable listeners |
541 |
* @property onAvailStack
|
|
542 |
* @static
|
|
543 |
* @private
|
|
541 |
* @property onAvailStack |
|
542 |
* @static |
|
543 |
* @private |
|
544 | 544 |
*/ |
545 | 545 |
onAvailStack = [], |
546 | 546 |
|
547 | 547 |
/** |
548 | 548 |
* Counter for auto id generation |
549 |
* @property counter
|
|
550 |
* @static
|
|
551 |
* @private
|
|
549 |
* @property counter |
|
550 |
* @static |
|
551 |
* @private |
|
552 | 552 |
*/ |
553 | 553 |
counter = 0, |
554 | 554 |
|
555 | 555 |
/** |
556 | 556 |
* Normalized keycodes for webkit/safari |
557 |
* @property webkitKeymap
|
|
558 |
* @type {int: int}
|
|
559 |
* @private
|
|
560 |
* @static
|
|
561 |
* @final
|
|
557 |
* @property webkitKeymap |
|
558 |
* @type {int: int} |
|
559 |
* @private |
|
560 |
* @static |
|
561 |
* @final |
|
562 | 562 |
*/ |
563 | 563 |
webkitKeymap = { |
564 | 564 |
63232: 38, // up |
... | ... | |
586 | 586 |
* has been loaded. The default is 500@amp;40 ms, so it will poll |
587 | 587 |
* for 20 seconds or until all outstanding handlers are bound |
588 | 588 |
* (whichever comes first). |
589 |
* @property POLL_RETRYS
|
|
590 |
* @type int
|
|
591 |
* @static
|
|
592 |
* @final
|
|
589 |
* @property POLL_RETRYS |
|
590 |
* @type int |
|
591 |
* @static |
|
592 |
* @final |
|
593 | 593 |
*/ |
594 | 594 |
POLL_RETRYS: 500, |
595 | 595 |
|
596 | 596 |
/** |
597 | 597 |
* The poll interval in milliseconds |
598 |
* @property POLL_INTERVAL
|
|
599 |
* @type int
|
|
600 |
* @static
|
|
601 |
* @final
|
|
598 |
* @property POLL_INTERVAL |
|
599 |
* @type int |
|
600 |
* @static |
|
601 |
* @final |
|
602 | 602 |
*/ |
603 | 603 |
POLL_INTERVAL: 40, |
604 | 604 |
|
605 | 605 |
/** |
606 | 606 |
* Element to bind, int constant |
607 |
* @property EL
|
|
608 |
* @type int
|
|
609 |
* @static
|
|
610 |
* @final
|
|
607 |
* @property EL |
|
608 |
* @type int |
|
609 |
* @static |
|
610 |
* @final |
|
611 | 611 |
*/ |
612 | 612 |
EL: 0, |
613 | 613 |
|
614 | 614 |
/** |
615 | 615 |
* Type of event, int constant |
616 |
* @property TYPE
|
|
617 |
* @type int
|
|
618 |
* @static
|
|
619 |
* @final
|
|
616 |
* @property TYPE |
|
617 |
* @type int |
|
618 |
* @static |
|
619 |
* @final |
|
620 | 620 |
*/ |
621 | 621 |
TYPE: 1, |
622 | 622 |
|
623 | 623 |
/** |
624 | 624 |
* Function to execute, int constant |
625 |
* @property FN
|
|
626 |
* @type int
|
|
627 |
* @static
|
|
628 |
* @final
|
|
625 |
* @property FN |
|
626 |
* @type int |
|
627 |
* @static |
|
628 |
* @final |
|
629 | 629 |
*/ |
630 | 630 |
FN: 2, |
631 | 631 |
|
632 | 632 |
/** |
633 | 633 |
* Function wrapped for context correction and cleanup, int constant |
634 |
* @property WFN
|
|
635 |
* @type int
|
|
636 |
* @static
|
|
637 |
* @final
|
|
634 |
* @property WFN |
|
635 |
* @type int |
|
636 |
* @static |
|
637 |
* @final |
|
638 | 638 |
*/ |
639 | 639 |
WFN: 3, |
640 | 640 |
|
... | ... | |
642 | 642 |
* Object passed in by the user that will be returned as a |
643 | 643 |
* parameter to the callback, int constant. Specific to |
644 | 644 |
* unload listeners |
645 |
* @property OBJ
|
|
646 |
* @type int
|
|
647 |
* @static
|
|
648 |
* @final
|
|
645 |
* @property OBJ |
|
646 |
* @type int |
|
647 |
* @static |
|
648 |
* @final |
|
649 | 649 |
*/ |
650 | 650 |
UNLOAD_OBJ: 3, |
651 | 651 |
|
652 | 652 |
/** |
653 | 653 |
* Adjusted context, either the element we are registering the event |
654 | 654 |
* on or the custom object passed in by the listener, int constant |
655 |
* @property ADJ_SCOPE
|
|
656 |
* @type int
|
|
657 |
* @static
|
|
658 |
* @final
|
|
655 |
* @property ADJ_SCOPE |
|
656 |
* @type int |
|
657 |
* @static |
|
658 |
* @final |
|
659 | 659 |
*/ |
660 | 660 |
ADJ_SCOPE: 4, |
661 | 661 |
|
662 | 662 |
/** |
663 | 663 |
* The original obj passed into addListener |
664 |
* @property OBJ
|
|
665 |
* @type int
|
|
666 |
* @static
|
|
667 |
* @final
|
|
664 |
* @property OBJ |
|
665 |
* @type int |
|
666 |
* @static |
|
667 |
* @final |
|
668 | 668 |
*/ |
669 | 669 |
OBJ: 5, |
670 | 670 |
|
671 | 671 |
/** |
672 | 672 |
* The original context parameter passed into addListener |
673 |
* @property OVERRIDE
|
|
674 |
* @type int
|
|
675 |
* @static
|
|
676 |
* @final
|
|
673 |
* @property OVERRIDE |
|
674 |
* @type int |
|
675 |
* @static |
|
676 |
* @final |
|
677 | 677 |
*/ |
678 | 678 |
OVERRIDE: 6, |
679 | 679 |
|
680 | 680 |
/** |
681 | 681 |
* The original capture parameter passed into addListener |
682 |
* @property CAPTURE
|
|
683 |
* @type int
|
|
684 |
* @static
|
|
685 |
* @final
|
|
682 |
* @property CAPTURE |
|
683 |
* @type int |
|
684 |
* @static |
|
685 |
* @final |
|
686 | 686 |
*/ |
687 | 687 |
CAPTURE: 7, |
688 | 688 |
|
... | ... | |
690 | 690 |
* addListener/removeListener can throw errors in unexpected scenarios. |
691 | 691 |
* These errors are suppressed, the method returns false, and this property |
692 | 692 |
* is set |
693 |
* @property lastError
|
|
694 |
* @static
|
|
695 |
* @type Error
|
|
693 |
* @property lastError |
|
694 |
* @static |
|
695 |
* @type Error |
|
696 | 696 |
*/ |
697 | 697 |
lastError: null, |
698 | 698 |
|
699 | 699 |
/** |
700 | 700 |
* Safari detection |
701 |
* @property isSafari
|
|
702 |
* @private
|
|
703 |
* @static
|
|
704 |
* @deprecated use YAHOO.env.ua.webkit
|
|
701 |
* @property isSafari |
|
702 |
* @private |
|
703 |
* @static |
|
704 |
* @deprecated use YAHOO.env.ua.webkit |
|
705 | 705 |
*/ |
706 | 706 |
isSafari: YAHOO.env.ua.webkit, |
707 | 707 |
|
708 | 708 |
/** |
709 | 709 |
* webkit version |
710 |
* @property webkit
|
|
711 |
* @type string
|
|
712 |
* @private
|
|
713 |
* @static
|
|
714 |
* @deprecated use YAHOO.env.ua.webkit
|
|
710 |
* @property webkit |
|
711 |
* @type string |
|
712 |
* @private |
|
713 |
* @static |
|
714 |
* @deprecated use YAHOO.env.ua.webkit |
|
715 | 715 |
*/ |
716 | 716 |
webkit: YAHOO.env.ua.webkit, |
717 | 717 |
|
718 | 718 |
/** |
719 | 719 |
* IE detection |
720 |
* @property isIE
|
|
721 |
* @private
|
|
722 |
* @static
|
|
723 |
* @deprecated use YAHOO.env.ua.ie
|
|
720 |
* @property isIE |
|
721 |
* @private |
|
722 |
* @static |
|
723 |
* @deprecated use YAHOO.env.ua.ie |
|
724 | 724 |
*/ |
725 | 725 |
isIE: isIE, |
726 | 726 |
|
727 | 727 |
/** |
728 | 728 |
* poll handle |
729 |
* @property _interval
|
|
730 |
* @static
|
|
731 |
* @private
|
|
729 |
* @property _interval |
|
730 |
* @static |
|
731 |
* @private |
|
732 | 732 |
*/ |
733 | 733 |
_interval: null, |
734 | 734 |
|
735 | 735 |
/** |
736 | 736 |
* document readystate poll handle |
737 |
* @property _dri
|
|
738 |
* @static
|
|
739 |
* @private
|
|
737 |
* @property _dri |
|
738 |
* @static |
|
739 |
* @private |
|
740 | 740 |
*/ |
741 | 741 |
_dri: null, |
742 | 742 |
|
743 | 743 |
|
744 | 744 |
/** |
745 | 745 |
* Map of special event types |
746 |
* @property _specialTypes
|
|
747 |
* @static
|
|
748 |
* @private
|
|
746 |
* @property _specialTypes |
|
747 |
* @static |
|
748 |
* @private |
|
749 | 749 |
*/ |
750 | 750 |
_specialTypes: { |
751 | 751 |
focusin: (isIE ? "focusin" : "focus"), |
... | ... | |
755 | 755 |
|
756 | 756 |
/** |
757 | 757 |
* True when the document is initially usable |
758 |
* @property DOMReady
|
|
759 |
* @type boolean
|
|
760 |
* @static
|
|
758 |
* @property DOMReady |
|
759 |
* @type boolean |
|
760 |
* @static |
|
761 | 761 |
*/ |
762 | 762 |
DOMReady: false, |
763 | 763 |
|
... | ... | |
766 | 766 |
* and the error message is written to the debug console. If |
767 | 767 |
* this property is set to true, it will also re-throw the |
768 | 768 |
* error. |
769 |
* @property throwErrors
|
|
770 |
* @type boolean
|
|
771 |
* @default false
|
|
769 |
* @property throwErrors |
|
770 |
* @type boolean |
|
771 |
* @default false |
|
772 | 772 |
*/ |
773 | 773 |
throwErrors: false, |
774 | 774 |
|
775 | 775 |
|
776 | 776 |
/** |
777 |
* @method startInterval
|
|
778 |
* @static
|
|
779 |
* @private
|
|
777 |
* @method startInterval |
|
778 |
* @static |
|
779 |
* @private |
|
780 | 780 |
*/ |
781 | 781 |
startInterval: function() { |
782 | 782 |
if (!this._interval) { |
... | ... | |
798 | 798 |
* <p>The callback is executed with a single parameter: |
799 | 799 |
* the custom object parameter, if provided.</p> |
800 | 800 |
* |
801 |
* @method onAvailable
|
|
801 |
* @method onAvailable |
|
802 | 802 |
* |
803 |
* @param {string||string[]} id the id of the element, or an array
|
|
803 |
* @param {string||string[]} id the id of the element, or an array |
|
804 | 804 |
* of ids to look for. |
805 |
* @param {function} fn what to execute when the element is found.
|
|
806 |
* @param {object} obj an optional object to be passed back as
|
|
805 |
* @param {function} fn what to execute when the element is found. |
|
806 |
* @param {object} obj an optional object to be passed back as |
|
807 | 807 |
* a parameter to fn. |
808 |
* @param {boolean|object} overrideContext If set to true, fn will execute
|
|
808 |
* @param {boolean|object} overrideContext If set to true, fn will execute |
|
809 | 809 |
* in the context of obj, if set to an object it |
810 | 810 |
* will execute in the context of that object |
811 |
* @param checkContent {boolean} check child node readiness (onContentReady)
|
|
812 |
* @static
|
|
811 |
* @param checkContent {boolean} check child node readiness (onContentReady) |
|
812 |
* @static |
|
813 | 813 |
*/ |
814 | 814 |
onAvailable: function(id, fn, obj, overrideContext, checkContent) { |
815 | 815 |
|
... | ... | |
836 | 836 |
* <p>The callback is executed with a single parameter: |
837 | 837 |
* the custom object parameter, if provided.</p> |
838 | 838 |
* |
839 |
* @method onContentReady
|
|
839 |
* @method onContentReady |
|
840 | 840 |
* |
841 |
* @param {string} id the id of the element to look for.
|
|
842 |
* @param {function} fn what to execute when the element is ready.
|
|
843 |
* @param {object} obj an optional object to be passed back as
|
|
841 |
* @param {string} id the id of the element to look for. |
|
842 |
* @param {function} fn what to execute when the element is ready. |
|
843 |
* @param {object} obj an optional object to be passed back as |
|
844 | 844 |
* a parameter to fn. |
845 |
* @param {boolean|object} overrideContext If set to true, fn will execute
|
|
845 |
* @param {boolean|object} overrideContext If set to true, fn will execute |
|
846 | 846 |
* in the context of obj. If an object, fn will |
847 | 847 |
* exectute in the context of that object |
848 | 848 |
* |
849 |
* @static
|
|
849 |
* @static |
|
850 | 850 |
*/ |
851 | 851 |
onContentReady: function(id, fn, obj, overrideContext) { |
852 | 852 |
this.onAvailable(id, fn, obj, overrideContext, true); |
... | ... | |
873 | 873 |
* <p>"DOMReady", [], obj</p> |
874 | 874 |
* |
875 | 875 |
* |
876 |
* @method onDOMReady
|
|
876 |
* @method onDOMReady |
|
877 | 877 |
* |
878 |
* @param {function} fn what to execute when the element is found.
|
|
879 |
* @param {object} obj an optional object to be passed back as
|
|
878 |
* @param {function} fn what to execute when the element is found. |
|
879 |
* @param {object} obj an optional object to be passed back as |
|
880 | 880 |
* a parameter to fn. |
881 |
* @param {boolean|object} overrideContext If set to true, fn will execute
|
|
881 |
* @param {boolean|object} overrideContext If set to true, fn will execute |
|
882 | 882 |
* in the context of obj, if set to an object it |
883 | 883 |
* will execute in the context of that object |
884 | 884 |
* |
885 |
* @static
|
|
885 |
* @static |
|
886 | 886 |
*/ |
887 | 887 |
// onDOMReady: function(fn, obj, overrideContext) { |
888 | 888 |
onDOMReady: function() { |
... | ... | |
893 | 893 |
/** |
894 | 894 |
* Appends an event handler |
895 | 895 |
* |
896 |
* @method _addListener
|
|
896 |
* @method _addListener |
|
897 | 897 |
* |
898 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
898 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
899 | 899 |
* reference, or a collection of ids and/or elements to assign the |
900 | 900 |
* listener to. |
901 |
* @param {String} sType The type of event to append
|
|
902 |
* @param {Function} fn The method the event invokes
|
|
903 |
* @param {Object} obj An arbitrary object that will be
|
|
901 |
* @param {String} sType The type of event to append |
|
902 |
* @param {Function} fn The method the event invokes |
|
903 |
* @param {Object} obj An arbitrary object that will be |
|
904 | 904 |
* passed as a parameter to the handler |
905 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
905 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
906 | 906 |
* the execution context of the listener. If an |
907 | 907 |
* object, this object becomes the execution |
908 | 908 |
* context. |
909 |
* @param {boolen} capture capture or bubble phase
|
|
910 |
* @return {Boolean} True if the action was successful or defered,
|
|
909 |
* @param {boolen} capture capture or bubble phase |
|
910 |
* @return {Boolean} True if the action was successful or defered, |
|
911 | 911 |
* false if one or more of the elements |
912 | 912 |
* could not have the listener attached, |
913 | 913 |
* or if the operation throws an exception. |
914 |
* @private
|
|
915 |
* @static
|
|
914 |
* @private |
|
915 |
* @static |
|
916 | 916 |
*/ |
917 | 917 |
_addListener: function(el, sType, fn, obj, overrideContext, bCapture) { |
918 | 918 |
|
... | ... | |
1016 | 1016 |
* (as defined by the _specialTypes hash), and (if so) returns |
1017 | 1017 |
* the special type name. |
1018 | 1018 |
* |
1019 |
* @method _getType
|
|
1019 |
* @method _getType |
|
1020 | 1020 |
* |
1021 |
* @param {String} sType The type to look up
|
|
1022 |
* @private
|
|
1021 |
* @param {String} sType The type to look up |
|
1022 |
* @private |
|
1023 | 1023 |
*/ |
1024 | 1024 |
_getType: function (type) { |
1025 | 1025 |
|
... | ... | |
1031 | 1031 |
/** |
1032 | 1032 |
* Appends an event handler |
1033 | 1033 |
* |
1034 |
* @method addListener
|
|
1034 |
* @method addListener |
|
1035 | 1035 |
* |
1036 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1036 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1037 | 1037 |
* reference, or a collection of ids and/or elements to assign the |
1038 | 1038 |
* listener to. |
1039 |
* @param {String} sType The type of event to append
|
|
1040 |
* @param {Function} fn The method the event invokes
|
|
1041 |
* @param {Object} obj An arbitrary object that will be
|
|
1039 |
* @param {String} sType The type of event to append |
|
1040 |
* @param {Function} fn The method the event invokes |
|
1041 |
* @param {Object} obj An arbitrary object that will be |
|
1042 | 1042 |
* passed as a parameter to the handler |
1043 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
1043 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
1044 | 1044 |
* the execution context of the listener. If an |
1045 | 1045 |
* object, this object becomes the execution |
1046 | 1046 |
* context. |
1047 |
* @return {Boolean} True if the action was successful or defered,
|
|
1047 |
* @return {Boolean} True if the action was successful or defered, |
|
1048 | 1048 |
* false if one or more of the elements |
1049 | 1049 |
* could not have the listener attached, |
1050 | 1050 |
* or if the operation throws an exception. |
1051 |
* @static
|
|
1051 |
* @static |
|
1052 | 1052 |
*/ |
1053 | 1053 |
addListener: function (el, sType, fn, obj, overrideContext) { |
1054 | 1054 |
|
... | ... | |
1063 | 1063 |
* Attaches a focusin event listener to the specified element for |
1064 | 1064 |
* the purpose of listening for the focus event on the element's |
1065 | 1065 |
* descendants. |
1066 |
* @method addFocusListener
|
|
1066 |
* @method addFocusListener |
|
1067 | 1067 |
* |
1068 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1068 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1069 | 1069 |
* reference, or a collection of ids and/or elements to assign the |
1070 | 1070 |
* listener to. |
1071 |
* @param {Function} fn The method the event invokes
|
|
1072 |
* @param {Object} obj An arbitrary object that will be
|
|
1071 |
* @param {Function} fn The method the event invokes |
|
1072 |
* @param {Object} obj An arbitrary object that will be |
|
1073 | 1073 |
* passed as a parameter to the handler |
1074 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
1074 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
1075 | 1075 |
* the execution context of the listener. If an |
1076 | 1076 |
* object, this object becomes the execution |
1077 | 1077 |
* context. |
1078 |
* @return {Boolean} True if the action was successful or defered,
|
|
1078 |
* @return {Boolean} True if the action was successful or defered, |
|
1079 | 1079 |
* false if one or more of the elements |
1080 | 1080 |
* could not have the listener attached, |
1081 | 1081 |
* or if the operation throws an exception. |
1082 |
* @static
|
|
1082 |
* @static |
|
1083 | 1083 |
* @deprecated use YAHOO.util.Event.on and specify "focusin" as the event type. |
1084 | 1084 |
*/ |
1085 | 1085 |
addFocusListener: function (el, fn, obj, overrideContext) { |
... | ... | |
1092 | 1092 |
* the purpose of listening for the focus event on the element's |
1093 | 1093 |
* descendants. |
1094 | 1094 |
* |
1095 |
* @method removeFocusListener
|
|
1095 |
* @method removeFocusListener |
|
1096 | 1096 |
* |
1097 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1097 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1098 | 1098 |
* reference, or a collection of ids and/or elements to remove |
1099 | 1099 |
* the listener from. |
1100 |
* @param {Function} fn the method the event invokes. If fn is
|
|
1100 |
* @param {Function} fn the method the event invokes. If fn is |
|
1101 | 1101 |
* undefined, then all event handlers for the type of event are |
1102 | 1102 |
* removed. |
1103 |
* @return {boolean} true if the unbind was successful, false
|
|
1103 |
* @return {boolean} true if the unbind was successful, false |
|
1104 | 1104 |
* otherwise. |
1105 |
* @static
|
|
1105 |
* @static |
|
1106 | 1106 |
* @deprecated use YAHOO.util.Event.removeListener and specify "focusin" as the event type. |
1107 | 1107 |
*/ |
1108 | 1108 |
removeFocusListener: function (el, fn) { |
... | ... | |
1114 | 1114 |
* the purpose of listening for the blur event on the element's |
1115 | 1115 |
* descendants. |
1116 | 1116 |
* |
1117 |
* @method addBlurListener
|
|
1117 |
* @method addBlurListener |
|
1118 | 1118 |
* |
1119 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1119 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1120 | 1120 |
* reference, or a collection of ids and/or elements to assign the |
1121 | 1121 |
* listener to. |
1122 |
* @param {Function} fn The method the event invokes
|
|
1123 |
* @param {Object} obj An arbitrary object that will be
|
|
1122 |
* @param {Function} fn The method the event invokes |
|
1123 |
* @param {Object} obj An arbitrary object that will be |
|
1124 | 1124 |
* passed as a parameter to the handler |
1125 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes
|
|
1125 |
* @param {Boolean|object} overrideContext If true, the obj passed in becomes |
|
1126 | 1126 |
* the execution context of the listener. If an |
1127 | 1127 |
* object, this object becomes the execution |
1128 | 1128 |
* context. |
1129 |
* @return {Boolean} True if the action was successful or defered,
|
|
1129 |
* @return {Boolean} True if the action was successful or defered, |
|
1130 | 1130 |
* false if one or more of the elements |
1131 | 1131 |
* could not have the listener attached, |
1132 | 1132 |
* or if the operation throws an exception. |
1133 |
* @static
|
|
1133 |
* @static |
|
1134 | 1134 |
* @deprecated use YAHOO.util.Event.on and specify "focusout" as the event type. |
1135 | 1135 |
*/ |
1136 | 1136 |
addBlurListener: function (el, fn, obj, overrideContext) { |
... | ... | |
1142 | 1142 |
* the purpose of listening for the blur event on the element's |
1143 | 1143 |
* descendants. |
1144 | 1144 |
* |
1145 |
* @method removeBlurListener
|
|
1145 |
* @method removeBlurListener |
|
1146 | 1146 |
* |
1147 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1147 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1148 | 1148 |
* reference, or a collection of ids and/or elements to remove |
1149 | 1149 |
* the listener from. |
1150 |
* @param {Function} fn the method the event invokes. If fn is
|
|
1150 |
* @param {Function} fn the method the event invokes. If fn is |
|
1151 | 1151 |
* undefined, then all event handlers for the type of event are |
1152 | 1152 |
* removed. |
1153 |
* @return {boolean} true if the unbind was successful, false
|
|
1153 |
* @return {boolean} true if the unbind was successful, false |
|
1154 | 1154 |
* otherwise. |
1155 |
* @static
|
|
1155 |
* @static |
|
1156 | 1156 |
* @deprecated use YAHOO.util.Event.removeListener and specify "focusout" as the event type. |
1157 | 1157 |
*/ |
1158 | 1158 |
removeBlurListener: function (el, fn) { |
... | ... | |
1162 | 1162 |
/** |
1163 | 1163 |
* Removes an event listener |
1164 | 1164 |
* |
1165 |
* @method removeListener
|
|
1165 |
* @method removeListener |
|
1166 | 1166 |
* |
1167 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element
|
|
1167 |
* @param {String|HTMLElement|Array|NodeList} el An id, an element |
|
1168 | 1168 |
* reference, or a collection of ids and/or elements to remove |
1169 | 1169 |
* the listener from. |
1170 |
* @param {String} sType the type of event to remove.
|
|
1171 |
* @param {Function} fn the method the event invokes. If fn is
|
|
1170 |
* @param {String} sType the type of event to remove. |
|
1171 |
* @param {Function} fn the method the event invokes. If fn is |
|
1172 | 1172 |
* undefined, then all event handlers for the type of event are |
1173 | 1173 |
* removed. |
1174 |
* @return {boolean} true if the unbind was successful, false
|
|
1174 |
* @return {boolean} true if the unbind was successful, false |
|
1175 | 1175 |
* otherwise. |
1176 |
* @static
|
|
1176 |
* @static |
|
1177 | 1177 |
*/ |
1178 | 1178 |
removeListener: function(el, sType, fn) { |
1179 | 1179 |
var i, len, li; |
... | ... | |
1260 | 1260 |
* Returns the event's target element. Safari sometimes provides |
1261 | 1261 |
* a text node, and this is automatically resolved to the text |
1262 | 1262 |
* node's parent so that it behaves like other browsers. |
1263 |
* @method getTarget
|
|
1264 |
* @param {Event} ev the event
|
|
1265 |
* @param {boolean} resolveTextNode when set to true the target's
|
|
1263 |
* @method getTarget |
|
1264 |
* @param {Event} ev the event |
|
1265 |
* @param {boolean} resolveTextNode when set to true the target's |
|
1266 | 1266 |
* parent will be returned if the target is a |
1267 | 1267 |
* text node. @deprecated, the text node is |
1268 | 1268 |
* now resolved automatically |
1269 |
* @return {HTMLElement} the event's target
|
|
1270 |
* @static
|
|
1269 |
* @return {HTMLElement} the event's target |
|
1270 |
* @static |
|
1271 | 1271 |
*/ |
1272 | 1272 |
getTarget: function(ev, resolveTextNode) { |
1273 | 1273 |
var t = ev.target || ev.srcElement; |
... | ... | |
1278 | 1278 |
* In some cases, some browsers will return a text node inside |
1279 | 1279 |
* the actual element that was targeted. This normalizes the |
1280 | 1280 |
* return value for getTarget and getRelatedTarget. |
1281 |
* @method resolveTextNode
|
|
1282 |
* @param {HTMLElement} node node to resolve
|
|
1283 |
* @return {HTMLElement} the normized node
|
|
1284 |
* @static
|
|
1281 |
* @method resolveTextNode |
|
1282 |
* @param {HTMLElement} node node to resolve |
|
1283 |
* @return {HTMLElement} the normized node |
|
1284 |
* @static |
|
1285 | 1285 |
*/ |
1286 | 1286 |
resolveTextNode: function(n) { |
1287 | 1287 |
try { |
... | ... | |
1295 | 1295 |
|
1296 | 1296 |
/** |
1297 | 1297 |
* Returns the event's pageX |
1298 |
* @method getPageX
|
|
1299 |
* @param {Event} ev the event
|
|
1300 |
* @return {int} the event's pageX
|
|
1301 |
* @static
|
|
1298 |
* @method getPageX |
|
1299 |
* @param {Event} ev the event |
|
1300 |
* @return {int} the event's pageX |
|
1301 |
* @static |
|
1302 | 1302 |
*/ |
1303 | 1303 |
getPageX: function(ev) { |
1304 | 1304 |
var x = ev.pageX; |
... | ... | |
1315 | 1315 |
|
1316 | 1316 |
/** |
1317 | 1317 |
* Returns the event's pageY |
1318 |
* @method getPageY
|
|
1319 |
* @param {Event} ev the event
|
|
1320 |
* @return {int} the event's pageY
|
|
1321 |
* @static
|
|
1318 |
* @method getPageY |
|
1319 |
* @param {Event} ev the event |
|
1320 |
* @return {int} the event's pageY |
|
1321 |
* @static |
|
1322 | 1322 |
*/ |
1323 | 1323 |
getPageY: function(ev) { |
1324 | 1324 |
var y = ev.pageY; |
... | ... | |
1336 | 1336 |
|
1337 | 1337 |
/** |
1338 | 1338 |
* Returns the pageX and pageY properties as an indexed array. |
1339 |
* @method getXY
|
|
1340 |
* @param {Event} ev the event
|
|
1341 |
* @return {[x, y]} the pageX and pageY properties of the event
|
|
1342 |
* @static
|
|
1339 |
* @method getXY |
|
1340 |
* @param {Event} ev the event |
|
1341 |
* @return {[x, y]} the pageX and pageY properties of the event |
|
1342 |
* @static |
|
1343 | 1343 |
*/ |
1344 | 1344 |
getXY: function(ev) { |
1345 | 1345 |
return [this.getPageX(ev), this.getPageY(ev)]; |
... | ... | |
1347 | 1347 |
|
1348 | 1348 |
/** |
1349 | 1349 |
* Returns the event's related target |
1350 |
* @method getRelatedTarget
|
|
1351 |
* @param {Event} ev the event
|
|
1352 |
* @return {HTMLElement} the event's relatedTarget
|
|
1353 |
* @static
|
|
1350 |
* @method getRelatedTarget |
|
1351 |
* @param {Event} ev the event |
|
1352 |
* @return {HTMLElement} the event's relatedTarget |
|
1353 |
* @static |
|
1354 | 1354 |
*/ |
1355 | 1355 |
getRelatedTarget: function(ev) { |
1356 | 1356 |
var t = ev.relatedTarget; |
... | ... | |
1368 | 1368 |
/** |
1369 | 1369 |
* Returns the time of the event. If the time is not included, the |
1370 | 1370 |
* event is modified using the current time. |
1371 |
* @method getTime
|
|
1372 |
* @param {Event} ev the event
|
|
1373 |
* @return {Date} the time of the event
|
|
1374 |
* @static
|
|
1371 |
* @method getTime |
|
1372 |
* @param {Event} ev the event |
|
1373 |
* @return {Date} the time of the event |
|
1374 |
* @static |
|
1375 | 1375 |
*/ |
1376 | 1376 |
getTime: function(ev) { |
1377 | 1377 |
if (!ev.time) { |
... | ... | |
1389 | 1389 |
|
1390 | 1390 |
/** |
1391 | 1391 |
* Convenience method for stopPropagation + preventDefault |
1392 |
* @method stopEvent
|
|
1393 |
* @param {Event} ev the event
|
|
1394 |
* @static
|
|
1392 |
* @method stopEvent |
|
1393 |
* @param {Event} ev the event |
|
1394 |
* @static |
|
1395 | 1395 |
*/ |
1396 | 1396 |
stopEvent: function(ev) { |
1397 | 1397 |
this.stopPropagation(ev); |
... | ... | |
1400 | 1400 |
|
1401 | 1401 |
/** |
1402 | 1402 |
* Stops event propagation |
1403 |
* @method stopPropagation
|
|
1404 |
* @param {Event} ev the event
|
|
1405 |
* @static
|
|
1403 |
* @method stopPropagation |
|
1404 |
* @param {Event} ev the event |
|
1405 |
* @static |
|
1406 | 1406 |
*/ |
1407 | 1407 |
stopPropagation: function(ev) { |
1408 | 1408 |
if (ev.stopPropagation) { |
... | ... | |
1414 | 1414 |
|
1415 | 1415 |
/** |
1416 | 1416 |
* Prevents the default behavior of the event |
1417 |
* @method preventDefault
|
|
1418 |
* @param {Event} ev the event
|
|
1419 |
* @static
|
|
1417 |
* @method preventDefault |
|
1418 |
* @param {Event} ev the event |
|
1419 |
* @static |
|
1420 | 1420 |
*/ |
1421 | 1421 |
preventDefault: function(ev) { |
1422 | 1422 |
if (ev.preventDefault) { |
... | ... | |
1432 | 1432 |
* executed automatically for events registered through the event |
1433 | 1433 |
* manager, so the implementer should not normally need to execute |
1434 | 1434 |
* this function at all. |
1435 |
* @method getEvent
|
|
1436 |
* @param {Event} e the event parameter from the handler
|
|
1437 |
* @param {HTMLElement} boundEl the element the listener is attached to
|
|
1438 |
* @return {Event} the event
|
|
1439 |
* @static
|
|
1435 |
* @method getEvent |
|
1436 |
* @param {Event} e the event parameter from the handler |
|
1437 |
* @param {HTMLElement} boundEl the element the listener is attached to |
|
1438 |
* @return {Event} the event |
|
1439 |
* @static |
|
1440 | 1440 |
*/ |
1441 | 1441 |
getEvent: function(e, boundEl) { |
1442 | 1442 |
var ev = e || window.event; |
... | ... | |
1457 | 1457 |
|
1458 | 1458 |
/** |
1459 | 1459 |
* Returns the charcode for an event |
1460 |
* @method getCharCode
|
|
1461 |
* @param {Event} ev the event
|
|
1462 |
* @return {int} the event's charCode
|
|
1463 |
* @static
|
|
1460 |
* @method getCharCode |
|
1461 |
* @param {Event} ev the event |
|
1462 |
* @return {int} the event's charCode |
|
1463 |
* @static |
|
1464 | 1464 |
*/ |
1465 | 1465 |
getCharCode: function(ev) { |
1466 | 1466 |
var code = ev.keyCode || ev.charCode || 0; |
... | ... | |
1475 | 1475 |
/** |
1476 | 1476 |
* Locating the saved event handler data by function ref |
1477 | 1477 |
* |
1478 |
* @method _getCacheIndex
|
|
1479 |
* @static
|
|
1480 |
* @private
|
|
1478 |
* @method _getCacheIndex |
|
1479 |
* @static |
|
1480 |
* @private |
|
1481 | 1481 |
*/ |
1482 | 1482 |
_getCacheIndex: function(a, el, sType, fn) { |
1483 | 1483 |
for (var i=0, l=a.length; i<l; i=i+1) { |
... | ... | |
1496 | 1496 |
/** |
1497 | 1497 |
* Generates an unique ID for the element if it does not already |
1498 | 1498 |
* have one. |
1499 |
* @method generateId
|
|
1500 |
* @param el the element to create the id for
|
|
1501 |
* @return {string} the resulting id of the element
|
|
1502 |
* @static
|
|
1499 |
* @method generateId |
|
1500 |
* @param el the element to create the id for |
|
1501 |
* @return {string} the resulting id of the element |
|
1502 |
* @static |
|
1503 | 1503 |
*/ |
1504 | 1504 |
generateId: function(el) { |
1505 | 1505 |
var id = el.id; |
... | ... | |
1520 | 1520 |
* browsers return different types of collections. This function |
1521 | 1521 |
* tests to determine if the object is array-like. It will also |
1522 | 1522 |
* fail if the object is an array, but is empty. |
1523 |
* @method _isValidCollection
|
|
1524 |
* @param o the object to test
|
|
1525 |
* @return {boolean} true if the object is array-like and populated
|
|
1526 |
* @static
|
|
1527 |
* @private
|
|
1523 |
* @method _isValidCollection |
|
1524 |
* @param o the object to test |
|
1525 |
* @return {boolean} true if the object is array-like and populated |
|
1526 |
* @static |
|
1527 |
* @private |
|
1528 | 1528 |
*/ |
1529 | 1529 |
_isValidCollection: function(o) { |
1530 | 1530 |
try { |
... | ... | |
1542 | 1542 |
}, |
1543 | 1543 |
|
1544 | 1544 |
/** |
1545 |
* @private
|
|
1546 |
* @property elCache
|
|
1545 |
* @private |
|
1546 |
* @property elCache |
|
1547 | 1547 |
* DOM element cache |
1548 |
* @static
|
|
1549 |
* @deprecated Elements are not cached due to issues that arise when
|
|
1548 |
* @static |
|
1549 |
* @deprecated Elements are not cached due to issues that arise when |
|
1550 | 1550 |
* elements are removed and re-added |
1551 | 1551 |
*/ |
1552 | 1552 |
elCache: {}, |
... | ... | |
1554 | 1554 |
/** |
1555 | 1555 |
* We cache elements bound by id because when the unload event |
1556 | 1556 |
* fires, we can no longer use document.getElementById |
1557 |
* @method getEl
|
|
1558 |
* @static
|
|
1559 |
* @private
|
|
1560 |
* @deprecated Elements are not cached any longer
|
|
1557 |
* @method getEl |
|
1558 |
* @static |
|
1559 |
* @private |
|
1560 |
* @deprecated Elements are not cached any longer |
|
1561 | 1561 |
*/ |
1562 | 1562 |
getEl: function(id) { |
1563 | 1563 |
return (typeof id === "string") ? document.getElementById(id) : id; |
... | ... | |
1565 | 1565 |
|
1566 | 1566 |
/** |
1567 | 1567 |
* Clears the element cache |
1568 |
* @deprecated Elements are not cached any longer
|
|
1569 |
* @method clearCache
|
|
1570 |
* @static
|
|
1571 |
* @private
|
|
1568 |
* @deprecated Elements are not cached any longer |
|
1569 |
* @method clearCache |
|
1570 |
* @static |
|
1571 |
* @private |
|
1572 | 1572 |
*/ |
1573 | 1573 |
clearCache: function() { }, |
1574 | 1574 |
|
1575 | 1575 |
/** |
1576 | 1576 |
* Custom event the fires when the dom is initially usable |
1577 |
* @event DOMReadyEvent
|
|
1577 |
* @event DOMReadyEvent |
|
1578 | 1578 |
*/ |
1579 | 1579 |
DOMReadyEvent: new YAHOO.util.CustomEvent("DOMReady", YAHOO, 0, 0, 1), |
1580 | 1580 |
|
1581 | 1581 |
/** |
1582 | 1582 |
* hook up any deferred listeners |
1583 |
* @method _load
|
|
1584 |
* @static
|
|
1585 |
* @private
|
|
1583 |
* @method _load |
|
1584 |
* @static |
|
1585 |
* @private |
|
1586 | 1586 |
*/ |
1587 | 1587 |
_load: function(e) { |
1588 | 1588 |
|
... | ... | |
1605 | 1605 |
/** |
1606 | 1606 |
* Fires the DOMReady event listeners the first time the document is |
1607 | 1607 |
* usable. |
1608 |
* @method _ready
|
|
1609 |
* @static
|
|
1610 |
* @private
|
|
1608 |
* @method _ready |
|
1609 |
* @static |
|
1610 |
* @private |
|
1611 | 1611 |
*/ |
1612 | 1612 |
_ready: function(e) { |
1613 | 1613 |
var EU = YAHOO.util.Event; |
... | ... | |
1626 | 1626 |
* Polling function that runs before the onload event fires, |
1627 | 1627 |
* attempting to attach to DOM Nodes as soon as they are |
1628 | 1628 |
* available |
1629 |
* @method _tryPreloadAttach
|
|
1630 |
* @static
|
|
1631 |
* @private
|
|
1629 |
* @method _tryPreloadAttach |
|
1630 |
* @static |
|
1631 |
* @private |
|
1632 | 1632 |
*/ |
1633 | 1633 |
_tryPreloadAttach: function() { |
1634 | 1634 |
|
... | ... | |
1741 | 1741 |
* Removes all listeners attached to the given element via addListener. |
1742 | 1742 |
* Optionally, the node's children can also be purged. |
1743 | 1743 |
* Optionally, you can specify a specific type of event to remove. |
1744 |
* @method purgeElement
|
|
1745 |
* @param {HTMLElement} el the element to purge
|
|
1746 |
* @param {boolean} recurse recursively purge this element's children
|
|
1744 |
* @method purgeElement |
|
1745 |
* @param {HTMLElement} el the element to purge |
|
1746 |
* @param {boolean} recurse recursively purge this element's children |
|
1747 | 1747 |
* as well. Use with caution. |
1748 |
* @param {string} sType optional type of listener to purge. If
|
|
1748 |
* @param {string} sType optional type of listener to purge. If |
|
1749 | 1749 |
* left out, all listeners will be removed |
1750 |
* @static
|
|
1750 |
* @static |
|
1751 | 1751 |
*/ |
1752 | 1752 |
purgeElement: function(el, recurse, sType) { |
1753 | 1753 |
var oEl = (YAHOO.lang.isString(el)) ? this.getEl(el) : el; |
... | ... | |
1769 | 1769 |
/** |
1770 | 1770 |
* Returns all listeners attached to the given element via addListener. |
1771 | 1771 |
* Optionally, you can specify a specific type of event to return. |
1772 |
* @method getListeners
|
|
1773 |
* @param el {HTMLElement|string} the element or element id to inspect
|
|
1774 |
* @param sType {string} optional type of listener to return. If
|
|
1772 |
* @method getListeners |
|
1773 |
* @param el {HTMLElement|string} the element or element id to inspect |
|
1774 |
* @param sType {string} optional type of listener to return. If |
|
1775 | 1775 |
* left out, all listeners will be returned |
1776 |
* @return {Object} the listener. Contains the following fields:
|
|
1776 |
* @return {Object} the listener. Contains the following fields: |
|
1777 | 1777 |
* type: (string) the type of event |
1778 | 1778 |
* fn: (function) the callback supplied to addListener |
1779 | 1779 |
* obj: (object) the custom object supplied to addListener |
1780 | 1780 |
* adjust: (boolean|object) whether or not to adjust the default context |
1781 | 1781 |
* scope: (boolean) the derived context based on the adjust parameter |
1782 | 1782 |
* index: (int) its position in the Event util listener cache |
1783 |
* @static
|
|
1783 |
* @static |
|
1784 | 1784 |
*/ |
1785 | 1785 |
getListeners: function(el, sType) { |
1786 | 1786 |
var results=[], searchLists; |
... | ... | |
1821 | 1821 |
/** |
1822 | 1822 |
* Removes all listeners registered by pe.event. Called |
1823 | 1823 |
* automatically during the unload event. |
1824 |
* @method _unload
|
|
1825 |
* @static
|
|
1826 |
* @private
|
|
1824 |
* @method _unload |
|
1825 |
* @static |
|
1826 |
* @private |
|
1827 | 1827 |
*/ |
1828 | 1828 |
_unload: function(e) { |
1829 | 1829 |
|
... | ... | |
1872 | 1872 |
|
1873 | 1873 |
/** |
1874 | 1874 |
* Returns scrollLeft |
1875 |
* @method _getScrollLeft
|
|
1876 |
* @static
|
|
1877 |
* @private
|
|
1875 |
* @method _getScrollLeft |
|
1876 |
* @static |
|
1877 |
* @private |
|
1878 | 1878 |
*/ |
1879 | 1879 |
_getScrollLeft: function() { |
1880 | 1880 |
return this._getScroll()[1]; |
... | ... | |
1882 | 1882 |
|
1883 | 1883 |
/** |
1884 | 1884 |
* Returns scrollTop |
1885 |
* @method _getScrollTop
|
|
1886 |
* @static
|
|
1887 |
* @private
|
|
1885 |
* @method _getScrollTop |
|
1886 |
* @static |
|
1887 |
* @private |
|
1888 | 1888 |
*/ |
1889 | 1889 |
_getScrollTop: function() { |
1890 | 1890 |
return this._getScroll()[0]; |
... | ... | |
1893 | 1893 |
/** |
1894 | 1894 |
* Returns the scrollTop and scrollLeft. Used to calculate the |
1895 | 1895 |
* pageX and pageY in Internet Explorer |
1896 |
* @method _getScroll
|
|
1897 |
* @static
|
|
1898 |
* @private
|
|
1896 |
* @method _getScroll |
|
1897 |
* @static |
|
1898 |
* @private |
|
1899 | 1899 |
*/ |
1900 | 1900 |
_getScroll: function() { |
1901 | 1901 |
var dd = document.documentElement, db = document.body; |
... | ... | |
1911 | 1911 |
/** |
1912 | 1912 |
* Used by old versions of CustomEvent, restored for backwards |
1913 | 1913 |
* compatibility |
1914 |
* @method regCE
|
|
1915 |
* @private
|
|
1916 |
* @static
|
|
1917 |
* @deprecated still here for backwards compatibility
|
|
1914 |
* @method regCE |
|
1915 |
* @private |
|
1916 |
* @static |
|
1917 |
* @deprecated still here for backwards compatibility |
|
1918 | 1918 |
*/ |
1919 | 1919 |
regCE: function() {}, |
1920 | 1920 |
|
1921 | 1921 |
/** |
1922 | 1922 |
* Adds a DOM event directly without the caching, cleanup, context adj, etc |
1923 | 1923 |
* |
1924 |
* @method _simpleAdd
|
|
1925 |
* @param {HTMLElement} el the element to bind the handler to
|
|
1926 |
* @param {string} sType the type of event handler
|
|
1927 |
* @param {function} fn the callback to invoke
|
|
1928 |
* @param {boolen} capture capture or bubble phase
|
|
1929 |
* @static
|
|
1930 |
* @private
|
|
1924 |
* @method _simpleAdd |
|
1925 |
* @param {HTMLElement} el the element to bind the handler to |
|
1926 |
* @param {string} sType the type of event handler |
|
1927 |
* @param {function} fn the callback to invoke |
|
1928 |
* @param {boolen} capture capture or bubble phase |
|
1929 |
* @static |
|
1930 |
* @private |
|
1931 | 1931 |
*/ |
1932 | 1932 |
_simpleAdd: function () { |
1933 | 1933 |
if (window.addEventListener) { |
... | ... | |
1946 | 1946 |
/** |
1947 | 1947 |
* Basic remove listener |
1948 | 1948 |
* |
1949 |
* @method _simpleRemove
|
|
1950 |
* @param {HTMLElement} el the element to bind the handler to
|
|
1951 |
* @param {string} sType the type of event handler
|
|
1952 |
* @param {function} fn the callback to invoke
|
|
1953 |
* @param {boolen} capture capture or bubble phase
|
|
1954 |
* @static
|
|
1955 |
* @private
|
|
1949 |
* @method _simpleRemove |
|
1950 |
* @param {HTMLElement} el the element to bind the handler to |
|
1951 |
* @param {string} sType the type of event handler |
|
1952 |
* @param {function} fn the callback to invoke |
|
1953 |
* @param {boolen} capture capture or bubble phase |
|
1954 |
* @static |
|
1955 |
* @private |
|
1956 | 1956 |
*/ |
1957 | 1957 |
_simpleRemove: function() { |
1958 | 1958 |
if (window.removeEventListener) { |
... | ... | |
1976 | 1976 |
|
1977 | 1977 |
/** |
1978 | 1978 |
* YAHOO.util.Event.on is an alias for addListener |
1979 |
* @method on
|
|
1980 |
* @see addListener
|
|
1981 |
* @static
|
|
1979 |
* @method on |
|
1980 |
* @see addListener |
|
1981 |
* @static |
|
1982 | 1982 |
*/ |
1983 | 1983 |
EU.on = EU.addListener; |
1984 | 1984 |
|
1985 | 1985 |
/** |
1986 | 1986 |
* YAHOO.util.Event.onFocus is an alias for addFocusListener |
1987 |
* @method onFocus
|
|
1988 |
* @see addFocusListener
|
|
1989 |
* @static
|
|
1987 |
* @method onFocus |
|
1988 |
* @see addFocusListener |
|
1989 |
* @static |
|
1990 | 1990 |
* @deprecated use YAHOO.util.Event.on and specify "focusin" as the event type. |
1991 | 1991 |
*/ |
1992 | 1992 |
EU.onFocus = EU.addFocusListener; |
1993 | 1993 |
|
1994 | 1994 |
/** |
1995 | 1995 |
* YAHOO.util.Event.onBlur is an alias for addBlurListener |
1996 |
* @method onBlur
|
|
1997 |
* @see addBlurListener
|
|
1998 |
* @static
|
|
1996 |
* @method onBlur |
|
1997 |
* @see addBlurListener |
|
1998 |
* @static |
|
1999 | 1999 |
* @deprecated use YAHOO.util.Event.on and specify "focusout" as the event type. |
2000 | 2000 |
*/ |
2001 | 2001 |
EU.onBlur = EU.addBlurListener; |
... | ... | |
2081 | 2081 |
|
2082 | 2082 |
/** |
2083 | 2083 |
* Private storage of custom events |
2084 |
* @property __yui_events
|
|
2085 |
* @type Object[]
|
|
2086 |
* @private
|
|
2084 |
* @property __yui_events |
|
2085 |
* @type Object[] |
|
2086 |
* @private |
|
2087 | 2087 |
*/ |
2088 | 2088 |
__yui_events: null, |
2089 | 2089 |
|
2090 | 2090 |
/** |
2091 | 2091 |
* Private storage of custom event subscribers |
2092 |
* @property __yui_subscribers
|
|
2093 |
* @type Object[]
|
|
2094 |
* @private
|
|
2092 |
* @property __yui_subscribers |
|
2093 |
* @type Object[] |
|
2094 |
* @private |
|
2095 | 2095 |
*/ |
2096 | 2096 |
__yui_subscribers: null, |
2097 | 2097 |
|
2098 | 2098 |
/** |
2099 | 2099 |
* Subscribe to a CustomEvent by event type |
2100 | 2100 |
* |
2101 |
* @method subscribe
|
|
2102 |
* @param p_type {string} the type, or name of the event
|
|
2103 |
* @param p_fn {function} the function to exectute when the event fires
|
|
2104 |
* @param p_obj {Object} An object to be passed along when the event
|
|
2101 |
* @method subscribe |
|
2102 |
* @param p_type {string} the type, or name of the event |
|
2103 |
* @param p_fn {function} the function to exectute when the event fires |
|
2104 |
* @param p_obj {Object} An object to be passed along when the event |
|
2105 | 2105 |
* fires |
2106 |
* @param overrideContext {boolean} If true, the obj passed in becomes the
|
|
2106 |
* @param overrideContext {boolean} If true, the obj passed in becomes the |
|
2107 | 2107 |
* execution scope of the listener |
2108 | 2108 |
*/ |
2109 | 2109 |
subscribe: function(p_type, p_fn, p_obj, overrideContext) { |
... | ... | |
2126 | 2126 |
|
2127 | 2127 |
/** |
2128 | 2128 |
* Unsubscribes one or more listeners the from the specified event |
2129 |
* @method unsubscribe
|
|
2130 |
* @param p_type {string} The type, or name of the event. If the type
|
|
2129 |
* @method unsubscribe |
|
2130 |
* @param p_type {string} The type, or name of the event. If the type |
|
2131 | 2131 |
* is not specified, it will attempt to remove |
2132 | 2132 |
* the listener from all hosted events. |
2133 |
* @param p_fn {Function} The subscribed function to unsubscribe, if not
|
|
2133 |
* @param p_fn {Function} The subscribed function to unsubscribe, if not |
|
2134 | 2134 |
* supplied, all subscribers will be removed. |
2135 |
* @param p_obj {Object} The custom object passed to subscribe. This is
|
|
2135 |
* @param p_obj {Object} The custom object passed to subscribe. This is |
|
2136 | 2136 |
* optional, but if supplied will be used to |
2137 | 2137 |
* disambiguate multiple listeners that are the same |
2138 | 2138 |
* (e.g., you subscribe many object using a function |
2139 | 2139 |
* that lives on the prototype) |
2140 |
* @return {boolean} true if the subscriber was found and detached.
|
|
2140 |
* @return {boolean} true if the subscriber was found and detached. |
|
2141 | 2141 |
*/ |
2142 | 2142 |
unsubscribe: function(p_type, p_fn, p_obj) { |
2143 | 2143 |
this.__yui_events = this.__yui_events || {}; |
... | ... | |
2164 | 2164 |
* Removes all listeners from the specified event. If the event type |
2165 | 2165 |
* is not specified, all listeners from all hosted custom events will |
2166 | 2166 |
* be removed. |
2167 |
* @method unsubscribeAll
|
|
2168 |
* @param p_type {string} The type, or name of the event
|
|
2167 |
* @method unsubscribeAll |
|
2168 |
* @param p_type {string} The type, or name of the event |
|
2169 | 2169 |
*/ |
2170 | 2170 |
unsubscribeAll: function(p_type) { |
2171 | 2171 |
return this.unsubscribe(p_type); |
... | ... | |
2176 | 2176 |
* by that name already exists, it will not be re-created. In either |
2177 | 2177 |
* case the custom event is returned. |
2178 | 2178 |
* |
2179 |
* @method createEvent
|
|
2179 |
* @method createEvent |
|
2180 | 2180 |
* |
2181 |
* @param p_type {string} the type, or name of the event
|
|
2182 |
* @param p_config {object} optional config params. Valid properties are:
|
|
2181 |
* @param p_type {string} the type, or name of the event |
|
2182 |
* @param p_config {object} optional config params. Valid properties are: |
|
2183 | 2183 |
* |
2184 | 2184 |
* <ul> |
2185 | 2185 |
* <li> |
... | ... | |
2250 | 2250 |
* <li>The custom object (if any) that was passed into the subscribe() |
2251 | 2251 |
* method</li> |
2252 | 2252 |
* </ul> |
2253 |
* @method fireEvent
|
|
2254 |
* @param p_type {string} the type, or name of the event
|
|
2255 |
* @param arguments {Object*} an arbitrary set of parameters to pass to
|
|
2253 |
* @method fireEvent |
|
2254 |
* @param p_type {string} the type, or name of the event |
|
2255 |
* @param arguments {Object*} an arbitrary set of parameters to pass to |
|
2256 | 2256 |
* the handler. |
2257 |
* @return {boolean} the return value from CustomEvent.fire
|
|
2257 |
* @return {boolean} the return value from CustomEvent.fire |
|
2258 | 2258 |
* |
2259 | 2259 |
*/ |
2260 | 2260 |
fireEvent: function(p_type) { |
... | ... | |
2277 | 2277 |
/** |
2278 | 2278 |
* Returns true if the custom event of the provided type has been created |
2279 | 2279 |
* with createEvent. |
2280 |
* @method hasEvent
|
|
2281 |
* @param type {string} the type, or name of the event
|
|
2280 |
* @method hasEvent |
|
2281 |
* @param type {string} the type, or name of the event |
|
2282 | 2282 |
*/ |
2283 | 2283 |
hasEvent: function(type) { |
Also available in: Unified diff
fixed headerinfos