From 121c25b6d581758d7a9ae19cb3e4416835da6964 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 21 May 2012 13:25:03 -0700 Subject: CSS Panel - Selection change fix for pushing to the selection array --- .../styles-view-container.js | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'js/panels/css-panel') 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, { this.needsDraw = true; } }, - _lastSelection : { + _prevSelection : { value: null }, + prevSelection : { + get: function() { + return this._prevSelection; + }, + set: function(value) { + console.log("setting last selection to " + value); + this._prevSelection = value; + } + }, _hasStyles : { value: false }, @@ -75,16 +84,25 @@ exports.StylesViewContainer = Montage.create(Component, { this.eventManager.addEventListener( "selectionChange", this, false); } }, + _copy : { + value: function(array) { + return array.map(function(item) { return item; }); + } + }, handleSelectionChange: { value: function() { - var elements = this.application.ninja.selectedElements; + var elements = this.application.ninja.selectedElements, + elementsCopy = this._copy(elements); - if(this._isSameArray(elements, this._lastSelection) && this.contentPanel === "rules") { + if(this._isSameArray(elements, this.prevSelection) && this.contentPanel === "rules") { console.log('new selection is identical'); return false; } - this._lastSelection = elements; + // TODO: should selection always create new array + // TODO: pushing to selection array makes prevSelection + // TODO: invalid + this.prevSelection = elementsCopy; if(elements.length === 0) { this.hasStyles = false; @@ -96,7 +114,7 @@ exports.StylesViewContainer = Montage.create(Component, { this.selectionNameLabelText = this._getElementLabel(elements[0]); if(this.contentPanel === "rules") { - this.ruleListContainer.displayListForSelection(elements); + this.ruleListContainer.displayListForSelection(elementsCopy); } else { this.computedStyleView.declaration = elements[0]; } @@ -106,7 +124,7 @@ exports.StylesViewContainer = Montage.create(Component, { this.contentPanel = "rules"; this.selectionNameLabelText = elements.length + " elements selected."; ///// find common rules - this.ruleListContainer.displayListForSelection(elements); + this.ruleListContainer.displayListForSelection(elementsCopy); } -- cgit v1.2.3