aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js')
-rw-r--r--js/panels/css-panel/styles-view-container.reel/styles-view-container.js83
1 files changed, 13 insertions, 70 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 6164a14c..5967345a 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,9 +8,6 @@ var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component;
9 9
10exports.StylesViewContainer = Montage.create(Component, { 10exports.StylesViewContainer = Montage.create(Component, {
11 noStylesCondition : {
12 value: true
13 },
14 contentController : { 11 contentController : {
15 value: null 12 value: null
16 }, 13 },
@@ -47,41 +44,31 @@ exports.StylesViewContainer = Montage.create(Component, {
47 44
48 if(elements.length === 0) { 45 if(elements.length === 0) {
49 return false; 46 return false;
50 } else if(elements.length >= 1) { 47 } else if(elements.length > 1) {
51 type = 'ELEMENTS'; 48 type = 'ELEMENTS';
52 selection = elements; 49 selection = elements.map(function(obj) {
50 return obj._element;
51 });
53 } else { 52 } else {
54 type = 'ELEMENTS'; 53 type = 'ELEMENT';
55 selection = elements[0] 54 selection = elements[0]._element;
56 } 55 }
57 56
58 ruleList = this._getRuleList({ 57 ruleList = this.ruleListContainer._getRuleList({
59 selectionType : type, 58 selectionType : type,
60 selection : selection 59 selection : selection
61 }); 60 });
62 61
63 if(ruleList) { 62 if(ruleList) {
64 this.displayedList = ruleList; 63 this.ruleListContainer.displayedList = ruleList;
64 } else {
65 this.ruleListContainer.add(type, selection);
65 } 66 }
67
68 this.hasStyles = true;
66 } 69 }
67 }, 70 },
68 _lastDisplayedList : { 71
69 value: null
70 },
71 _displayedList : {
72 value: null
73 },
74 displayedList : {
75 get: function() {
76 return this._displayedList;
77 },
78 set: function(list) {
79 this._hasStyles = true;
80 this._lastDisplayedList = this._displayedList;
81 this._displayedList = list;
82 this.needsDraw = true;
83 }
84 },
85 _ruleList : { 72 _ruleList : {
86 value: [] 73 value: []
87 }, 74 },
@@ -101,60 +88,16 @@ exports.StylesViewContainer = Montage.create(Component, {
101 }, 88 },
102 prepareForDraw : { 89 prepareForDraw : {
103 value: function() { 90 value: function() {
104 debugger;
105 console.log("styles view container - prepare for draw"); 91 console.log("styles view container - prepare for draw");
106 } 92 }
107 }, 93 },
108 draw : { 94 draw : {
109 value: function() { 95 value: function() {
110 console.log("styles view container - draw");
111console.log("has style = " + this._hasStyles);
112 if(this.hasStyles) { 96 if(this.hasStyles) {
113 this.element.classList.remove('no-styles'); 97 this.element.classList.remove('no-styles');
114 } else { 98 } else {
115 this.element.classList.add('no-styles'); 99 this.element.classList.add('no-styles');
116 } 100 }
117
118 if(this._lastDisplayedList) {
119 //this._lastDisplayedList.style.display = 'none';
120 }
121
122 //this._displayedList.style.display = '';
123 }
124 },
125 _getRuleList : {
126 value: function(s) {
127 var ruleListsOfType, i, list, matchesAll;
128
129 ruleListsOfType = this.ruleLists.filter(function(list) {
130 return list.selectionType = s.selectionType;
131 });
132
133 for(i = 0; i<this.ruleLists.length; i++) {
134 list = this.ruleLists[i];
135
136 if(s.selectionType === 'elements') {
137 matchesAll = list.selection.every(function(element, index, array) {
138 return array.indexOf(element) !== 0;
139 });
140
141 if(matchesAll) {
142 break;
143 }
144 } else {
145 ///// Selection (single element or stylesheet) is the same,
146 ///// Use the existing rule list
147 if(list.selection === s.selection) {
148 break;
149 }
150 }
151 }
152
153 return list;
154
155 } 101 }
156 },
157 ruleLists : {
158 value: []
159 } 102 }
160}); \ No newline at end of file 103}); \ No newline at end of file