diff options
author | Pushkar Joshi | 2012-02-07 07:21:27 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-07 07:21:27 -0800 |
commit | 4bbe42e6d01fd0f81d13357a75b40eae9925dda3 (patch) | |
tree | 57f49ebfa5d3fcef28753b34015209edda6e620a /node_modules/montage/ui/repetition.reel | |
parent | e7aa17a9b472640355e95c54841399f6203050d4 (diff) | |
parent | 8950b342d1eda8bfa195372e1c17363a409651cd (diff) | |
download | ninja-4bbe42e6d01fd0f81d13357a75b40eae9925dda3.tar.gz |
Merge branch 'master' into pentool
Diffstat (limited to 'node_modules/montage/ui/repetition.reel')
-rwxr-xr-x | node_modules/montage/ui/repetition.reel/repetition.js | 243 |
1 files changed, 142 insertions, 101 deletions
diff --git a/node_modules/montage/ui/repetition.reel/repetition.js b/node_modules/montage/ui/repetition.reel/repetition.js index a50c4823..3405a3d7 100755 --- a/node_modules/montage/ui/repetition.reel/repetition.js +++ b/node_modules/montage/ui/repetition.reel/repetition.js | |||
@@ -33,15 +33,6 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
33 | value: false, | 33 | value: false, |
34 | enumerable: false | 34 | enumerable: false |
35 | }, | 35 | }, |
36 | /** | ||
37 | Description TODO | ||
38 | @type {Property} | ||
39 | @default {Boolean} false | ||
40 | */ | ||
41 | USE_FLATTENING: { | ||
42 | enumerable: false, | ||
43 | value: false | ||
44 | }, | ||
45 | 36 | ||
46 | /** | 37 | /** |
47 | Description TODO | 38 | Description TODO |
@@ -94,6 +85,7 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
94 | if (this._contentController) { | 85 | if (this._contentController) { |
95 | Object.deleteBinding(this, "objects"); | 86 | Object.deleteBinding(this, "objects"); |
96 | Object.deleteBinding(this, "selectedIndexes"); | 87 | Object.deleteBinding(this, "selectedIndexes"); |
88 | Object.deleteBinding(this, "selections"); | ||
97 | } | 89 | } |
98 | 90 | ||
99 | this._contentController = value; | 91 | this._contentController = value; |
@@ -107,7 +99,8 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
107 | 99 | ||
108 | // And bind what we need from the new contentController | 100 | // And bind what we need from the new contentController |
109 | var objectsBindingDescriptor, | 101 | var objectsBindingDescriptor, |
110 | selectedIndexesBindingDescriptor; | 102 | selectedIndexesBindingDescriptor, |
103 | selectionsBindingDescriptor; | ||
111 | 104 | ||
112 | objectsBindingDescriptor = { | 105 | objectsBindingDescriptor = { |
113 | boundObject: this._contentController, | 106 | boundObject: this._contentController, |
@@ -120,11 +113,17 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
120 | boundObjectPropertyPath: "selectedIndexes" | 113 | boundObjectPropertyPath: "selectedIndexes" |
121 | }; | 114 | }; |
122 | 115 | ||
116 | selectionsBindingDescriptor = { | ||
117 | boundObject: this._contentController, | ||
118 | boundObjectPropertyPath: "selections" | ||
119 | }; | ||
120 | |||
123 | // If we're ready for bindings...go ahead an install | 121 | // If we're ready for bindings...go ahead an install |
124 | // TODO: Look at changing this once the new serialization has been implemented | 122 | // TODO: Look at changing this once the new serialization has been implemented |
125 | if (this._hasBeenDeserialized) { | 123 | if (this._hasBeenDeserialized) { |
126 | Object.defineBinding(this, "objects", objectsBindingDescriptor); | 124 | Object.defineBinding(this, "objects", objectsBindingDescriptor); |
127 | Object.defineBinding(this, "selectedIndexes", selectedIndexesBindingDescriptor); | 125 | Object.defineBinding(this, "selectedIndexes", selectedIndexesBindingDescriptor); |
126 | Object.defineBinding(this, "selections", selectionsBindingDescriptor); | ||
128 | } else { | 127 | } else { |
129 | // otherwise we need to defer it until later; we haven't been deserialized yet | 128 | // otherwise we need to defer it until later; we haven't been deserialized yet |
130 | if (!this._controllerBindingsToInstall) { | 129 | if (!this._controllerBindingsToInstall) { |
@@ -133,6 +132,7 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
133 | 132 | ||
134 | this._controllerBindingsToInstall.objects = objectsBindingDescriptor; | 133 | this._controllerBindingsToInstall.objects = objectsBindingDescriptor; |
135 | this._controllerBindingsToInstall.selectedIndexes = selectedIndexesBindingDescriptor; | 134 | this._controllerBindingsToInstall.selectedIndexes = selectedIndexesBindingDescriptor; |
135 | this._controllerBindingsToInstall.selections = selectionsBindingDescriptor; | ||
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
@@ -161,7 +161,7 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
161 | }, | 161 | }, |
162 | set: function(value) { | 162 | set: function(value) { |
163 | if (logger.isDebug) { | 163 | if (logger.isDebug) { |
164 | logger.debug(this, " set objects:", value.length, value, "same objects?", value === this._objects); | 164 | logger.debug(this, " set objects:", (value ? value.length : null), value, "same objects?", value === this._objects); |
165 | } | 165 | } |
166 | this._objects = value; | 166 | this._objects = value; |
167 | 167 | ||
@@ -173,6 +173,7 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
173 | if (this._isComponentExpanded) { | 173 | if (this._isComponentExpanded) { |
174 | this._refreshItems(); | 174 | this._refreshItems(); |
175 | } | 175 | } |
176 | |||
176 | }, | 177 | }, |
177 | modify: function(modificationType, newValue, oldValue) { | 178 | modify: function(modificationType, newValue, oldValue) { |
178 | this.selectedIndexes = null; | 179 | this.selectedIndexes = null; |
@@ -223,7 +224,7 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
223 | Description TODO | 224 | Description TODO |
224 | @private | 225 | @private |
225 | */ | 226 | */ |
226 | _childComponentsCount: { | 227 | _iterationChildComponentsCount: { |
227 | enumerable: false, | 228 | enumerable: false, |
228 | serializable: true, | 229 | serializable: true, |
229 | value: null | 230 | value: null |
@@ -279,14 +280,6 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
279 | Description TODO | 280 | Description TODO |
280 | @private | 281 | @private |
281 | */ | 282 | */ |
282 | _iterationFragment: { | ||
283 | enumerable: false, | ||
284 | value: null | ||
285 | }, | ||
286 | /** | ||
287 | Description TODO | ||
288 | @private | ||
289 | */ | ||
290 | _refreshingItems: { | 283 | _refreshingItems: { |
291 | value: false | 284 | value: false |
292 | }, | 285 | }, |
@@ -322,7 +315,7 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
322 | // or well I'm trying a flag right | 315 | // or well I'm trying a flag right |
323 | if (neededItemCount > 0) { | 316 | if (neededItemCount > 0) { |
324 | // _addItem might be completly synchrounous since we cache both template and deserializer so we need to set this before adding any item otherwise it will trigger a draw after every iteration template instantiation. | 317 | // _addItem might be completly synchrounous since we cache both template and deserializer so we need to set this before adding any item otherwise it will trigger a draw after every iteration template instantiation. |
325 | this._expectedChildComponentsCount += (this._childComponentsCount||1) * neededItemCount; | 318 | this._expectedChildComponentsCount += (this._iterationChildComponentsCount||1) * neededItemCount; |
326 | this.canDrawGate.setField("iterationLoaded", false); | 319 | this.canDrawGate.setField("iterationLoaded", false); |
327 | // Need to add more items | 320 | // Need to add more items |
328 | for (i = 0; i < neededItemCount; i++) { | 321 | for (i = 0; i < neededItemCount; i++) { |
@@ -363,10 +356,8 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
363 | // for clarity sake | 356 | // for clarity sake |
364 | this._itemsToAppend.push(this._currentItem); | 357 | this._itemsToAppend.push(this._currentItem); |
365 | index = items.length + this._itemsToAppend.length - 1; | 358 | index = items.length + this._itemsToAppend.length - 1; |
366 | |||
367 | self._canDraw = false; | 359 | self._canDraw = false; |
368 | componentsCount = this._childComponentsCount; | 360 | componentsCount = this._iterationChildComponentsCount; |
369 | |||
370 | this._iterationTemplate.instantiateWithComponent(this, function() { | 361 | this._iterationTemplate.instantiateWithComponent(this, function() { |
371 | if (componentsCount === 0) { | 362 | if (componentsCount === 0) { |
372 | if (++self._childLoadedCount === self._expectedChildComponentsCount) { | 363 | if (++self._childLoadedCount === self._expectedChildComponentsCount) { |
@@ -374,11 +365,10 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
374 | } | 365 | } |
375 | } else { | 366 | } else { |
376 | childComponents = self.childComponents; | 367 | childComponents = self.childComponents; |
377 | componentStartIndex = index * self._childComponentsCount; | 368 | componentStartIndex = index * self._iterationChildComponentsCount; |
378 | componentEndIndex = componentStartIndex + componentsCount; | 369 | componentEndIndex = componentStartIndex + componentsCount; |
379 | for (var i = componentStartIndex; i < componentEndIndex; i++) { | 370 | for (var i = componentStartIndex; i < componentEndIndex; i++) { |
380 | childComponent = childComponents[i]; | 371 | childComponent = childComponents[i]; |
381 | childComponent.element.id = childComponent.element.id + "-" + index; | ||
382 | childComponent.needsDraw = true; | 372 | childComponent.needsDraw = true; |
383 | childComponent.loadComponentTree(function() { | 373 | childComponent.loadComponentTree(function() { |
384 | if (++self._childLoadedCount === self._expectedChildComponentsCount) { | 374 | if (++self._childLoadedCount === self._expectedChildComponentsCount) { |
@@ -395,13 +385,14 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
395 | */ | 385 | */ |
396 | _deleteItem: {value: function() { | 386 | _deleteItem: {value: function() { |
397 | 387 | ||
398 | var deletedItem, itemIndex, removedComponents, childComponents = this.childComponents, childComponentsCount = this._childComponentsCount, | 388 | var deletedItem, itemIndex, removedComponents, childComponents = this.childComponents, childComponentsCount = this._iterationChildComponentsCount, |
399 | itemsToAppendCount = this._itemsToAppend.length; | 389 | itemsToAppendCount = this._itemsToAppend.length; |
400 | if (itemsToAppendCount > 0) { | 390 | if (itemsToAppendCount > 0) { |
401 | // We caught the need to remove these items before they got inserted | 391 | // We caught the need to remove these items before they got inserted |
402 | // just don't bother appending them | 392 | // just don't bother appending them |
403 | deletedItem = this._itemsToAppend.pop(); | 393 | deletedItem = this._itemsToAppend.pop(); |
404 | this._deletedItems.push(deletedItem); | 394 | // TODO: make _deletedItems usable in _addItem |
395 | //this._deletedItems.push(deletedItem); | ||
405 | if (--itemsToAppendCount <= this._nextDeserializedItemIx) { | 396 | if (--itemsToAppendCount <= this._nextDeserializedItemIx) { |
406 | this._nextDeserializedItemIx = itemsToAppendCount; | 397 | this._nextDeserializedItemIx = itemsToAppendCount; |
407 | } | 398 | } |
@@ -416,7 +407,7 @@ var Repetition = exports.Repetition = Montage.create(Component, /** @lends modul | |||
416 | this._childLoadedCount -= childComponentsCount; | 407 | this._childLoadedCount -= childComponentsCount; |
417 | this._expectedChildComponentsCount -= childComponentsCount; | 408 | this._expectedChildComponentsCount -= childComponentsCount; |
418 | for (var i = 0, l = removedComponents.length; i < l; i++) { | 409 | for (var i = 0, l = removedComponents.length; i < l; i+ |