diff options
author | Valerio Virgillito | 2012-02-01 00:09:27 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-01 00:09:27 -0800 |
commit | 8592cfb89db05f0e52d8c1b8c7046e6f49e3522d (patch) | |
tree | a6f9b5adfe16fd6232708f8a2345cd79056caca9 /node_modules/montage-user/ui/component.js | |
parent | c6d1a1da9e7cdf477daf32410d80691eb1e828d5 (diff) | |
download | ninja-8592cfb89db05f0e52d8c1b8c7046e6f49e3522d.tar.gz |
Adding a montage framework copy for the user document
Adding a new montage copy containing the latest version of montage to use the new native widgets
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage-user/ui/component.js')
-rwxr-xr-x | node_modules/montage-user/ui/component.js | 1791 |
1 files changed, 1791 insertions, 0 deletions
diff --git a/node_modules/montage-user/ui/component.js b/node_modules/montage-user/ui/component.js new file mode 100755 index 00000000..90612f83 --- /dev/null +++ b/node_modules/montage-user/ui/component.js | |||
@@ -0,0 +1,1791 @@ | |||
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 | */ | ||
17 | var 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 | */ | ||
30 | var 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 | /** | ||