From 7358c12a45ac2923e7553b17a1cc7c15af70e4c8 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 10 May 2012 16:33:12 -0700 Subject: CSS Panel - Add work-around for selection change event. --- .../styles-view-container.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/panels') 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 6ce64b8f..a47b0db1 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 @@ -14,6 +14,9 @@ exports.StylesViewContainer = Montage.create(Component, { contentPanel : { value: 'rules' }, + _lastSelection : { + value: null + }, _hasStyles : { value: false }, @@ -59,6 +62,10 @@ exports.StylesViewContainer = Montage.create(Component, { value: function() { var elements = this.application.ninja.selectedElements; + if(this._isSameArray(elements, this._lastSelection)) { console.log('new selection is identical');return false; } + + this._lastSelection = elements; + if(elements.length === 0) { this.hasStyles = false; return false; @@ -129,5 +136,16 @@ exports.StylesViewContainer = Montage.create(Component, { this.selectionNameLabel.classList.add('no-styles'); } } + }, + + _isSameArray : { + value: function(left, right) { + if(!left || !right) { return false; } + if(left.length !== right.length) { return false; } + + return left.every(function(item, i) { + return item === right[i]; + }); + } } }); \ No newline at end of file -- cgit v1.2.3