| 1 | /* |
| 2 | * Copyright 2008 Closure Compiler Authors |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /** |
| 18 | * @fileoverview Definitions for W3C's event specification. |
| 19 | * The whole file has been fully type annotated. |
| 20 | * Created from |
| 21 | * http://www.w3.org/TR/DOM-Level-2-Events/ecma-script-binding.html |
| 22 | * |
| 23 | * @externs |
| 24 | */ |
| 25 | |
| 26 | |
| 27 | /** |
| 28 | * @interface |
| 29 | */ |
| 30 | function EventTarget() {} |
| 31 | |
| 32 | /** |
| 33 | * @param {string} type |
| 34 | * @param {EventListener|function(Event):(boolean|undefined)} listener |
| 35 | * @param {boolean} useCapture |
| 36 | * @return {undefined} |
| 37 | */ |
| 38 | EventTarget.prototype.addEventListener = function(type, listener, useCapture) {}; |
| 39 | |
| 40 | /** |
| 41 | * @param {string} type |
| 42 | * @param {EventListener|function(Event):(boolean|undefined)} listener |
| 43 | * @param {boolean} useCapture |
| 44 | * @return {undefined} |
| 45 | */ |
| 46 | EventTarget.prototype.removeEventListener = function(type, listener, useCapture) {}; |
| 47 | |
| 48 | /** |
| 49 | * @param {Event} evt |
| 50 | * @return {boolean} |
| 51 | */ |
| 52 | EventTarget.prototype.dispatchEvent = function(evt) {}; |
| 53 | |
| 54 | /** |
| 55 | * @interface |
| 56 | */ |
| 57 | function EventListener() {} |
| 58 | |
| 59 | /** |
| 60 | * @param {Event} evt |
| 61 | * @return {undefined} |
| 62 | */ |
| 63 | EventListener.prototype.handleEvent = function(evt) {}; |
| 64 | |
| 65 | /** |
| 66 | * @constructor |
| 67 | */ |
| 68 | function Event() {} |
| 69 | |
| 70 | /** |
| 71 | * @type {number} |
| 72 | * @see http://www.w3.org/TR/DOM-Level-2-Events/ecma-script-binding.html |
| 73 | */ |
| 74 | Event.AT_TARGET; |
| 75 | |
| 76 | /** |
| 77 | * @type {number} |
| 78 | * @see http://www.w3.org/TR/DOM-Level-2-Events/ecma-script-binding.html |
| 79 | */ |
| 80 | Event.BUBBLING_PHASE; |
| 81 | |
| 82 | /** |
| 83 | * @type {number} |
| 84 | * @see http://www.w3.org/TR/DOM-Level-2-Events/ecma-script-binding.html |
| 85 | */ |
| 86 | Event.CAPTURING_PHASE; |
| 87 | |
| 88 | |
| 89 | /** @type {string} */ |
| 90 | Event.prototype.type; |
| 91 | |
| 92 | /** @type {EventTarget} */ |
| 93 | Event.prototype.target; |
| 94 | |
| 95 | /** @type {EventTarget} */ |
| 96 | Event.prototype.currentTarget; |
| 97 | |
| 98 | /** @type {number} */ |
| 99 | Event.prototype.eventPhase; |
| 100 | |
| 101 | /** @type {boolean} */ |
| 102 | Event.prototype.bubbles; |
| 103 | |
| 104 | /** @type {boolean} */ |
| 105 | Event.prototype.cancelable; |
| 106 | |
| 107 | /** @type {number} */ |
| 108 | Event.prototype.timeStamp; |
| 109 | |
| 110 | /** @type {Object} */ |
| 111 | Event.prototype.state; |
| 112 | |
| 113 | /** |
| 114 | * @return {undefined} |
| 115 | */ |
| 116 | Event.prototype.stopPropagation = function() {}; |
| 117 | |
| 118 | /** |
| 119 | * @return {undefined} |
| 120 | */ |
| 121 | Event.prototype.preventDefault = function() {}; |
| 122 | |
| 123 | /** |
| 124 | * @param {string} eventTypeArg |
| 125 | * @param {boolean} canBubbleArg |
| 126 | * @param {boolean} cancelableArg |
| 127 | * @return {undefined} |
| 128 | */ |
| 129 | Event.prototype.initEvent = function(eventTypeArg, canBubbleArg, cancelableArg) {}; |
| 130 | |
| 131 | /** |
| 132 | * @constructor |
| 133 | * @extends {Event} |
| 134 | * @see http://www.w3.org/TR/DOM-Level-3-Events/#interface-CustomEvent |
| 135 | */ |
| 136 | function CustomEvent() {} |
| 137 | |
| 138 | /** |
| 139 | * @param {string} eventType |
| 140 | * @param {boolean} bubbles |
| 141 | * @param {boolean} cancelable |
| 142 | * @param {*} detail |
| 143 | */ |
| 144 | CustomEvent.prototype.initCustomEvent = function( |
| 145 | eventType, bubbles, cancelable, detail) {}; |
| 146 | |
| 147 | /** |
| 148 | * @type {*} |
| 149 | */ |
| 150 | CustomEvent.prototype.detail; |
| 151 | |
| 152 | /** |
| 153 | * @constructor |
| 154 | */ |
| 155 | function DocumentEvent() {} |
| 156 | |
| 157 | /** |
| 158 | * @param {string} eventType |
| 159 | * @return {Event} |
| 160 | */ |
| 161 | DocumentEvent.prototype.createEvent = function(eventType) {}; |
| 162 | |
| 163 | /** |
| 164 | * @constructor |
| 165 | * @extends {Event} |
| 166 | */ |
| 167 | function UIEvent() {} |
| 168 | |
| 169 | /** @type {number} */ |
| 170 | UIEvent.prototype.detail; |
| 171 | |
| 172 | ///** |
| 173 | // * @param {string} typeArg |
| 174 | // * @param {boolean} canBubbleArg |
| 175 | // * @param {boolean} cancelableArg |
| 176 | // * @param {AbstractView} viewArg |
| 177 | // * @param {number} detailArg |
| 178 | // * @return undefined |
| 179 | // */ |
| 180 | //UIEvent.prototype.initUIEvent = function (typeArg, canBubbleArg, cancelableArg, viewArg, detailArg) {}; |
| 181 | |
| 182 | /** |
| 183 | * @constructor |
| 184 | * @extends {UIEvent} |
| 185 | */ |
| 186 | function MouseEvent() {} |
| 187 | |
| 188 | /** @type {number} */ |
| 189 | MouseEvent.prototype.screenX; |
| 190 | |
| 191 | /** @type {number} */ |
| 192 | MouseEvent.prototype.screenY; |
| 193 | |
| 194 | /** @type {number} */ |
| 195 | MouseEvent.prototype.clientX; |
| 196 | |
| 197 | /** @type {number} */ |
| 198 | MouseEvent.prototype.clientY; |
| 199 | |
| 200 | /** @type {boolean} */ |
| 201 | MouseEvent.prototype.ctrlKey; |
| 202 | |
| 203 | /** @type {boolean} */ |
| 204 | MouseEvent.prototype.shiftKey; |
| 205 | |
| 206 | /** @type {boolean} */ |
| 207 | MouseEvent.prototype.altKey; |
| 208 | |
| 209 | /** @type {boolean} */ |
| 210 | MouseEvent.prototype.metaKey; |
| 211 | |
| 212 | /** @type {number} */ |
| 213 | MouseEvent.prototype.button; |
| 214 | |
| 215 | /** @type {EventTarget} */ |
| 216 | MouseEvent.prototype.relatedTarget; |
| 217 | |
| 218 | |
| 219 | /** |
| 220 | * @constructor |
| 221 | * @extends {Event} |
| 222 | */ |
| 223 | function MutationEvent() {} |
| 224 | |
| 225 | /** @type {Node} */ |
| 226 | MutationEvent.prototype.relatedNode; |
| 227 | |
| 228 | /** @type {string} */ |
| 229 | MutationEvent.prototype.prevValue; |
| 230 | |
| 231 | /** @type {string} */ |
| 232 | MutationEvent.prototype.newValue; |
| 233 | |
| 234 | /** @type {string} */ |
| 235 | MutationEvent.prototype.attrName; |
| 236 | |
| 237 | /** @type {number} */ |
| 238 | MutationEvent.prototype.attrChange; |
| 239 | |
| 240 | /** |
| 241 | * @param {string} typeArg |
| 242 | * @param {boolean} canBubbleArg |
| 243 | * @param {boolean} cancelableArg |
| 244 | * @param {Node} relatedNodeArg |
| 245 | * @param {string} prevValueArg |
| 246 | * @param {string} newValueArg |
| 247 | * @param {string} attrNameArg |
| 248 | * @param {number} attrChangeArg |
| 249 | * @return {undefined} |
| 250 | */ |
| 251 | MutationEvent.prototype.initMutationEvent = function(typeArg, canBubbleArg, cancelableArg, relatedNodeArg, prevValueArg, newValueArg, attrNameArg, attrChangeArg) {}; |
| 252 | |
| 253 | |
| 254 | // DOM3 |
| 255 | /** |
| 256 | * @constructor |
| 257 | * @extends {UIEvent} |
| 258 | */ |
| 259 | function KeyboardEvent() {} |
| 260 | |
| 261 | /** @type {string} */ |
| 262 | KeyboardEvent.prototype.keyIdentifier; |
| 263 | |
| 264 | /** @type {boolean} */ |
| 265 | KeyboardEvent.prototype.ctrlKey; |
| 266 | |
| 267 | /** @type {boolean} */ |
| 268 | KeyboardEvent.prototype.shiftKey; |
| 269 | |
| 270 | /** @type {boolean} */ |
| 271 | KeyboardEvent.prototype.altKey; |
| 272 | |
| 273 | /** @type {boolean} */ |
| 274 | KeyboardEvent.prototype.metaKey; |
| 275 | |
| 276 | /** |
| 277 | * @param {string} keyIdentifierArg |
| 278 | * @return {boolean} |
| 279 | */ |
| 280 | KeyboardEvent.prototype.getModifierState = function(keyIdentifierArg) {}; |