OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview This is a simple pure JS event class that can be used with |
| 7 * {@code cr.ui.EventTarget}. It should not be used with DOM EventTargets. |
| 8 */ |
| 9 |
| 10 cr.define('cr', function() { |
| 11 |
| 12 // cr.Event is called CustomEvent in here to prevent naming conflicts. We |
| 13 // alse store the original Event in case someone does a global alias of |
| 14 // cr.Event. |
| 15 |
| 16 const DomEvent = Event; |
| 17 |
| 18 /** |
| 19 * Creates a new event to be used with cr.EventTarget or DOM EventTarget |
| 20 * objects. |
| 21 * @param {string} type The name of the event. |
| 22 * @param {boolean=} |
| 23 * @constructor |
| 24 */ |
| 25 function CustomEvent(type, opt_bubbles, opt_capture) { |
| 26 var e = cr.doc.createEvent('Event'); |
| 27 e.initEvent(type, !!opt_bubbles, !!opt_capture); |
| 28 e.__proto__ = CustomEvent.prototype; |
| 29 return e; |
| 30 } |
| 31 |
| 32 CustomEvent.prototype = { |
| 33 __proto__: DomEvent.prototype |
| 34 }; |
| 35 |
| 36 // Export |
| 37 return { |
| 38 Event: CustomEvent |
| 39 }; |
| 40 }); |
OLD | NEW |