| 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 | |
| 22 | goog.provide('goog.events.EventType'); |
| 23 | |
| 24 | goog.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 | */ |
| 34 | goog.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 | */ |
| 45 | goog.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 | SELECT: 'select', |
| 88 | SUBMIT: 'submit', |
| 89 | INPUT: 'input', |
| 90 | PROPERTYCHANGE: 'propertychange', // IE only |
| 91 | |
| 92 | // Drag and drop |
| 93 | DRAGSTART: 'dragstart', |
| 94 | DRAG: 'drag', |
| 95 | DRAGENTER: 'dragenter', |
| 96 | DRAGOVER: 'dragover', |
| 97 | DRAGLEAVE: 'dragleave', |
| 98 | DROP: 'drop', |
| 99 | DRAGEND: 'dragend', |
| 100 | |
| 101 | // Touch events |
| 102 | // Note that other touch events exist, but we should follow the W3C list here. |
| 103 | // http://www.w3.org/TR/touch-events/#list-of-touchevent-types |
| 104 | TOUCHSTART: 'touchstart', |
| 105 | TOUCHMOVE: 'touchmove', |
| 106 | TOUCHEND: 'touchend', |
| 107 | TOUCHCANCEL: 'touchcancel', |
| 108 | |
| 109 | // Misc |
| 110 | BEFOREUNLOAD: 'beforeunload', |
| 111 | CONSOLEMESSAGE: 'consolemessage', |
| 112 | CONTEXTMENU: 'contextmenu', |
| 113 | DOMCONTENTLOADED: 'DOMContentLoaded', |
| 114 | ERROR: 'error', |
| 115 | HELP: 'help', |
| 116 | LOAD: 'load', |
| 117 | LOSECAPTURE: 'losecapture', |
| 118 | ORIENTATIONCHANGE: 'orientationchange', |
| 119 | READYSTATECHANGE: 'readystatechange', |
| 120 | RESIZE: 'resize', |
| 121 | SCROLL: 'scroll', |
| 122 | UNLOAD: 'unload', |
| 123 | |
| 124 | // HTML 5 History events |
| 125 | // See http://www.w3.org/TR/html5/history.html#event-definitions |
| 126 | HASHCHANGE: 'hashchange', |
| 127 | PAGEHIDE: 'pagehide', |
| 128 | PAGESHOW: 'pageshow', |
| 129 | POPSTATE: 'popstate', |
| 130 | |
| 131 | // Copy and Paste |
| 132 | // Support is limited. Make sure it works on your favorite browser |
| 133 | // before using. |
| 134 | // http://www.quirksmode.org/dom/events/cutcopypaste.html |
| 135 | COPY: 'copy', |
| 136 | PASTE: 'paste', |
| 137 | CUT: 'cut', |
| 138 | BEFORECOPY: 'beforecopy', |
| 139 | BEFORECUT: 'beforecut', |
| 140 | BEFOREPASTE: 'beforepaste', |
| 141 | |
| 142 | // HTML5 online/offline events. |
| 143 | // http://www.w3.org/TR/offline-webapps/#related |
| 144 | ONLINE: 'online', |
| 145 | OFFLINE: 'offline', |
| 146 | |
| 147 | // HTML 5 worker events |
| 148 | MESSAGE: 'message', |
| 149 | CONNECT: 'connect', |
| 150 | |
| 151 | // CSS animation events. |
| 152 | /** @suppress {missingRequire} */ |
| 153 | ANIMATIONSTART: goog.events.getVendorPrefixedName_('AnimationStart'), |
| 154 | /** @suppress {missingRequire} */ |
| 155 | ANIMATIONEND: goog.events.getVendorPrefixedName_('AnimationEnd'), |
| 156 | /** @suppress {missingRequire} */ |
| 157 | ANIMATIONITERATION: goog.events.getVendorPrefixedName_('AnimationIteration'), |
| 158 | |
| 159 | // CSS transition events. Based on the browser support described at: |
| 160 | // https://developer.mozilla.org/en/css/css_transitions#Browser_compatibility |
| 161 | /** @suppress {missingRequire} */ |
| 162 | TRANSITIONEND: goog.events.getVendorPrefixedName_('TransitionEnd'), |
| 163 | |
| 164 | // W3C Pointer Events |
| 165 | // http://www.w3.org/TR/pointerevents/ |
| 166 | POINTERDOWN: 'pointerdown', |
| 167 | POINTERUP: 'pointerup', |
| 168 | POINTERCANCEL: 'pointercancel', |
| 169 | POINTERMOVE: 'pointermove', |
| 170 | POINTEROVER: 'pointerover', |
| 171 | POINTEROUT: 'pointerout', |
| 172 | POINTERENTER: 'pointerenter', |
| 173 | POINTERLEAVE: 'pointerleave', |
| 174 | GOTPOINTERCAPTURE: 'gotpointercapture', |
| 175 | LOSTPOINTERCAPTURE: 'lostpointercapture', |
| 176 | |
| 177 | // IE specific events. |
| 178 | // See http://msdn.microsoft.com/en-us/library/ie/hh772103(v=vs.85).aspx |
| 179 | // Note: these events will be supplanted in IE11. |
| 180 | MSGESTURECHANGE: 'MSGestureChange', |
| 181 | MSGESTUREEND: 'MSGestureEnd', |
| 182 | MSGESTUREHOLD: 'MSGestureHold', |
| 183 | MSGESTURESTART: 'MSGestureStart', |
| 184 | MSGESTURETAP: 'MSGestureTap', |
| 185 | MSGOTPOINTERCAPTURE: 'MSGotPointerCapture', |
| 186 | MSINERTIASTART: 'MSInertiaStart', |
| 187 | MSLOSTPOINTERCAPTURE: 'MSLostPointerCapture', |
| 188 | MSPOINTERCANCEL: 'MSPointerCancel', |
| 189 | MSPOINTERDOWN: 'MSPointerDown', |
| 190 | MSPOINTERENTER: 'MSPointerEnter', |
| 191 | MSPOINTERHOVER: 'MSPointerHover', |
| 192 | MSPOINTERLEAVE: 'MSPointerLeave', |
| 193 | MSPOINTERMOVE: 'MSPointerMove', |
| 194 | MSPOINTEROUT: 'MSPointerOut', |
| 195 | MSPOINTEROVER: 'MSPointerOver', |
| 196 | MSPOINTERUP: 'MSPointerUp', |
| 197 | |
| 198 | // Native IMEs/input tools events. |
| 199 | TEXT: 'text', |
| 200 | TEXTINPUT: 'textInput', |
| 201 | COMPOSITIONSTART: 'compositionstart', |
| 202 | COMPOSITIONUPDATE: 'compositionupdate', |
| 203 | COMPOSITIONEND: 'compositionend', |
| 204 | |
| 205 | // Webview tag events |
| 206 | // See http://developer.chrome.com/dev/apps/webview_tag.html |
| 207 | EXIT: 'exit', |
| 208 | LOADABORT: 'loadabort', |
| 209 | LOADCOMMIT: 'loadcommit', |
| 210 | LOADREDIRECT: 'loadredirect', |
| 211 | LOADSTART: 'loadstart', |
| 212 | LOADSTOP: 'loadstop', |
| 213 | RESPONSIVE: 'responsive', |
| 214 | SIZECHANGED: 'sizechanged', |
| 215 | UNRESPONSIVE: 'unresponsive', |
| 216 | |
| 217 | // HTML5 Page Visibility API. See details at |
| 218 | // {@code goog.labs.dom.PageVisibilityMonitor}. |
| 219 | VISIBILITYCHANGE: 'visibilitychange', |
| 220 | |
| 221 | // LocalStorage event. |
| 222 | STORAGE: 'storage', |
| 223 | |
| 224 | // DOM Level 2 mutation events (deprecated). |
| 225 | DOMSUBTREEMODIFIED: 'DOMSubtreeModified', |
| 226 | DOMNODEINSERTED: 'DOMNodeInserted', |
| 227 | DOMNODEREMOVED: 'DOMNodeRemoved', |
| 228 | DOMNODEREMOVEDFROMDOCUMENT: 'DOMNodeRemovedFromDocument', |
| 229 | DOMNODEINSERTEDINTODOCUMENT: 'DOMNodeInsertedIntoDocument', |
| 230 | DOMATTRMODIFIED: 'DOMAttrModified', |
| 231 | DOMCHARACTERDATAMODIFIED: 'DOMCharacterDataModified' |
| 232 | }; |