diff options
author | Valerio Virgillito | 2012-02-03 12:20:10 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-03 12:20:10 -0800 |
commit | e6e539f345f5e1ac36a595db5d1a1c3700715e88 (patch) | |
tree | 39846bf1570f9b5a4057b726c54905de9e9e1c02 /node_modules/montage/ui/controller/array-controller.js | |
parent | 7950424cf704bb221971f4645406b01e6979db18 (diff) | |
parent | c630ead20487c3948fa36448d3e7d5f7b5cba782 (diff) | |
download | ninja-e6e539f345f5e1ac36a595db5d1a1c3700715e88.tar.gz |
Merge branch 'master' into components
Conflicts:
node_modules/montage/ui/bluemoon/progress.reel/progress.html
node_modules/montage/ui/image2.reel/image2.html
node_modules/ninja-components/effect/desaturate-effect.js
node_modules/ninja-components/effect/effect.js
node_modules/ninja-components/effect/invert-effect.js
node_modules/ninja-components/effect/kaliedoscope-effect.js
node_modules/ninja-components/effect/multiply-effect.js
node_modules/ninja-components/effect/sepia-effect.js
node_modules/ninja-components/flow-controller.reel/flow-controller.html
node_modules/ninja-components/flow-controller.reel/flow-controller.js
node_modules/ninja-components/flow-offset.js
node_modules/ninja-components/hottext.reel/hottext.css
node_modules/ninja-components/hottext.reel/hottext.html
node_modules/ninja-components/hottext.reel/hottext.js
node_modules/ninja-components/hottextunit.reel/hottextunit.css
node_modules/ninja-components/hottextunit.reel/hottextunit.html
node_modules/ninja-components/hottextunit.reel/hottextunit.js
node_modules/ninja-components/image2.reel/image2.html
node_modules/ninja-components/image2.reel/image2.js
node_modules/ninja-components/image3d.reel/image3d.html
node_modules/ninja-components/image3d.reel/image3d.js
node_modules/ninja-components/photo-editor.reel/photo-editor.css
node_modules/ninja-components/photo-editor.reel/photo-editor.html
node_modules/ninja-components/photo-editor.reel/photo-editor.js
node_modules/ninja-components/slider-base.js
user-document-templates/montage-application-cloud/appdelegate.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/controller/array-controller.js')
-rwxr-xr-x | node_modules/montage/ui/controller/array-controller.js | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/node_modules/montage/ui/controller/array-controller.js b/node_modules/montage/ui/controller/array-controller.js index 98b0c66f..868ae5de 100755 --- a/node_modules/montage/ui/controller/array-controller.js +++ b/node_modules/montage/ui/controller/array-controller.js | |||
@@ -47,8 +47,8 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController, | |||
47 | 47 | ||
48 | //TODO for right now assume that any content change invalidates the selection completely; we'll need to address this of course | 48 | //TODO for right now assume that any content change invalidates the selection completely; we'll need to address this of course |
49 | this.selectedObjects = null; | 49 | this.selectedObjects = null; |
50 | |||
51 | this.organizeObjects(); | 50 | this.organizeObjects(); |
51 | this._initSelections(); | ||
52 | } | 52 | } |
53 | }, | 53 | }, |
54 | 54 | ||
@@ -599,7 +599,7 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController, | |||
599 | 599 | ||
600 | return this._selectedContentIndexes; | 600 | return this._selectedContentIndexes; |
601 | }, | 601 | }, |
602 | set: function(value) { | 602 | set: function(value, internalSet) { |
603 | var selectedIndexesChangeEvent, | 603 | var selectedIndexesChangeEvent, |
604 | selectedObjectsChangeEvent; | 604 | selectedObjectsChangeEvent; |
605 | 605 | ||
@@ -642,9 +642,78 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController, | |||
642 | 642 | ||
643 | this.dispatchEvent(selectedIndexesChangeEvent.withPlusValue(this.selectedIndexes)); | 643 | this.dispatchEvent(selectedIndexesChangeEvent.withPlusValue(this.selectedIndexes)); |
644 | this.dispatchEvent(selectedObjectsChangeEvent.withPlusValue(this.selectedObjects)); | 644 | this.dispatchEvent(selectedObjectsChangeEvent.withPlusValue(this.selectedObjects)); |
645 | |||
646 | if(!internalSet) { | ||
647 | // update the selections only if the selectedContentIndexes is set directly | ||
648 | this._updateSelections(); | ||
649 | } | ||
650 | |||
651 | } | ||
652 | }, | ||
653 | |||
654 | |||
655 | _initSelections: { | ||
656 | value: function() { | ||
657 | // create an array with null values with same | ||
658 | // length as organizedObjects | ||
659 | var len = this._organizedObjects.length; | ||
660 | var arr = []; | ||
661 | arr[0] = null; | ||
662 | arr[len-1] = null; | ||
663 | |||
664 | this._selections = arr; | ||
665 | //Object.getPropertyDescriptor(this, "selections").set.call(this, arr, true); | ||
645 | } | 666 | } |
646 | }, | 667 | }, |
647 | 668 | ||
669 | _updateSelections: { | ||
670 | value: function() { | ||
671 | |||
672 | if(this.selectedIndexes) { | ||
673 | this._initSelections(); | ||
674 | var arr = this._selections; | ||
675 | var selectedIndexes = this.selectedIndexes || []; | ||
676 | var len = selectedIndexes.length, i=0, index; | ||
677 | |||
678 | for(i=0; i< len; i++) { | ||
679 | index = selectedIndexes[i]; | ||
680 | if(index < arr.length-1) { | ||
681 | arr[index] = true; | ||
682 | } | ||
683 | } | ||
684 | } | ||
685 | |||
686 | Object.getPropertyDescriptor(this, "selections").set.call(this, arr, true); | ||
687 | |||
688 | } | ||
689 | }, | ||
690 | |||
691 | // parse array with same length as objects but contains true / false(falsy) | ||
692 | _selections: {value: null}, | ||
693 | selections: { | ||
694 | get: function() { | ||
695 | return this._selections; | ||
696 | }, | ||
697 | set: function(v, internalSet) { | ||
698 | this._selections = v; | ||
699 | if(this._selections) { | ||
700 | |||
701 | if(!internalSet) { | ||
702 | var arr = []; | ||
703 | this._selections.forEach(function(item, i) { | ||
704 | if(item) { | ||
705 | arr.push(i); | ||
706 | } | ||
707 | }); | ||
708 | // use the internalSet flag to prevent setting the selections again, | ||
709 | Object.getPropertyDescriptor(this, "selectedIndexes").set.call(this, arr, true); | ||
710 | } | ||
711 | |||
712 | } | ||
713 | } | ||
714 | }, | ||
715 | |||
716 | |||
648 | /** | 717 | /** |
649 | Initalizes the ArrayController with the specified content. | 718 | Initalizes the ArrayController with the specified content. |
650 | @function | 719 | @function |