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/ui/repetition.reel/repetition.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/ui/repetition.reel/repetition.js')
-rwxr-xr-x | node_modules/montage/ui/repetition.reel/repetition.js | 1115 |
1 files changed, 1115 insertions, 0 deletions
diff --git a/node_modules/montage/ui/repetition.reel/repetition.js b/node_modules/montage/ui/repetition.reel/repetition.js new file mode 100755 index 00000000..a50c4823 --- /dev/null +++ b/node_modules/montage/ui/repetition.reel/repetition.js | |||
@@ -0,0 +1,1115 @@ | |||
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/repetition.reel" | ||
8 | @requires montage/core/core | ||
9 | @requires montage/ui/component | ||
10 | @requires montage/ui/template | ||
11 | @requires montage/core/logger | ||
12 | @requires montage/core/gate | ||
13 | */ | ||
14 | var Montage = require("montage").Montage, | ||
15 | Component = require("ui/component").Component, | ||
16 | Template = require("ui/template").Template, | ||
17 | logger = require("core/logger").logger("repetition"), | ||
18 | Gate = require("core/gate").Gate; | ||
19 | /** | ||
20 | @class module:"montage/ui/repetition.reel".Repetition | ||
21 | @extends module:montage/ui/component.Component | ||
22 | */ | ||
23 | var Repetition = exports.Repetition = Montage.create(Component, /** @lends module:"montage/ui/repetition.reel".Repetition# */{ | ||
24 | /** | ||
25 | Description TODO | ||
26 | */ | ||
27 | hasTemplate: {value: false}, | ||
28 | |||
29 | /** | ||
30 | @private | ||
31 | */ | ||
32 | _hasBeenDeserialized: { | ||
33 | value: false, | ||
34 | enumerable: false | ||
35 | }, | ||
36 | /** | ||
37 | Description TODO | ||
38 | @type {Property} | ||
39 | @default {Boolean} false | ||
40 | */ | ||
41 | USE_FLATTENING: { | ||
42 | enumerable: false, | ||
43 | value: false | ||
44 | }, | ||
45 | |||
46 | /** | ||
47 | Description TODO | ||
48 | @private | ||
49 | */ | ||
50 | _nextDeserializedItemIx: { | ||
51 | enumerable: false, | ||
52 | value: 0, | ||
53 | distinct: true | ||
54 | }, | ||
55 | /** | ||
56 | Description TODO | ||
57 | @function | ||
58 | @returns itself | ||
59 | */ | ||
60 | init: { | ||
61 | enumerable: false, | ||
62 | value: function() { | ||
63 | this._items = []; | ||
64 | this._itemsToAppend = []; | ||
65 | this._nextDeserializedItemIx = 0; | ||
66 | this._itemsToRemove = []; | ||
67 | this._deletedItems = []; | ||
68 | return this; | ||
69 | } | ||
70 | }, | ||
71 | /** | ||
72 | Description TODO | ||
73 | @private | ||
74 | */ | ||
75 | _contentController: { | ||
76 | enumerable: false, | ||
77 | value: null | ||
78 | }, | ||
79 | /** | ||
80 | The collection of items managed the Repetition. | ||
81 | @type {Function} | ||
82 | @default null | ||
83 | */ | ||
84 | contentController: { | ||
85 | enumerable: false, | ||
86 | get: function() { | ||
87 | return this._contentController; | ||
88 | }, | ||
89 | set: function(value) { | ||
90 | if (this._contentController === value) { | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | if (this._contentController) { | ||
95 | Object.deleteBinding(this, "objects"); | ||
96 | Object.deleteBinding(this, "selectedIndexes"); | ||
97 | } | ||
98 | |||
99 | this._contentController = value; | ||
100 | |||
101 | if (this._contentController) { | ||
102 | |||
103 | // If we're already getting contentController related values from other bindings...stop that | ||
104 | if (this._bindingDescriptors) { | ||
105 | Object.deleteBinding(this, "objects"); | ||
106 | } | ||
107 | |||
108 | // And bind what we need from the new contentController | ||
109 | var objectsBindingDescriptor, | ||
110 | selectedIndexesBindingDescriptor; | ||
111 | |||
112 | objectsBindingDescriptor = { | ||
113 | boundObject: this._contentController, | ||
114 | boundObjectPropertyPath: "organizedObjects", | ||
115 | oneway: true | ||
116 | }; | ||
117 | |||
118 | selectedIndexesBindingDescriptor = { | ||
119 | boundObject: this._contentController, | ||
120 | boundObjectPropertyPath: "selectedIndexes" | ||
121 | }; | ||
122 | |||
123 | // If we're ready for bindings...go ahead an install | ||
124 | // TODO: Look at changing this once the new serialization has been implemented | ||
125 | if (this._hasBeenDeserialized) { | ||
126 | Object.defineBinding(this, "objects", objectsBindingDescriptor); | ||
127 | Object.defineBinding(this, "selectedIndexes", selectedIndexesBindingDescriptor); | ||
128 | } else { | ||
129 | // otherwise we need to defer it until later; we haven't been deserialized yet | ||
130 | if (!this._controllerBindingsToInstall) { | ||
131 | this._controllerBindingsToInstall = {}; | ||
132 | } | ||
133 | |||
134 | this._controllerBindingsToInstall.objects = objectsBindingDescriptor; | ||
135 | this._controllerBindingsToInstall.selectedIndexes = selectedIndexesBindingDescriptor; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | //TODO otherwise if no contentController should we disable selections? | ||
140 | |||
141 | } | ||
142 | }, | ||
143 | /** | ||
144 | Description TODO | ||
145 | @private | ||
146 | */ | ||
147 | _objects: { | ||
148 | enumerable: false, | ||
149 | serializable: true, | ||
150 | value: null | ||
151 | }, | ||
152 | /** | ||
153 | Description TODO | ||
154 | @type {Function} | ||
155 | @default null | ||
156 | */ | ||
157 | objects: { | ||
158 | enumerable: false, | ||
159 | get: function() { | ||
160 | return this._objects; | ||
161 | }, | ||
162 | set: function(value) { | ||
163 | if (logger.isDebug) { | ||
164 | logger.debug(this, " set objects:", value.length, value, "same objects?", value === this._objects); | ||
165 | } | ||
166 | this._objects = value; | ||
167 | |||
168 | // Objects have changed, clear the selectedIndexes, if we're managing our own selection | ||
169 | if (!this.contentController) { | ||
170 | this.selectedIndexes = null; | ||
171 | } | ||
172 | |||
173 | if (this._isComponentExpanded) { | ||
174 | this._refreshItems(); | ||
175 | } | ||
176 | }, | ||
177 | modify: function(modificationType, newValue, oldValue) { | ||
178 | this.selectedIndexes = null; | ||
179 | |||
180 | if (this._isComponentExpanded) { | ||
181 | this._refreshItems(); | ||
182 | } | ||
183 | } | ||
184 | }, | ||
185 | /** | ||
186 | Description TODO | ||
187 | @private | ||
188 | */ | ||
189 | _isSelectionEnabled: { | ||
190 | enumerable: false, | ||
191 | value: false | ||
192 | }, | ||
193 | /** | ||
194 | Description TODO | ||
195 | @type {Function} | ||
196 | @default {Boolean} false | ||
197 | */ | ||
198 | isSelectionEnabled: { | ||
199 | get: function() { | ||
200 | return this._isSelectionEnabled; | ||
201 | }, | ||
202 | set: function(value) { | ||
203 | if (value === this._isSelectionEnabled) { | ||
204 | return; | ||
205 | } | ||
206 | |||
207 | this._isSelectionEnabled = value; | ||
208 | |||
209 | if (this._isComponentExpanded) { | ||
210 | this._refreshSelectionTracking(); | ||
211 | } | ||
212 | } | ||
213 | }, | ||
214 | /** | ||
215 | Description TODO | ||
216 | @private | ||