summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Presentation/vs2005/Scripts/EventUtilities.js
blob: 1828a11f4853ac62abdb268afc3b9546d4ce1add (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

	// attach a handler to a particular event on an element
	// in a browser-independent way
	function registerEventHandler (element, event, handler) {
		if (element.attachEvent) {
			// MS registration model
			element.attachEvent('on' + event, handler);
		} else if (element.addEventListener) {
			// NN (W4C) regisration model
			element.addEventListener(event, handler, false);
		} else {
			// old regisration model as fall-back
			element[event] = handler;
		}
	}

	// get a delegate that refers to an instance method
	function getInstanceDelegate (obj, methodName) {
		return( function(e) {
			e = e || window.event;
			return obj[methodName](e);
		} );
	}