diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /node_modules/montage/core/event/action-event-listener.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'node_modules/montage/core/event/action-event-listener.js')
-rwxr-xr-x | node_modules/montage/core/event/action-event-listener.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/node_modules/montage/core/event/action-event-listener.js b/node_modules/montage/core/event/action-event-listener.js new file mode 100755 index 00000000..bbe5baad --- /dev/null +++ b/node_modules/montage/core/event/action-event-listener.js | |||
@@ -0,0 +1,76 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /** | ||
7 | @module montage/core/event/action-event-listener | ||
8 | @requires montage/core/core | ||
9 | */ | ||
10 | var Montage = require("montage").Montage; | ||
11 | |||
12 | /** | ||
13 | @class module:montage/core/event/action-event-listener.ActionEventListener | ||
14 | @extends module:montage/core/core.Montage | ||
15 | */ | ||
16 | var ActionEventListener = exports.ActionEventListener = Montage.create(Montage, /** @lends module:montage/core/event/action-event-listener.ActionEventListener# */ { | ||
17 | |||
18 | /** | ||
19 | The object to handle the event. | ||
20 | @type {Property} | ||
21 | @default {Event handler} null | ||
22 | */ | ||
23 | handler: { | ||
24 | value: null | ||
25 | }, | ||
26 | |||
27 | /** | ||
28 | The action (function) to invoke on the handler object. | ||
29 | @type {Property} | ||
30 | @default {Event handler} null | ||
31 | */ | ||
32 | action: { | ||
33 | value: null | ||
34 | }, | ||
35 | |||
36 | /** | ||
37 | Returns a new ActionEventListener instance with the specified handler and action. | ||
38 | @function | ||
39 | @param {Event} handler The event handler. | ||
40 | @param {Event} action The event handler action. | ||
41 | @returns itself | ||
42 | */ | ||
43 | initWithHandler_action_: { | ||
44 | value: function(handler, action) { | ||
45 | this.handler = handler; | ||
46 | this.action = action; | ||
47 | |||
48 | return this; | ||
49 | } | ||
50 | }, | ||
51 | |||
52 | /** | ||
53 | @private | ||
54 | */ | ||
55 | handleEvent: { | ||
56 | value: function(event) { | ||
57 | if (typeof this.action === "function") { | ||
58 | // TODO call this in what context? | ||
59 | this.action(event); | ||
60 | } else { | ||
61 | this.handler[this.action](event); | ||
62 | } | ||
63 | } | ||
64 | }, | ||
65 | |||
66 | /** | ||
67 | @private | ||
68 | */ | ||
69 | serializeSelf: { | ||
70 | value: function(serializer) { | ||
71 | serializer.setReference("handler", this.handler); | ||
72 | serializer.set("action", this.action); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | }); | ||