1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
14 goog.provide('i18n.input.chrome.inputview.events.ConfigLoadedEvent');
15 goog.provide('i18n.input.chrome.inputview.events.ContextUpdateEvent');
16 goog.provide('i18n.input.chrome.inputview.events.DragEvent');
17 goog.provide('i18n.input.chrome.inputview.events.EventType');
18 goog.provide('i18n.input.chrome.inputview.events.LayoutLoadedEvent');
19 goog.provide('i18n.input.chrome.inputview.events.MessageEvent');
20 goog.provide('i18n.input.chrome.inputview.events.PointerEvent');
21 goog.provide('i18n.input.chrome.inputview.events.SurroundingTextChangedEvent');
22 goog.provide('i18n.input.chrome.inputview.events.SwipeEvent');
24 goog.require('goog.events');
25 goog.require('goog.events.Event');
28 goog.scope(function() {
29 var events = i18n.input.chrome.inputview.events;
33 * Event types in input view keyboard.
38 CLICK: goog.events.getUniqueId('c'),
39 CONFIG_LOADED: goog.events.getUniqueId('cl'),
40 DOUBLE_CLICK: goog.events.getUniqueId('dc'),
41 DOUBLE_CLICK_END: goog.events.getUniqueId('dce'),
42 DRAG: goog.events.getUniqueId('dg'),
43 LAYOUT_LOADED: goog.events.getUniqueId('ll'),
44 LONG_PRESS: goog.events.getUniqueId('lp'),
45 LONG_PRESS_END: goog.events.getUniqueId('lpe'),
46 POINTER_DOWN: goog.events.getUniqueId('pd'),
47 POINTER_UP: goog.events.getUniqueId('pu'),
48 POINTER_OVER: goog.events.getUniqueId('pv'),
49 POINTER_OUT: goog.events.getUniqueId('po'),
50 REFRESH: goog.events.getUniqueId('rf'),
51 SETTINGS_READY: goog.events.getUniqueId('sr'),
52 SURROUNDING_TEXT_CHANGED: goog.events.getUniqueId('stc'),
53 SWIPE: goog.events.getUniqueId('s'),
54 CONTEXT_UPDATE: goog.events.getUniqueId('cu'),
55 CONTEXT_FOCUS: goog.events.getUniqueId('cf'),
56 CONTEXT_BLUR: goog.events.getUniqueId('cb'),
57 VISIBILITY_CHANGE: goog.events.getUniqueId('vc'),
58 MODEL_UPDATE: goog.events.getUniqueId('mu'),
59 URL_CHANGED: goog.events.getUniqueId('uc'),
60 UPDATE_SETTINGS: goog.events.getUniqueId('us'),
61 VOICE_STATE_CHANGE: goog.events.getUniqueId('vsc'),
62 HWT_NETWORK_ERROR: goog.events.getUniqueId('hne'),
63 FRONT_TOGGLE_LANGUAGE_STATE: goog.events.getUniqueId('ftls')
69 * The event when the data is loaded complete.
71 * @param {!Object} data The layout data.
73 * @extends {goog.events.Event}
75 events.LayoutLoadedEvent = function(data) {
76 goog.base(this, events.EventType.LAYOUT_LOADED);
85 goog.inherits(events.LayoutLoadedEvent, goog.events.Event);
90 * The event when the configuration is loaded complete.
92 * @param {!Object} data The configuration data.
94 * @extends {goog.events.Event}
96 events.ConfigLoadedEvent = function(data) {
97 goog.base(this, events.EventType.CONFIG_LOADED);
100 * The configuration data.
106 goog.inherits(events.ConfigLoadedEvent, goog.events.Event);
111 * The events generated from receiving a message. It dispatched from adapter to
112 * controller or other parts which do not have access to chrome APIs.
114 * @param {events.EventType} type .
117 * @extends {goog.events.Event}
119 events.MessageEvent = function(type, msg) {
120 goog.base(this, type);
125 goog.inherits(events.MessageEvent, goog.events.Event);
132 * @param {i18n.input.chrome.inputview.elements.Element} view .
133 * @param {events.EventType} type .
134 * @param {Node} target The event target.
135 * @param {number} x .
136 * @param {number} y .
137 * @param {number} identifier .
138 * @param {number=} opt_timestamp The timestamp of a pointer event.
140 * @extends {goog.events.Event}
142 events.PointerEvent = function(view, type, target, x, y, identifier,
144 goog.base(this, type, target);
149 * @type {i18n.input.chrome.inputview.elements.Element}
168 * The event identifier.
172 this.identifier = identifier;
179 this.timestamp = opt_timestamp || 0;
181 goog.inherits(events.PointerEvent, goog.events.Event);
188 * @param {i18n.input.chrome.inputview.elements.Element} view .
189 * @param {number} direction See SwipeDirection in pointer handler.
190 * @param {Node} target The event target.
191 * @param {number} x .
192 * @param {number} y .
193 * @param {number} identifier .
195 * @extends {events.PointerEvent}
197 events.SwipeEvent = function(view, direction, target, x, y, identifier) {
198 goog.base(this, view, events.EventType.SWIPE,
199 target, x, y, identifier);
206 this.direction = direction;
208 goog.inherits(events.SwipeEvent, events.PointerEvent);
215 * @param {i18n.input.chrome.inputview.elements.Element} view .
216 * @param {number} direction See SwipeDirection in pointer handler.
217 * @param {Node} target The event target.
218 * @param {number} x .
219 * @param {number} y .
220 * @param {number} deltaX The drag distance of x-coordinate.
221 * @param {number} deltaY The drag distance of y-coordinate.
222 * @param {number} identifier .
224 * @extends {events.PointerEvent}
226 events.DragEvent = function(view, direction, target, x, y, deltaX, deltaY,
228 goog.base(this, view, events.EventType.DRAG,
229 target, x, y, identifier);
235 this.direction = direction;
238 * The value of deltaX
242 this.deltaX = deltaX;
245 * The value of deltaY
249 this.deltaY = deltaY;
251 goog.inherits(events.DragEvent, events.PointerEvent);
256 * The event when the surrounding text is changed.
258 * @param {string} text The surrounding text.
259 * @param {number} anchor .
260 * @param {number} focus .
262 * @extends {goog.events.Event}
264 events.SurroundingTextChangedEvent = function(text, anchor, focus) {
265 goog.base(this, events.EventType.SURROUNDING_TEXT_CHANGED);
267 /** @type {string} */
269 /** @type {number} */
270 this.anchor = anchor;
271 /** @type {number} */
274 goog.inherits(events.SurroundingTextChangedEvent, goog.events.Event);
279 * The event when context is updated.
281 * @param {string} compositionText .
282 * @param {string} committedText .
284 * @extends {goog.events.Event}
286 events.ContextUpdateEvent = function(compositionText, committedText) {
287 goog.base(this, events.EventType.CONTEXT_UPDATE);
289 /** @type {string} */
290 this.compositionText = compositionText;
292 /** @type {string} */
293 this.committedText = committedText;
295 goog.inherits(events.ContextUpdateEvent, goog.events.Event);