]> git.proxmox.com Git - sencha-touch.git/blob - src/src/core/EventManager.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / src / core / EventManager.js
1 //@tag dom,core
2 //@define Ext.EventManager
3 //@define Ext.core.EventManager
4 //@require Ext.Loader
5
6 /**
7 * @class Ext.EventManager
8 *
9 * This object has been deprecated in Sencha Touch 2.0.0. Please refer to the method documentation for specific alternatives.
10 *
11 * @deprecated 2.0.0
12 * @singleton
13 * @private
14 */
15
16 //<deprecated product=touch since=2.0>
17 Ext.ns('Ext.core');
18 Ext.core.EventManager =
19 Ext.EventManager = {
20 /**
21 * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
22 * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
23 * @param {String/HTMLElement} el The HTML element or `id` to assign the event handler to.
24 * @param {String} eventName The name of the event to listen for.
25 * @param {Function} handler The handler function the event invokes. This function is passed
26 * the following parameters:
27 * @param {Ext.EventObject} handler.evt The {@link Ext.EventObject EventObject} describing the event.
28 * @param {Ext.Element} handler.t The {@link Ext.Element Element} which was the target of the event.
29 * Note that this may be filtered by using the `delegate` option.
30 * @param {Object} handler.o The options object from the addListener call.
31 * @param {Object} scope (optional) The scope (`this` reference) in which the handler function is executed. __Defaults to the Element__.
32 * @param {Object} options (optional) An object containing handler configuration properties.
33 * This may contain any of the following properties:
34 * @param {Object} [options.scope] The scope (`this` reference) in which the handler function is executed. __Defaults to the Element__.
35 * @param {String} [options.delegate] A simple selector to filter the target or look for a descendant of the target.
36 * @param {Boolean} [options.stopEvent] `true` to stop the event. That is stop propagation, and prevent the default action.
37 * @param {Boolean} [options.preventDefault] `true` to prevent the default action.
38 * @param {Boolean} [options.stopPropagation] `true` to prevent event propagation.
39 * @param {Boolean} [options.normalized] `false` to pass a browser event to the handler function instead of an Ext.EventObject.
40 * @param {Number} [options.delay] The number of milliseconds to delay the invocation of the handler after the event fires.
41 * @param {Boolean} [options.single] `true` to add a handler to handle just the next firing of the event, and then remove itself.
42 * @param {Number} [options.buffer] Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
43 * by the specified number of milliseconds. If the event fires again within that time, the original
44 * handler is _not_ invoked, but the new handler is scheduled in its place.
45 * @param {Ext.Element} [options.target] Only call the handler if the event was fired on the target Element, _not_ if the event was bubbled up from a child node.
46 *
47 * See {@link Ext.Element#addListener} for examples of how to use these options.
48 * @deprecated 2.0.0 Please use {@link Ext.dom.Element#addListener addListener} on an instance of Ext.Element instead.
49 */
50 addListener: function(element, eventName, fn, scope, options) {
51 //<debug warn>
52 Ext.Logger.deprecate("Ext.EventManager.addListener is deprecated, use addListener() directly from an instance of Ext.Element instead", 2);
53 //</debug>
54 element.on(eventName, fn, scope, options);
55 },
56
57 /**
58 * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
59 * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
60 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
61 * @param {String} eventName The name of the event.
62 * @param {Function} fn The handler function to remove. __This must be a reference to the function passed into the {@link #addListener} call.__
63 * @param {Object} scope If a scope (`this` reference) was specified when the listener was added,
64 * then this must refer to the same object.
65 * @deprecated 2.0.0 Please use {@link Ext.dom.Element#removeListener removeListener} on an instance of Ext.Element instead.
66 */
67 removeListener: function(element, eventName, fn, scope) {
68 //<debug warn>
69 Ext.Logger.deprecate("Ext.EventManager.removeListener is deprecated, use removeListener() directly from an instance of Ext.Element instead", 2);
70 //</debug>
71 element.un(eventName, fn, scope);
72 },
73
74 /**
75 * Removes all event handers from an element. Typically you will use {@link Ext.Element#clearListeners}
76 * directly on an Element in favor of calling this version.
77 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
78 * @deprecated 2.0.0 Please use {@link Ext.dom.Element#clearListeners clearListeners} on an instance of Ext.Element instead.
79 */
80 removeAll: function(element){
81 //<debug warn>
82 Ext.Logger.deprecate("Ext.EventManager.removeAll is deprecated, use clearListeners() directly from an instance of Ext.Element instead", 3);
83 //</debug>
84 Ext.get(element).clearListeners();
85 },
86
87 /**
88 * Adds a listener to be notified when the document is ready (before `onload` and before images are loaded).
89 * @removed 2.0.0 Please use {@link Ext#onReady onReady}
90 */
91 onDocumentReady: function() {
92 //<debug warn>
93 Ext.Logger.deprecate("Ext.EventManager.onDocumentReady has been removed, please use Ext.onReady instead", 3);
94 //</debug>
95 },
96
97 /**
98 * Adds a listener to be notified when the browser window is resized and provides resize event buffering (50 milliseconds),
99 * passes new viewport width and height to handlers.
100 * @param {Function} fn The handler function the window resize event invokes.
101 * @param {Object} scope The scope (`this` reference) in which the handler function executes. Defaults to the browser window.
102 * @param {Boolean} options Options object as passed to {@link Ext.Element#addListener}
103 * @deprecated 2.0.0 Please listen to the {@link Ext.Viewport#event-resize resize} on Ext.Viewport instead.
104 */
105 onWindowResize: function(fn, scope, options) {
106 //<debug warn>
107 Ext.Logger.deprecate("Ext.EventManager.onWindowResize is deprecated, attach listener to Ext.Viewport instead, i.e: Ext.Viewport.on('resize', ...)", 2);
108 //</debug>
109 Ext.Viewport.on('resize', fn, scope, options);
110 },
111
112 onOrientationChange: function(fn, scope, options) {
113 //<debug warn>
114 Ext.Logger.deprecate("Ext.EventManager.onOrientationChange is deprecated, attach listener to Ext.Viewport instead, i.e: Ext.Viewport.on('orientationchange', ...)", 2);
115 //</debug>
116 Ext.Viewport.on('orientationchange', fn, scope, options);
117 },
118
119 unOrientationChange: function(fn, scope, options) {
120 //<debug warn>
121 Ext.Logger.deprecate("Ext.EventManager.unOrientationChange is deprecated, remove listener from Ext.Viewport instead, i.e: Ext.Viewport.un('orientationchange', ...)", 2);
122 //</debug>
123 Ext.Viewport.un('orientationchange', fn, scope, options);
124 }
125 };
126
127 /**
128 * Appends an event handler to an element. Shorthand for {@link #addListener}.
129 * @param {String/HTMLElement} el The html element or id to assign the event handler to.
130 * @param {String} eventName The name of the event to listen for.
131 * @param {Function} handler The handler function the event invokes.
132 * @param {Object} scope (optional) (`this` reference) in which the handler function executes. __Defaults to the Element__.
133 * @param {Object} options (optional) An object containing standard {@link #addListener} options
134 * @member Ext.EventManager
135 * @method on
136 * @deprecated 2.0.0 Please use {@link Ext.dom.Element#addListener addListener} on an instance of Ext.Element instead.
137 */
138 Ext.EventManager.on = Ext.EventManager.addListener;
139
140 /**
141 * Removes an event handler from an element. Shorthand for {@link #removeListener}.
142 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
143 * @param {String} eventName The name of the event.
144 * @param {Function} fn The handler function to remove. __This must be a reference to the function passed into the {@link #on} call.__
145 * @param {Object} scope If a scope (`this` reference) was specified when the listener was added,
146 * then this must refer to the same object.
147 * @member Ext.EventManager
148 * @method un
149 * @deprecated 2.0.0 Please use {@link Ext.dom.Element#removeListener removeListener} on an instance of Ext.Element instead.
150 */
151 Ext.EventManager.un = Ext.EventManager.removeListener;
152 //</deprecated>