aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorEric Guzman2012-05-21 13:25:03 -0700
committerEric Guzman2012-05-21 13:25:03 -0700
commit121c25b6d581758d7a9ae19cb3e4416835da6964 (patch)
tree11fc885f66faa28cabd589d272fc66bf7dee152b /js
parent1e6f46ba556ca3270c89fb848d93856804dd1cc8 (diff)
downloadninja-121c25b6d581758d7a9ae19cb3e4416835da6964.tar.gz
CSS Panel - Selection change fix for pushing to the selection array
Diffstat (limited to 'js')
-rw-r--r--js/panels/css-panel/styles-view-container.reel/styles-view-container.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/js/panels/css-panel/styles-view-container.reel/styles-view-container.js b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
index 3f0cd47e..7560ce6f 100644
--- a/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
+++ b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
@@ -29,9 +29,18 @@ exports.StylesViewContainer = Montage.create(Component, {
29 this.needsDraw = true; 29 this.needsDraw = true;
30 } 30 }
31 }, 31 },
32 _lastSelection : { 32 _prevSelection : {
33 value: null 33 value: null
34 }, 34 },
35 prevSelection : {
36 get: function() {
37 return this._prevSelection;
38 },
39 set: function(value) {
40 console.log("setting last selection to " + value);
41 this._prevSelection = value;
42 }
43 },
35 _hasStyles : { 44 _hasStyles : {
36 value: false 45 value: false
37 }, 46 },
@@ -75,16 +84,25 @@ exports.StylesViewContainer = Montage.create(Component, {
75 this.eventManager.addEventListener( "selectionChange", this, false); 84 this.eventManager.addEventListener( "selectionChange", this, false);
76 } 85 }
77 }, 86 },
87 _copy : {
88 value: function(array) {
89 return array.map(function(item) { return item; });
90 }
91 },
78 handleSelectionChange: { 92 handleSelectionChange: {
79 value: function() { 93 value: function() {
80 var elements = this.application.ninja.selectedElements; 94 var elements = this.application.ninja.selectedElements,
95 elementsCopy = this._copy(elements);
81 96
82 if(this._isSameArray(elements, this._lastSelection) && this.contentPanel === "rules") { 97 if(this._isSameArray(elements, this.prevSelection) && this.contentPanel === "rules") {
83 console.log('new selection is identical'); 98 console.log('new selection is identical');
84 return false; 99 return false;
85 } 100 }
86 101
87 this._lastSelection = elements; 102 // TODO: should selection always create new array
103 // TODO: pushing to selection array makes prevSelection
104 // TODO: invalid
105 this.prevSelection = elementsCopy;
88 106
89 if(elements.length === 0) { 107 if(elements.length === 0) {
90 this.hasStyles = false; 108 this.hasStyles = false;
@@ -96,7 +114,7 @@ exports.StylesViewContainer = Montage.create(Component, {
96 this.selectionNameLabelText = this._getElementLabel(elements[0]); 114 this.selectionNameLabelText = this._getElementLabel(elements[0]);
97 115
98 if(this.contentPanel === "rules") { 116 if(this.contentPanel === "rules") {
99 this.ruleListContainer.displayListForSelection(elements); 117 this.ruleListContainer.displayListForSelection(elementsCopy);
100 } else { 118 } else {
101 this.computedStyleView.declaration = elements[0]; 119 this.computedStyleView.declaration = elements[0];
102 } 120 }
@@ -106,7 +124,7 @@ exports.StylesViewContainer = Montage.create(Component, {
106 this.contentPanel = "rules"; 124 this.contentPanel = "rules";
107 this.selectionNameLabelText = elements.length + " elements selected."; 125 this.selectionNameLabelText = elements.length + " elements selected.";
108 ///// find common rules 126 ///// find common rules
109 this.ruleListContainer.displayListForSelection(elements); 127 this.ruleListContainer.displayListForSelection(elementsCopy);
110 128
111 } 129 }
112 130