aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/component.js
diff options
context:
space:
mode:
authorPierre Frisch2011-12-22 07:25:50 -0800
committerValerio Virgillito2012-01-27 11:18:17 -0800
commitb89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch)
tree0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /node_modules/montage/ui/component.js
parent2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff)
downloadninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/component.js')
-rwxr-xr-xnode_modules/montage/ui/component.js1527
1 files changed, 1527 insertions, 0 deletions
diff --git a/node_modules/montage/ui/component.js b/node_modules/montage/ui/component.js
new file mode 100755
index 00000000..30d59c22
--- /dev/null
+++ b/node_modules/montage/ui/component.js
@@ -0,0 +1,1527 @@
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/ui/component
8 @requires montage/core/core
9 @requires montage/core/event/mutable-event
10 @requires montage/core/bitfield
11 @requires montage/ui/reel
12 @requires montage/core/gate
13 @requires montage/core/logger | component
14 @requires montage/core/logger | drawing
15 @requires montage/core/event/event-manager
16*/
17var Montage = require("montage").Montage,
18 MutableEvent = require("core/event/mutable-event").MutableEvent,
19 BitField = require("core/bitfield").BitField,
20 Template = require("ui/template").Template,
21 Gate = require("core/gate").Gate,
22 logger = require("core/logger").logger("component"),
23 drawLogger = require("core/logger").logger("drawing"),
24 defaultEventManager = require("core/event/event-manager").defaultEventManager;
25/**
26 * @class module:montage/ui/component.Component
27 * @classdesc Base class for all Montage components.
28 @extends module:montage/core/core.Montage
29 */
30var Component = exports.Component = Montage.create(Montage,/** @lends module:montage/ui/component.Component# */ {
31/**
32 Description TODO
33 @type {Property}
34 @default null
35 */
36 delegate: {
37 enumerable: false,
38 value: null
39 },
40
41 parentProperty: {
42 serializable: true,
43 value: "parentComponent"
44 },
45
46 /**
47 Dispatch the actionEvent this component is configured to emit upon interaction
48 @private
49 */
50 _dispatchActionEvent: {
51 value: function() {
52 this.dispatchEvent(this.createActionEvent());
53 },
54 enumerable: false
55 },
56
57 /**
58 Create a custom event to dispatch upon interaction
59 @type {Function}
60 @returns and event to dispatch upon interaction
61 */
62 createActionEvent: {
63 value: function() {
64 var actionEvent = document.createEvent("CustomEvent");
65 actionEvent.initCustomEvent("action", true, true, null);
66 actionEvent.type = "action";
67 return actionEvent;
68 }
69 },
70
71/**
72 Description TODO
73 @function
74 @returns this._canDrawGate
75 */
76 canDrawGate: {
77 get: function() {
78 if (!this._canDrawGate) {
79 this._canDrawGate = Gate.create().initWithDelegate(this);
80 this._canDrawGate.setField("componentTreeLoaded", false);
81 }
82 return this._canDrawGate;
83 }
84 },
85/**
86 Description TODO
87 @private
88*/
89 _blockDrawGate: {
90 value: null
91 },
92/**
93 Description TODO
94 @function
95 @returns this._blockDrawGate
96 */
97 blockDrawGate: {
98 get: function() {
99 if (!this._blockDrawGate) {
100 this._blockDrawGate = Gate.create().initWithDelegate(this);
101 this._blockDrawGate.setField("element", false);
102 this._blockDrawGate.setField("drawRequested", false);
103 }
104 return this._blockDrawGate;
105 }
106 },
107
108 /**
109 Description TODO
110 @private
111*/ _firstDraw: {
112 enumerable: false,
113 value: true
114 },
115/**
116 Description TODO
117 @private
118*/
119 _completedFirstDraw: {
120 enumerable: false,
121 value: false
122 },
123/**
124 Description TODO
125 @private
126*/
127 _element: {
128 enumerable: false,
129 value: null
130 },
131/**
132 Description TODO
133 @type {Function}
134 @default null
135 */
136 element: {
137 serializable: true,
138 enumerable: true,
139 get: function() {
140 return this._element;
141 },
142 set: function(value) {
143 if (value == null) {
144 console.log("Warning: Tried to set element of ", this, " as " + value + ".");
145 return;
146 }
147
148 this.eventManager.registerEventHandlerForElement(this, value);
149
150 if (this.isDeserializing) {
151 // if this component has a template and has been already instantiated then assume the value is the template.
152 if (this._isTemplateInstantiated) {
153 this._templateElement = value;
154 } else {
155 this._element = value;
156 if (!this.blockDrawGate.value && this._element) {
157 this.blockDrawGate.setField("element", true);
158 }
159 }
160 } else {
161 this._element = value;
162 if (!this.blockDrawGate.value && this._element) {
163 this.blockDrawGate.setField("element", true);
164 }
165 }
166 }
167 },
168
169 // access to the Application object
170/**
171 Description TODO
172 @function
173 @returns document.application
174 */
175 application: {
176 get: function() {
177 return document.application;
178 }
179 },
180/**
181 Description TODO
182 @function
183 @returns defaultEventManager
184 */
185 eventManager: {
186 get: function() {
187 return defaultEventManager;
188 }
189 },
190/**
191 Description TODO
192 @function
193 @returns rootComponent
194 */
195 rootComponent: {
196 get: function() {
197 return rootComponent;
198 }
199 },
200/**
201 Description TODO
202 @function
203 @returns {Boolean} false
204 */
205 acceptsDirectFocus: {
206 enumerable: false,
207 value: function() {
208 return false;
209 }
210 },
211/**
212 Description TODO
213 @function
214 @returns targetElementController
215 */
216 elementControllerFromEvent: {
217 enumerable: false,
218 value: function(event, targetElementController) {
219 return targetElementController;
220 }
221 },
222/**
223 Description TODO
224 @private
225*/
226 _cachedParentComponent: {
227 value: null
228 },
229 // TODO store the value and delete it after draw
230/**
231 The parent component is found by walking up the DOM tree from the node returned by the <i>element</i> property.<br>
232 If we find a parentNode that has a controller then we return this controller.<br>
233 Returns undefined if this is the rootComponent.
234 @function
235 @returns undefined