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