1(function(){ 2 function Event(type,origin,extra) { 3 if (typeof(type)!='string') { 4 throw "Invalid event type"; 5 } 6 this.type=type; 7 this.origin=origin || window; 8 this.opts=extra || {}; 9 this._propagate=true; 10 } 11 Event.prototype.stopPropagation=function(){ 12 this._propagate=false; 13 } 14 var events={}; 15 var EventEmitter = function(){} 16 EventEmitter.prototype = (function(){ return { 17 "emit": function(type,origin,extra){ 18 var handler,e,i,listeners; 19 if(!events) 20 events = {}; 21 handler = events[type]; 22 if(typeof(handler)=="undefined") 23 return false; 24 extra=extra || {}; 25 origin=origin || window; 26 e=new Event(type,origin,extra); 27 listeners = handler.slice(); 28 for(i=0;i<listeners.length; i++){ 29 listeners[i].h.call(listeners[i].ctx,e,listeners[i].opts); 30 if(!e._propagate) 31 break; 32 } 33 return true; 34 }, 35 "on": function(type,listener,bind_to,extra){ 36 if(typeof(listener)!="function") 37 throw "Listener must be a function"; 38 if(!events) 39 events = {}; 40 if(!events[type]) 41 events[type] = []; 42 extra=extra || {}; 43 bind_to=bind_to || window; 44 events[type].push({ 45 h: listener, 46 opts: extra, 47 ctx: bind_to 48 }); 49 return this; 50 }, 51 "once": function(type,listener,origin,extra){ 52 if(typeof(listener)!="function") 53 throw "Listener must be a function"; 54 extra=extra || {}; 55 origin=origin || window; 56 var fired = false; 57 var self=this; 58 function g(e) { 59 self.removeListener(type, g); 60 if(!fired) { 61 fired = true; 62 listener.call(origin,e,extra); 63 } 64 } 65 g.listener = listener; 66 this.on(type,g,origin,extra); 67 return this; 68 }, 69 "removeListener": function(type,listener){ 70 var list, position, length, i; 71 if(typeof(listener)!="function") 72 throw "Listener must be a function"; 73 if(!events || !events[type]) 74 return this; 75 list = events[type]; 76 length = list.length; 77 position = -1; 78 for(i = length; i-- > 0;) { 79 if(list[i].h === listener) { 80 position = i; 81 break; 82 } 83 } 84 if(position < 0) 85 return this; 86 if(list.length === 1) { 87 list.length = 0; 88 delete events[type]; 89 } else 90 list.splice(position,1); 91 return this; 92 } 93 } })(); 94 runCore.class_method({"events": (function(){ 95 var eventMachine; 96 return function(){ 97 if(typeof(eventMachine)=="undefined") 98 eventMachine=new EventEmitter(); 99 return eventMachine; 100 } 101 })() }); 102})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.