File: EventUtilities.js

package info (click to toggle)
db 5.1.29-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 150,348 kB
  • sloc: ansic: 400,169; java: 94,399; tcl: 70,967; sh: 37,399; cs: 30,758; cpp: 21,132; perl: 14,227; xml: 9,854; makefile: 3,777; yacc: 1,003; awk: 942; sql: 801; erlang: 461; python: 216; php: 24; asm: 14
file content (23 lines) | stat: -rw-r--r-- 685 bytes parent folder | download | duplicates (13)
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);
		} );
	}