lib/goog/events/eventtype.js

1// Copyright 2010 The Closure Library Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS-IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/**
16 * @fileoverview Event Types.
17 *
18 * @author arv@google.com (Erik Arvidsson)
19 */
20
21
22goog.provide('goog.events.EventType');
23
24goog.require('goog.userAgent');
25
26
27/**
28 * Returns a prefixed event name for the current browser.
29 * @param {string} eventName The name of the event.
30 * @return {string} The prefixed event name.
31 * @suppress {missingRequire|missingProvide}
32 * @private
33 */
34goog.events.getVendorPrefixedName_ = function(eventName) {
35 return goog.userAgent.WEBKIT ? 'webkit' + eventName :
36 (goog.userAgent.OPERA ? 'o' + eventName.toLowerCase() :
37 eventName.toLowerCase());
38};
39
40
41/**
42 * Constants for event names.
43 * @enum {string}
44 */
45goog.events.EventType = {
46 // Mouse events
47 CLICK: 'click',
48 RIGHTCLICK: 'rightclick',
49 DBLCLICK: 'dblclick',
50 MOUSEDOWN: 'mousedown',
51 MOUSEUP: 'mouseup',
52 MOUSEOVER: 'mouseover',
53 MOUSEOUT: 'mouseout',
54 MOUSEMOVE: 'mousemove',
55 MOUSEENTER: 'mouseenter',
56 MOUSELEAVE: 'mouseleave',
57 // Select start is non-standard.
58 // See http://msdn.microsoft.com/en-us/library/ie/ms536969(v=vs.85).aspx.
59 SELECTSTART: 'selectstart', // IE, Safari, Chrome
60
61 // Wheel events
62 // http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
63 WHEEL: 'wheel',
64
65 // Key events
66 KEYPRESS: 'keypress',
67 KEYDOWN: 'keydown',
68 KEYUP: 'keyup',
69
70 // Focus
71 BLUR: 'blur',
72 FOCUS: 'focus',
73 DEACTIVATE: 'deactivate', // IE only
74 // NOTE: The following two events are not stable in cross-browser usage.
75 // WebKit and Opera implement DOMFocusIn/Out.
76 // IE implements focusin/out.
77 // Gecko implements neither see bug at
78 // https://bugzilla.mozilla.org/show_bug.cgi?id=396927.
79 // The DOM Events Level 3 Draft deprecates DOMFocusIn in favor of focusin:
80 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html
81 // You can use FOCUS in Capture phase until implementations converge.
82 FOCUSIN: goog.userAgent.IE ? 'focusin' : 'DOMFocusIn',
83 FOCUSOUT: goog.userAgent.IE ? 'focusout' : 'DOMFocusOut',
84
85 // Forms
86 CHANGE: 'change',
87 RESET: 'reset',
88 SELECT: 'select',
89 SUBMIT: 'submit',
90 INPUT: 'input',
91 PROPERTYCHANGE: 'propertychange', // IE only
92
93 // Drag and drop
94 DRAGSTART: 'dragstart',
95 DRAG: 'drag',
96 DRAGENTER: 'dragenter',
97 DRAGOVER: 'dragover',
98 DRAGLEAVE: 'dragleave',
99 DROP: 'drop',
100 DRAGEND: 'dragend',
101
102 // Touch events
103 // Note that other touch events exist, but we should follow the W3C list here.
104 // http://www.w3.org/TR/touch-events/#list-of-touchevent-types
105 TOUCHSTART: 'touchstart',
106 TOUCHMOVE: 'touchmove',
107 TOUCHEND: 'touchend',
108 TOUCHCANCEL: 'touchcancel',
109
110 // Misc
111 BEFOREUNLOAD: 'beforeunload',
112 CONSOLEMESSAGE: 'consolemessage',
113 CONTEXTMENU: 'contextmenu',
114 DOMCONTENTLOADED: 'DOMContentLoaded',
115 ERROR: 'error',
116 HELP: 'help',
117 LOAD: 'load',
118 LOSECAPTURE: 'losecapture',
119 ORIENTATIONCHANGE: 'orientationchange',
120 READYSTATECHANGE: 'readystatechange',
121 RESIZE: 'resize',
122 SCROLL: 'scroll',
123 UNLOAD: 'unload',
124
125 // HTML 5 History events
126 // See http://www.w3.org/TR/html5/history.html#event-definitions
127 HASHCHANGE: 'hashchange',
128 PAGEHIDE: 'pagehide',
129 PAGESHOW: 'pageshow',
130 POPSTATE: 'popstate',
131
132 // Copy and Paste
133 // Support is limited. Make sure it works on your favorite browser
134 // before using.
135 // http://www.quirksmode.org/dom/events/cutcopypaste.html
136 COPY: 'copy',
137 PASTE: 'paste',
138 CUT: 'cut',
139 BEFORECOPY: 'beforecopy',
140 BEFORECUT: 'beforecut',
141 BEFOREPASTE: 'beforepaste',
142
143 // HTML5 online/offline events.
144 // http://www.w3.org/TR/offline-webapps/#related
145 ONLINE: 'online',
146 OFFLINE: 'offline',
147
148 // HTML 5 worker events
149 MESSAGE: 'message',
150 CONNECT: 'connect',
151
152 // CSS animation events.
153 /** @suppress {missingRequire} */
154 ANIMATIONSTART: goog.events.getVendorPrefixedName_('AnimationStart'),
155 /** @suppress {missingRequire} */
156 ANIMATIONEND: goog.events.getVendorPrefixedName_('AnimationEnd'),
157 /** @suppress {missingRequire} */
158 ANIMATIONITERATION: goog.events.getVendorPrefixedName_('AnimationIteration'),
159
160 // CSS transition events. Based on the browser support described at:
161 // https://developer.mozilla.org/en/css/css_transitions#Browser_compatibility
162 /** @suppress {missingRequire} */
163 TRANSITIONEND: goog.events.getVendorPrefixedName_('TransitionEnd'),
164
165 // W3C Pointer Events
166 // http://www.w3.org/TR/pointerevents/
167 POINTERDOWN: 'pointerdown',
168 POINTERUP: 'pointerup',
169 POINTERCANCEL: 'pointercancel',
170 POINTERMOVE: 'pointermove',
171 POINTEROVER: 'pointerover',
172 POINTEROUT: 'pointerout',
173 POINTERENTER: 'pointerenter',
174 POINTERLEAVE: 'pointerleave',
175 GOTPOINTERCAPTURE: 'gotpointercapture',
176 LOSTPOINTERCAPTURE: 'lostpointercapture',
177
178 // IE specific events.
179 // See http://msdn.microsoft.com/en-us/library/ie/hh772103(v=vs.85).aspx
180 // Note: these events will be supplanted in IE11.
181 MSGESTURECHANGE: 'MSGestureChange',
182 MSGESTUREEND: 'MSGestureEnd',
183 MSGESTUREHOLD: 'MSGestureHold',
184 MSGESTURESTART: 'MSGestureStart',
185 MSGESTURETAP: 'MSGestureTap',
186 MSGOTPOINTERCAPTURE: 'MSGotPointerCapture',
187 MSINERTIASTART: 'MSInertiaStart',
188 MSLOSTPOINTERCAPTURE: 'MSLostPointerCapture',
189 MSPOINTERCANCEL: 'MSPointerCancel',
190 MSPOINTERDOWN: 'MSPointerDown',
191 MSPOINTERENTER: 'MSPointerEnter',
192 MSPOINTERHOVER: 'MSPointerHover',
193 MSPOINTERLEAVE: 'MSPointerLeave',
194 MSPOINTERMOVE: 'MSPointerMove',
195 MSPOINTEROUT: 'MSPointerOut',
196 MSPOINTEROVER: 'MSPointerOver',
197 MSPOINTERUP: 'MSPointerUp',
198
199 // Native IMEs/input tools events.
200 TEXT: 'text',
201 TEXTINPUT: 'textInput',
202 COMPOSITIONSTART: 'compositionstart',
203 COMPOSITIONUPDATE: 'compositionupdate',
204 COMPOSITIONEND: 'compositionend',
205
206 // Webview tag events
207 // See http://developer.chrome.com/dev/apps/webview_tag.html
208 EXIT: 'exit',
209 LOADABORT: 'loadabort',
210 LOADCOMMIT: 'loadcommit',
211 LOADREDIRECT: 'loadredirect',
212 LOADSTART: 'loadstart',
213 LOADSTOP: 'loadstop',
214 RESPONSIVE: 'responsive',
215 SIZECHANGED: 'sizechanged',
216 UNRESPONSIVE: 'unresponsive',
217
218 // HTML5 Page Visibility API. See details at
219 // {@code goog.labs.dom.PageVisibilityMonitor}.
220 VISIBILITYCHANGE: 'visibilitychange',
221
222 // LocalStorage event.
223 STORAGE: 'storage',
224
225 // DOM Level 2 mutation events (deprecated).
226 DOMSUBTREEMODIFIED: 'DOMSubtreeModified',
227 DOMNODEINSERTED: 'DOMNodeInserted',
228 DOMNODEREMOVED: 'DOMNodeRemoved',
229 DOMNODEREMOVEDFROMDOCUMENT: 'DOMNodeRemovedFromDocument',
230 DOMNODEINSERTEDINTODOCUMENT: 'DOMNodeInsertedIntoDocument',
231 DOMATTRMODIFIED: 'DOMAttrModified',
232 DOMCHARACTERDATAMODIFIED: 'DOMCharacterDataModified'
233};