OLD | NEW |
| (Empty) |
1 // Copyright 2011 (c) The Native Client 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 Life events. These are goog.events.Event objects with | |
7 * an added ID property, that identifies which UI element triggered the event | |
8 * in the first place. | |
9 */ | |
10 | |
11 goog.provide('uikit.events.Event'); | |
12 | |
13 goog.require('goog.events.Event'); | |
14 | |
15 /** | |
16 * Constructor for the Event class. This provides a default ID ('gs_event') | |
17 * if |opt_eventId| is null or undefined. | |
18 * @param {string} type The type of this event. | |
19 * @param {?Object} opt_target The target that triggered this event. | |
20 * @param {string} opt_eventId The id for this event. If null or undefined, | |
21 * the new event instance gets the default id 'gs_event'. | |
22 * @constructor | |
23 * @extends {goog.events.Event} | |
24 */ | |
25 uikit.events.Event = function(type, opt_target, opt_eventId) { | |
26 goog.events.Event.call(this, type, opt_target); | |
27 | |
28 /** | |
29 * The event id. Initialized to be |opt_eventId| or the default 'gs_event'. | |
30 * @type {string} | |
31 * @private | |
32 */ | |
33 this.eventId_ = opt_eventId || uikit.events.Event.DEFAULT_EVENT_ID; | |
34 }; | |
35 goog.inherits(uikit.events.Event, goog.events.Event); | |
36 | |
37 /** | |
38 * Override of disposeInternal() to dispose of retained objects. | |
39 * @override | |
40 */ | |
41 uikit.events.Event.prototype.disposeInternal = function() { | |
42 uikit.events.Event.superClass_.disposeInternal.call(this); | |
43 this.eventId_ = null; | |
44 }; | |
45 | |
46 /** | |
47 * Accessor for the |eventId_| property. | |
48 * @return {string} The id of this event instance, guaranteed not to be null. | |
49 */ | |
50 uikit.events.Event.prototype.eventId = function() { | |
51 return this.eventId_; | |
52 }; | |
53 | |
54 /** | |
55 * Mutator for the |eventId_| property. | |
56 * @param {string} eventId The new event id. If null or undefined, this method | |
57 * has no effect and silently returns. | |
58 */ | |
59 uikit.events.Event.prototype.setEventId = function(eventId) { | |
60 if (!eventId) | |
61 return; | |
62 this.eventId_ = eventId; | |
63 }; | |
64 | |
65 /** | |
66 * The default event id. This is the id for events created using the default | |
67 * constructor parameter. | |
68 * @type {string} | |
69 */ | |
70 uikit.events.Event.DEFAULT_EVENT_ID = 'gs_event'; | |
OLD | NEW |