PageRenderTime 121ms CodeModel.GetById 61ms app.highlight 1ms RepoModel.GetById 43ms app.codeStats 0ms

/Documentation/Help/scripts/EventUtilities.js

#
JavaScript | 23 lines | 15 code | 2 blank | 6 comment | 5 complexity | 3a50f9fd4558e642dcc289383e9212dd MD5 | raw file
 1
 2	// attach a handler to a particular event on an element
 3	// in a browser-independent way
 4	function registerEventHandler (element, event, handler) {
 5		if (element.attachEvent) {
 6			// MS registration model
 7			element.attachEvent('on' + event, handler);
 8		} else if (element.addEventListener) {
 9			// NN (W4C) regisration model
10			element.addEventListener(event, handler, false);
11		} else {
12			// old regisration model as fall-back
13			element[event] = handler;
14		}
15	}
16
17	// get a delegate that refers to an instance method
18	function getInstanceDelegate (obj, methodName) {
19		return( function(e) {
20			e = e || window.event;
21			return obj[methodName](e);
22		} );
23	}