From 1c528b42f9b1c9be9197921586388c3a3bdc5c17 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 22 Feb 2012 23:16:23 -0800 Subject: CSS Panel Update - Adding montage objects for css panel --- .../styles-view-container.js | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 js/panels/css-panel/styles-view-container.reel/styles-view-container.js (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 new file mode 100644 index 00000000..41e16192 --- /dev/null +++ b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js @@ -0,0 +1,35 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; + +exports.StylesViewContainer = Montage.create(Component, { + noDocumentCondition : { + value: true + }, + contentPanel : { + value: 'rules' + }, + displayedList : { + value: null + }, + deserializedFromTemplate : { + value: function() { + console.log("styles view container - deserialized"); + } + }, + prepareForDraw : { + value: function() { + console.log("styles view container - prepare for draw"); + } + }, + draw : { + value: function() { + console.log("styles view container - draw"); + } + } +}); \ No newline at end of file -- cgit v1.2.3 From 1433f2bdf2e5b8c5c18fed5e9c17fd983ab3606d Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 2 Mar 2012 10:55:51 -0800 Subject: CSS Panel - Updating components, created toolbar components, and small changes to styles controller --- .../styles-view-container.js | 133 ++++++++++++++++++++- 1 file changed, 129 insertions(+), 4 deletions(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 41e16192..6164a14c 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 @@ -8,28 +8,153 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; exports.StylesViewContainer = Montage.create(Component, { - noDocumentCondition : { + noStylesCondition : { value: true }, + contentController : { + value: null + }, contentPanel : { value: 'rules' }, - displayedList : { - value: null + _hasStyles : { + value: false }, - deserializedFromTemplate : { + hasStyles : { + get: function() { + return this._hasStyles; + }, + set: function(hasThem) { + this._hasStyles = hasThem; + this.needsDraw = true; + } + }, + templateDidLoad : { value: function() { console.log("styles view container - deserialized"); + this.eventManager.addEventListener('styleSheetsReady', this, false); + } + }, + handleStyleSheetsReady: { + value: function(e) { + this.eventManager.addEventListener( "selectionChange", this, false); + } + }, + handleSelectionChange: { + value: function() { + var elements = this.application.ninja.selectedElements, + type, selection, ruleList; + + if(elements.length === 0) { + return false; + } else if(elements.length >= 1) { + type = 'ELEMENTS'; + selection = elements; + } else { + type = 'ELEMENTS'; + selection = elements[0] + } + + ruleList = this._getRuleList({ + selectionType : type, + selection : selection + }); + + if(ruleList) { + this.displayedList = ruleList; + } + } + }, + _lastDisplayedList : { + value: null + }, + _displayedList : { + value: null + }, + displayedList : { + get: function() { + return this._displayedList; + }, + set: function(list) { + this._hasStyles = true; + this._lastDisplayedList = this._displayedList; + this._displayedList = list; + this.needsDraw = true; + } + }, + _ruleList : { + value: [] + }, + ruleList : { + get: function() { + return this._ruleList; + }, + set: function(list) { + if(!list) { + this._ruleList.length = 0; + return; + } + + this._ruleList = list; + this.needsDraw = true; } }, prepareForDraw : { value: function() { + debugger; console.log("styles view container - prepare for draw"); } }, draw : { value: function() { console.log("styles view container - draw"); +console.log("has style = " + this._hasStyles); + if(this.hasStyles) { + this.element.classList.remove('no-styles'); + } else { + this.element.classList.add('no-styles'); + } + + if(this._lastDisplayedList) { + //this._lastDisplayedList.style.display = 'none'; + } + + //this._displayedList.style.display = ''; + } + }, + _getRuleList : { + value: function(s) { + var ruleListsOfType, i, list, matchesAll; + + ruleListsOfType = this.ruleLists.filter(function(list) { + return list.selectionType = s.selectionType; + }); + + for(i = 0; i= 1) { + } else if(elements.length > 1) { type = 'ELEMENTS'; - selection = elements; + selection = elements.map(function(obj) { + return obj._element; + }); } else { - type = 'ELEMENTS'; - selection = elements[0] + type = 'ELEMENT'; + selection = elements[0]._element; } - ruleList = this._getRuleList({ + ruleList = this.ruleListContainer._getRuleList({ selectionType : type, selection : selection }); if(ruleList) { - this.displayedList = ruleList; + this.ruleListContainer.displayedList = ruleList; + } else { + this.ruleListContainer.add(type, selection); } + + this.hasStyles = true; } }, - _lastDisplayedList : { - value: null - }, - _displayedList : { - value: null - }, - displayedList : { - get: function() { - return this._displayedList; - }, - set: function(list) { - this._hasStyles = true; - this._lastDisplayedList = this._displayedList; - this._displayedList = list; - this.needsDraw = true; - } - }, + _ruleList : { value: [] }, @@ -101,60 +88,16 @@ exports.StylesViewContainer = Montage.create(Component, { }, prepareForDraw : { value: function() { - debugger; console.log("styles view container - prepare for draw"); } }, draw : { value: function() { - console.log("styles view container - draw"); -console.log("has style = " + this._hasStyles); if(this.hasStyles) { this.element.classList.remove('no-styles'); } else { this.element.classList.add('no-styles'); } - - if(this._lastDisplayedList) { - //this._lastDisplayedList.style.display = 'none'; - } - - //this._displayedList.style.display = ''; - } - }, - _getRuleList : { - value: function(s) { - var ruleListsOfType, i, list, matchesAll; - - ruleListsOfType = this.ruleLists.filter(function(list) { - return list.selectionType = s.selectionType; - }); - - for(i = 0; i 1) { type = 'ELEMENTS'; - selection = elements.map(function(obj) { - return obj._element; - }); + selection = elements; } else { type = 'ELEMENT'; - selection = elements[0]._element; + selection = elements[0]; } ruleList = this.ruleListContainer._getRuleList({ -- cgit v1.2.3 From 435dde54bf607620947007f7c66bd98bd03fe90b Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 11 Apr 2012 11:02:15 -0700 Subject: CSS Rule List - Enabled list switching on selection --- .../styles-view-container.js | 48 ++-------------------- 1 file changed, 3 insertions(+), 45 deletions(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 7df39d39..0204d2b8 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 @@ -28,7 +28,6 @@ exports.StylesViewContainer = Montage.create(Component, { }, templateDidLoad : { value: function() { - console.log("styles view container - deserialized"); this.eventManager.addEventListener('styleSheetsReady', this, false); } }, @@ -39,56 +38,15 @@ exports.StylesViewContainer = Montage.create(Component, { }, handleSelectionChange: { value: function() { - var elements = this.application.ninja.selectedElements, - type, selection, ruleList; + var elements = this.application.ninja.selectedElements; - if(elements.length === 0) { - return false; - } else if(elements.length > 1) { - type = 'ELEMENTS'; - selection = elements; - } else { - type = 'ELEMENT'; - selection = elements[0]; - } - - ruleList = this.ruleListContainer._getRuleList({ - selectionType : type, - selection : selection - }); - - if(ruleList) { - this.ruleListContainer.displayedList = ruleList; - } else { - this.ruleListContainer.add(type, selection); - } + if(elements.length === 0) { return false; } + this.ruleListContainer.displayListForSelection(elements); this.hasStyles = true; } }, - _ruleList : { - value: [] - }, - ruleList : { - get: function() { - return this._ruleList; - }, - set: function(list) { - if(!list) { - this._ruleList.length = 0; - return; - } - - this._ruleList = list; - this.needsDraw = true; - } - }, - prepareForDraw : { - value: function() { - console.log("styles view container - prepare for draw"); - } - }, draw : { value: function() { if(this.hasStyles) { -- cgit v1.2.3 From 9a94c6fb5f82d18139b48341788a0ffca23ae0af Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 1 May 2012 11:15:14 -0700 Subject: CSS Panel - Added removing of rules/styles --- .../css-panel/styles-view-container.reel/styles-view-container.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 0204d2b8..e51c78cd 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,6 +29,7 @@ exports.StylesViewContainer = Montage.create(Component, { templateDidLoad : { value: function() { this.eventManager.addEventListener('styleSheetsReady', this, false); + this.eventManager.addEventListener('elementChange', this, false); } }, handleStyleSheetsReady: { @@ -46,6 +47,13 @@ exports.StylesViewContainer = Montage.create(Component, { this.hasStyles = true; } }, + handleElementChange : { + value: function(e) { + if(e._event.detail.type !== 'cssChange') { + this.ruleListContainer.displayedList.component.update(); + } + } + }, draw : { value: function() { -- cgit v1.2.3 From 514aee0052f6721758401023accd9a4a56cdd217 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 1 May 2012 11:32:11 -0700 Subject: CSS Panel - Display no styles when deselecting all --- .../css-panel/styles-view-container.reel/styles-view-container.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 e51c78cd..1d6d6075 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 @@ -41,7 +41,10 @@ exports.StylesViewContainer = Montage.create(Component, { value: function() { var elements = this.application.ninja.selectedElements; - if(elements.length === 0) { return false; } + if(elements.length === 0) { + this.hasStyles = false; + return false; + } this.ruleListContainer.displayListForSelection(elements); this.hasStyles = true; -- cgit v1.2.3 From 560d9255ed1bba04f3dc3f4320307f7d5626bfab Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 3 May 2012 11:49:24 -0700 Subject: CSS Panel - Support showing computed styles --- .../styles-view-container.js | 46 ++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 1d6d6075..32b2c3ee 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,6 +29,7 @@ exports.StylesViewContainer = Montage.create(Component, { templateDidLoad : { value: function() { this.eventManager.addEventListener('styleSheetsReady', this, false); + //this.eventManager.addEventListener('elementChanging', this, false); this.eventManager.addEventListener('elementChange', this, false); } }, @@ -44,17 +45,56 @@ exports.StylesViewContainer = Montage.create(Component, { if(elements.length === 0) { this.hasStyles = false; return false; + } else if(elements.length === 1) { + if(this.contentPanel === "rules") { + this.ruleListContainer.displayListForSelection(elements); + } else { + this.computedStyleView.declaration = elements[0]; + } + } else { + } - this.ruleListContainer.displayListForSelection(elements); this.hasStyles = true; } }, handleElementChange : { value: function(e) { - if(e._event.detail.type !== 'cssChange') { - this.ruleListContainer.displayedList.component.update(); + var elements = this.application.ninja.selectedElements; + + if(elements.length === 0) { + return false; + } else if(elements.length === 1) { + if(this.contentPanel === "rules") { + if(e._event.detail.type !== 'cssChange') { + this.ruleListContainer.displayedList.component.update(); + } + } else { + this.computedStyleView.declaration = elements[0]; + } + } else { + return false; + } + + } + }, + + handleElementChanging : { + value: function(e) { + var elements = this.application.ninja.selectedElements; + + if(elements.length === 1) { + if(this.contentPanel === "rules") { +// if(e._event.detail.type !== 'cssChange') { +// this.ruleListContainer.displayedList.component.update(); +// } + } else { + this.computedStyleView.declaration = elements[0]; + } } + + return false; + } }, -- cgit v1.2.3 From 8b9024faa65566a18e4548f198b43f18390e6bc5 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 3 May 2012 16:01:47 -0700 Subject: CSS Panel - Add labels for selection and document names --- .../styles-view-container.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 32b2c3ee..c927fe9a 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 @@ -26,6 +26,23 @@ exports.StylesViewContainer = Montage.create(Component, { this.needsDraw = true; } }, + + _getElementLabel : { + value: function(el) { + var id = '#'+el.id, + className = '.'+Array.prototype.slice.call(el.classList).join('.'), + nodeName = el.nodeName; + + if(id.length > 1) { + return nodeName + id; + } else if(className.length > 1) { + return nodeName + className; + } + + return nodeName; + } + }, + templateDidLoad : { value: function() { this.eventManager.addEventListener('styleSheetsReady', this, false); @@ -46,6 +63,10 @@ exports.StylesViewContainer = Montage.create(Component, { this.hasStyles = false; return false; } else if(elements.length === 1) { + + ///// update the selection status label with the label of the element + this.selectionNameLabel.innerHTML = this._getElementLabel(elements[0]); + if(this.contentPanel === "rules") { this.ruleListContainer.displayListForSelection(elements); } else { @@ -102,8 +123,10 @@ exports.StylesViewContainer = Montage.create(Component, { value: function() { if(this.hasStyles) { this.element.classList.remove('no-styles'); + this.selectionNameLabel.classList.remove('no-styles'); } else { this.element.classList.add('no-styles'); + this.selectionNameLabel.classList.add('no-styles'); } } } -- cgit v1.2.3 From 5330de3ddb40a4db8a2a0572725ab64b23770b3b Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 8 May 2012 14:49:37 -0700 Subject: CSS Panel - Added update of new rules to rule list --- js/panels/css-panel/styles-view-container.reel/styles-view-container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 c927fe9a..6ce64b8f 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 @@ -88,7 +88,7 @@ exports.StylesViewContainer = Montage.create(Component, { } else if(elements.length === 1) { if(this.contentPanel === "rules") { if(e._event.detail.type !== 'cssChange') { - this.ruleListContainer.displayedList.component.update(); + this.ruleListContainer.update(); } } else { this.computedStyleView.declaration = elements[0]; -- cgit v1.2.3 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/css-panel/styles-view-container.reel/styles-view-container.js') 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 From d4ce8c2fe42fcbfc36cf4b20ef8de67c6471c241 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 14 May 2012 23:44:47 -0700 Subject: CSSPanel - Add mutli-selection and adding classes to groups of elements --- .../styles-view-container.js | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 a47b0db1..1372de0c 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,21 @@ exports.StylesViewContainer = Montage.create(Component, { contentPanel : { value: 'rules' }, + _selectionNameLabelText : { + value: null + }, + selectionNameLabelText : { + get: function() { + return this._selectionNameLabelText; + }, + set: function(value) { + if(value === this._selectionNameLabelText) { return false; } + + this._selectionNameLabelText = value; + + this.needsDraw = true; + } + }, _lastSelection : { value: null }, @@ -62,7 +77,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; } + if(this._isSameArray(elements, this._lastSelection) && this.contentPanel === "rules") { + console.log('new selection is identical'); + return false; + } this._lastSelection = elements; @@ -72,14 +90,20 @@ exports.StylesViewContainer = Montage.create(Component, { } else if(elements.length === 1) { ///// update the selection status label with the label of the element - this.selectionNameLabel.innerHTML = this._getElementLabel(elements[0]); + this.selectionNameLabelText = this._getElementLabel(elements[0]); if(this.contentPanel === "rules") { this.ruleListContainer.displayListForSelection(elements); } else { this.computedStyleView.declaration = elements[0]; } + this.toolbar.showButton('computed'); } else { + this.toolbar.hideButton('computed'); + this.contentPanel = "rules"; + this.selectionNameLabelText = elements.length + " elements selected."; + ///// find common rules + this.ruleListContainer.displayListForSelection(elements); } @@ -130,10 +154,12 @@ exports.StylesViewContainer = Montage.create(Component, { value: function() { if(this.hasStyles) { this.element.classList.remove('no-styles'); - this.selectionNameLabel.classList.remove('no-styles'); + //this.selectionNameLabel.classList.remove('no-styles'); + this.selectionName.element.classList.remove('no-styles'); } else { this.element.classList.add('no-styles'); - this.selectionNameLabel.classList.add('no-styles'); + //this.selectionNameLabel.classList.add('no-styles'); + this.selectionName.element.classList.add('no-styles'); } } }, -- cgit v1.2.3 From bbca3e05b39d43ce13c2f3e48cb33630ed7948b9 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 16 May 2012 14:14:25 -0700 Subject: CSS Panel - Added flag to draw method to improve perceived loading time --- .../css-panel/styles-view-container.reel/styles-view-container.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 1372de0c..e6e836ad 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 @@ -41,7 +41,8 @@ exports.StylesViewContainer = Montage.create(Component, { }, set: function(hasThem) { this._hasStyles = hasThem; - this.needsDraw = true; + //caller needs to set ndt + //this.needsDraw = true; } }, -- cgit v1.2.3 From d6f48218eb28804d4afbbf8b3e893aec8c19e520 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 17 May 2012 16:00:41 -0700 Subject: CSS Panel - Clear styles section on document close --- .../css-panel/styles-view-container.reel/styles-view-container.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 e6e836ad..e63e3c74 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 @@ -67,6 +67,7 @@ exports.StylesViewContainer = Montage.create(Component, { this.eventManager.addEventListener('styleSheetsReady', this, false); //this.eventManager.addEventListener('elementChanging', this, false); this.eventManager.addEventListener('elementChange', this, false); + this.eventManager.addEventListener("closeDocument", this, false); } }, handleStyleSheetsReady: { @@ -150,6 +151,12 @@ exports.StylesViewContainer = Montage.create(Component, { } }, + handleCloseDocument: { + value: function(e) { + this.hasStyles = false; + this.needsDraw = true; + } + }, draw : { value: function() { -- cgit v1.2.3 From e5f3f24f249ab5d2e260425d774c27f710be43bf Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 18 May 2012 17:26:03 -0700 Subject: CSS Panel - show no styles when all elements are deselected --- js/panels/css-panel/styles-view-container.reel/styles-view-container.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 e63e3c74..3f0cd47e 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 @@ -88,6 +88,7 @@ exports.StylesViewContainer = Montage.create(Component, { if(elements.length === 0) { this.hasStyles = false; + this.needsDraw = true; return false; } else if(elements.length === 1) { -- cgit v1.2.3 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/styles-view-container.reel/styles-view-container.js') 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 From d56af1a4716445db28d343182c8bfaf211eb6ab7 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 22 May 2012 11:15:47 -0700 Subject: CSS Panel - Remove console logs --- .../styles-view-container.js | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js') 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 7560ce6f..4a391421 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 @@ -37,7 +37,6 @@ exports.StylesViewContainer = Montage.create(Component, { return this._prevSelection; }, set: function(value) { - console.log("setting last selection to " + value); this._prevSelection = value; } }, @@ -74,7 +73,6 @@ exports.StylesViewContainer = Montage.create(Component, { templateDidLoad : { value: function() { this.eventManager.addEventListener('styleSheetsReady', this, false); - //this.eventManager.addEventListener('elementChanging', this, false); this.eventManager.addEventListener('elementChange', this, false); this.eventManager.addEventListener("closeDocument", this, false); } @@ -94,8 +92,8 @@ exports.StylesViewContainer = Montage.create(Component, { var elements = this.application.ninja.selectedElements, elementsCopy = this._copy(elements); + ///// Is selection identical? If so, do nothing. if(this._isSameArray(elements, this.prevSelection) && this.contentPanel === "rules") { - console.log('new selection is identical'); return false; } @@ -152,24 +150,6 @@ exports.StylesViewContainer = Montage.create(Component, { } }, - handleElementChanging : { - value: function(e) { - var elements = this.application.ninja.selectedElements; - - if(elements.length === 1) { - if(this.contentPanel === "rules") { -// if(e._event.detail.type !== 'cssChange') { -// this.ruleListContainer.displayedList.component.update(); -// } - } else { - this.computedStyleView.declaration = elements[0]; - } - } - - return false; - - } - }, handleCloseDocument: { value: function(e) { this.hasStyles = false; -- cgit v1.2.3