diff options
Diffstat (limited to 'node_modules/montage/ui/list.reel/list.js')
-rwxr-xr-x | node_modules/montage/ui/list.reel/list.js | 272 |
1 files changed, 272 insertions, 0 deletions
diff --git a/node_modules/montage/ui/list.reel/list.js b/node_modules/montage/ui/list.reel/list.js new file mode 100755 index 00000000..2af99bf4 --- /dev/null +++ b/node_modules/montage/ui/list.reel/list.js | |||
@@ -0,0 +1,272 @@ | |||
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/list.reel" | ||
8 | @requires montage/core/core | ||
9 | @requires montage/ui/component | ||
10 | */ | ||
11 | var Montage = require("montage").Montage, | ||
12 | Component = require("ui/component").Component; | ||
13 | /** | ||
14 | @class module:"montage/ui/list.reel".List | ||
15 | @extends module:montage/ui/component.Component | ||
16 | */ | ||
17 | var List = exports.List = Montage.create(Component,/** @lends module:"montage/ui/list.reel".List# */ { | ||
18 | /** | ||
19 | Description TODO | ||
20 | @private | ||
21 | */ | ||
22 | _repetition: { | ||
23 | enumerable: false, | ||
24 | value: null | ||
25 | }, | ||
26 | /** | ||
27 | Description TODO | ||
28 | @private | ||
29 | */ | ||
30 | _scrollview: { | ||
31 | enumerable: false, | ||
32 | value: null | ||
33 | }, | ||
34 | /** | ||
35 | Description TODO | ||
36 | @private | ||
37 | */ | ||
38 | _orphanedChildren: { | ||
39 | enumerable: false, | ||
40 | value: null | ||
41 | }, | ||
42 | /** | ||
43 | Description TODO | ||
44 | @type {Property} | ||
45 | @default null | ||
46 | */ | ||
47 | delegate: { | ||
48 | enumerable: false, | ||
49 | value: null | ||
50 | }, | ||
51 | |||
52 | //TODO make some convenient forwarding property or something, this is a little tedious | ||
53 | |||
54 | // Properties to forward to the scrollview | ||
55 | /** | ||
56 | Description TODO | ||
57 | @private | ||
58 | */ | ||
59 | _axisForScrollview: { | ||
60 | enumerable: false, | ||
61 | value: null | ||
62 | }, | ||
63 | /** | ||
64 | Description TODO | ||
65 | @type {Function} | ||
66 | @default null | ||
67 | */ | ||
68 | axis: { | ||
69 | enumerable: false, | ||
70 | get: function() { | ||
71 | if (this._scrollview) { | ||
72 | return this._scrollview.axis; | ||
73 | } else { | ||
74 | return this._axisForScrollview; | ||
75 | } | ||
76 | }, | ||
77 | set: function(value) { | ||
78 | if (this._scrollview) { | ||
79 | this._scrollview.axis = value; | ||
80 | } else { | ||
81 | this._axisForScrollview = value; | ||
82 | } | ||
83 | } | ||
84 | }, | ||
85 | |||
86 | //Properties to forward to the repetition | ||
87 | /** | ||
88 | Description TODO | ||
89 | @private | ||
90 | */ | ||
91 | _objectsForRepetition: { | ||
92 | enumerable: false, | ||
93 | value: null | ||
94 | }, | ||
95 | /** | ||
96 | Description TODO | ||
97 | @type {Function} | ||
98 | @default null | ||
99 | */ | ||
100 | objects: { | ||
101 | enumerable: false, | ||
102 | get: function() { | ||
103 | if (this._repetition) { | ||
104 | return this._repetition.objects; | ||
105 | } else { | ||
106 | return this._objectsForRepetition; | ||
107 | } | ||
108 | }, | ||
109 | set: function(value) { | ||
110 | if (this._repetition) { | ||
111 | this._repetition.objects = value; | ||
112 | } else { | ||
113 | this._objectsForRepetition = value; | ||
114 | } | ||
115 | } | ||
116 | }, | ||
117 | /** | ||
118 | Description TODO | ||
119 | @private | ||
120 | */ | ||
121 | _contentControllerForRepetition: { | ||
122 | enumerable: false, | ||
123 | value: null | ||
124 | }, | ||
125 | /** | ||
126 | Description TODO | ||
127 | @type {Function} | ||
128 | @default null | ||
129 | */ | ||
130 | contentController: { | ||
131 | enumerable: false, | ||
132 | get: function() { | ||
133 | if (this._repetition) { | ||
134 | return this._repetition.contentController; | ||
135 | } else { | ||
136 | return this._contentControllerForRepetition; | ||
137 | } | ||
138 | }, | ||
139 | set: function(value) { | ||
140 | if (this._repetition) { | ||
141 | this._repetition.contentController = value; | ||
142 | } else { | ||
143 | this._contentControllerForRepetition = value; | ||
144 | } | ||
145 | } | ||
146 | }, | ||
147 | /** | ||
148 | Description TODO | ||
149 | @private | ||
150 | */ | ||
151 | _isSelectionEnabledForRepetition: { | ||
152 | enumerable: false, | ||
153 | value: null | ||
154 | }, | ||
155 | /** | ||
156 | Description TODO | ||
157 | @type {Function} | ||
158 | @default null | ||
159 | */ | ||
160 | isSelectionEnabled: { | ||
161 | enumerable: false, | ||
162 | get: function() { | ||
163 | if (this._repetition) { | ||
164 | return this._repetition.isSelectionEnabled; | ||
165 | } else { | ||
166 | return this._isSelectionEnabledForRepetition; | ||
167 | } | ||
168 | }, | ||
169 | set: function(value) { | ||
170 | if (this._repetition) { | ||
171 | this._repetition.isSelectionEnabled = value; | ||
172 | } else { | ||
173 | this._isSelectionEnabledForRepetition = value; | ||
174 | } | ||
175 | } | ||
176 | }, | ||
177 | |||
178 | // Initialization | ||
179 | |||
180 | // TODO we should probably support the programmatic initialization of a list; forwarding the childComponents | ||
181 | // along to the repetition | ||
182 | // I want to say that if somebody knows enough to do that they know enough to append the child components' elements | ||
183 | // into the repetition, not the list | ||
184 | /** | ||
185 | Description TODO | ||
186 | @function | ||
187 | @param {Property} type TODO | ||
188 | @param {Property} listener TODO | ||
189 | @param {Property} useCapture TODO | ||
190 | @param {Property} atSignIndex TODO | ||
191 | @param {Property} bindingOrigin TODO | ||
192 | @param {Property} bindingPropertyPath TODO | ||
193 | @param {Property} bindingDescriptor TODO | ||
194 | @returns null or object | ||
195 | */ | ||
196 | propertyChangeBindingListener: { | ||
197 | value: function(type, listener, useCapture, atSignIndex, bindingOrigin, bindingPropertyPath, bindingDescriptor) { | ||
198 | |||
199 | // TODO could forward along less-special bindings this way such as "objects" in general, just to reduce an extra | ||
200 | // hop in the derived property path | ||
201 | if (bindingDescriptor.boundObjectPropertyPath.match(/objectAtCurrentIteration/)) { | ||
202 | if (this._repetition) { | ||
203 | // TODO not sure how safe this is, but I may want to use it in the repetition's oimplementation of | ||
204 | // this method as well as it looks like it should obviously be faster than replicating the descriptor | ||
205 | bindingDescriptor.boundObject = this._repetition; | ||
206 | return this._repetition.propertyChangeBindingListener.apply(this._repetition, arguments); | ||
207 | } else { | ||
208 | // Don't install this binding; we'll deal with that when the children are actually used inside | ||
209 | // the repetition and try to bind to the list directly in the future | ||
210 | // TODO maybe we could rewrite the bindingDescriptor at this point on the bindingOrigin | ||
211 | // to prevent this man-in-the-middle game we're playing with the list later on | ||
212 | return null; | ||
213 | } | ||
214 | } else { | ||
215 | return Object.prototype.propertyChangeBindingListener.apply(this, arguments); | ||
216 | } | ||
217 | }}, | ||
218 | |||
219 | /** | ||
220 | Description TODO | ||
221 | @function | ||
222 | */ | ||
223 | deserializedFromTemplate: { | ||
224 | value: function() { | ||
225 | // The childComponents of the list need to be pulled aside for a moment so we can give them to the repetition | ||
226 | // This is logically where people think these components are ending up anyway | ||
227 | this._orphanedChildren = this.childComponents; | ||
228 | this.childComponents = null; | ||
229 | } | ||
230 | }, | ||
231 | |||