r25048: From the archives (patch found in one of my old working trees):
[jelmer/samba4-debian.git] / webapps / qooxdoo-0.6.5-sdk / frontend / framework / source / class / qx / html / EventRegistration.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
9
10    License:
11      LGPL: http://www.gnu.org/licenses/lgpl.html
12      EPL: http://www.eclipse.org/org/documents/epl-v10.php
13      See the LICENSE file in the project's top-level directory for details.
14
15    Authors:
16      * Sebastian Werner (wpbasti)
17      * Andreas Ecker (ecker)
18
19 ************************************************************************ */
20
21 /* ************************************************************************
22
23 #module(core)
24 #require(qx.core.Client)
25
26 ************************************************************************ */
27
28 qx.OO.defineClass("qx.html.EventRegistration");
29
30 /**
31  * Assign a function to an event.
32  *
33  * @param vElement {Element} DOM Element
34  * @param vType {String} Name of the event
35  * @param vFunction {Function} The pointer to the function to assign
36  */
37 qx.html.EventRegistration.addEventListener = function(vElement, vType, vFunction) {};
38
39 /**
40  * Unassign a function from an event.
41  *
42  * @param vElement {Element} DOM Element
43  * @param vType {String} Name of the event
44  * @param vFunction {Function} The pointer to the function to assign
45  */
46 qx.html.EventRegistration.removeEventListener = function(vElement, vType, vFunction) {};
47
48 if (qx.core.Client.getInstance().isMshtml())
49 {
50   qx.html.EventRegistration.addEventListener = function(vElement, vType, vFunction) {
51     vElement.attachEvent("on" + vType, vFunction);
52   }
53
54   qx.html.EventRegistration.removeEventListener = function(vElement, vType, vFunction) {
55     vElement.detachEvent("on" + vType, vFunction);
56   }
57 }
58 else
59 {
60   qx.html.EventRegistration.addEventListener = function(vElement, vType, vFunction) {
61     vElement.addEventListener(vType, vFunction, false);
62   }
63
64   qx.html.EventRegistration.removeEventListener = function(vElement, vType, vFunction) {
65     vElement.removeEventListener(vType, vFunction, false);
66   }
67 }