MCPcopy
hub / github.com/RubyLouvre/anu / on

Function on

test/jquery.js:4775–4834  ·  view source on GitHub ↗
( elem, types, selector, data, fn, one )

Source from the content-addressed store, hash-verified

4773}
4774
4775function on( elem, types, selector, data, fn, one ) {
4776 var origFn, type;
4777
4778 // Types can be a map of types/handlers
4779 if ( typeof types === "object" ) {
4780
4781 // ( types-Object, selector, data )
4782 if ( typeof selector !== "string" ) {
4783
4784 // ( types-Object, data )
4785 data = data || selector;
4786 selector = undefined;
4787 }
4788 for ( type in types ) {
4789 on( elem, type, selector, data, types[ type ], one );
4790 }
4791 return elem;
4792 }
4793
4794 if ( data == null && fn == null ) {
4795
4796 // ( types, fn )
4797 fn = selector;
4798 data = selector = undefined;
4799 } else if ( fn == null ) {
4800 if ( typeof selector === "string" ) {
4801
4802 // ( types, selector, fn )
4803 fn = data;
4804 data = undefined;
4805 } else {
4806
4807 // ( types, data, fn )
4808 fn = data;
4809 data = selector;
4810 selector = undefined;
4811 }
4812 }
4813 if ( fn === false ) {
4814 fn = returnFalse;
4815 } else if ( !fn ) {
4816 return elem;
4817 }
4818
4819 if ( one === 1 ) {
4820 origFn = fn;
4821 fn = function( event ) {
4822
4823 // Can use an empty set, since event contains the info
4824 jQuery().off( event );
4825 return origFn.apply( this, arguments );
4826 };
4827
4828 // Use same guid so caller can remove using origFn
4829 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4830 }
4831 return elem.each( function() {
4832 jQuery.event.add( this, types, fn, data, selector );

Callers 1

jquery.jsFile · 0.85

Calls 1

jQueryFunction · 0.85

Tested by

no test coverage detected