MCPcopy Index your code
hub / github.com/mailru/FileAPI / _on

Function _on

lib/FileAPI.core.js:110–135  ·  view source on GitHub ↗
(el, type, fn)

Source from the content-addressed store, hash-verified

108 * Add event listener
109 */
110 _on = function (el, type, fn){
111 if( el ){
112 var uid = api.uid(el);
113
114 if( !_elEvents[uid] ){
115 _elEvents[uid] = {};
116 }
117
118 var isFileReader = (FileReader && el) && (el instanceof FileReader);
119 _each(type.split(/\s+/), function (type){
120 if( jQuery && !isFileReader){
121 jQuery.event.add(el, type, fn);
122 } else {
123 if( !_elEvents[uid][type] ){
124 _elEvents[uid][type] = [];
125 }
126
127 _elEvents[uid][type].push(fn);
128
129 if( el.addEventListener ){ el.addEventListener(type, fn, false); }
130 else if( el.attachEvent ){ el.attachEvent('on'+type, fn); }
131 else { el['on'+type] = fn; }
132 }
133 });
134 }
135 },
136
137
138 /**

Callers 3

_oneFunction · 0.85
FileAPI.core.jsFile · 0.85
_readAsFunction · 0.85

Calls 1

_eachFunction · 0.85

Tested by

no test coverage detected