diff options
Diffstat (limited to 'js/panels/css-panel/styles-view-delegate.js')
-rw-r--r-- | js/panels/css-panel/styles-view-delegate.js | 109 |
1 files changed, 54 insertions, 55 deletions
diff --git a/js/panels/css-panel/styles-view-delegate.js b/js/panels/css-panel/styles-view-delegate.js index 71b4a8dd..3f29ba27 100644 --- a/js/panels/css-panel/styles-view-delegate.js +++ b/js/panels/css-panel/styles-view-delegate.js | |||
@@ -72,61 +72,6 @@ exports.StylesViewMediator = Montage.create(Component, { | |||
72 | } | 72 | } |
73 | }, | 73 | }, |
74 | 74 | ||
75 | |||
76 | /// Toolbar Button Actions | ||
77 | /// ----------------------- | ||
78 | |||
79 | ///// Add rule button action | ||
80 | handleAddAction : { | ||
81 | value: function(e) { | ||
82 | var selector, | ||
83 | newRule, | ||
84 | applies = true; | ||
85 | |||
86 | ///// Get selection prefix | ||
87 | if(this.ruleListContainer.displayedList.selection.length > 1) { | ||
88 | selector = this.stylesController.generateClassName(null, true); | ||
89 | } else { | ||
90 | selector = this.stylesController.generateClassName(this.newClassPrefix); | ||
91 | } | ||
92 | |||
93 | ///// Create the rule with generated selector | ||
94 | newRule = this.application.ninja.stylesController.addRule('.'+selector, ' { }'); | ||
95 | |||
96 | ///// Add the generated class to each element in selection | ||
97 | ///// and check whether it applies to the element | ||
98 | this.ruleListContainer.displayedList.selection.forEach(function(el) { | ||
99 | this.stylesController.addClass(el, selector); | ||
100 | |||
101 | if(applies) { | ||
102 | applies = (this._doesSelectorTargetElement('.'+selector, el)); | ||
103 | } | ||
104 | },this); | ||
105 | |||
106 | ///// Add rule directly to the rule list | ||
107 | this.ruleListContainer.displayedList.component.addRule(newRule).applied = applies; | ||
108 | |||
109 | } | ||
110 | }, | ||
111 | |||
112 | ///// Show/hide computed style sub panel | ||
113 | handleComputedAction : { | ||
114 | value: function(e) { | ||
115 | var container = this.ownerComponent, | ||
116 | panelToShow = (container.contentPanel === "computed") ? "rules" : "computed"; | ||
117 | |||
118 | ///// Handle showing and hiding of the add button | ||
119 | if(panelToShow === "computed") { | ||
120 | container.toolbar.hideButton('add'); | ||
121 | } else { | ||
122 | container.toolbar.showButton('add'); | ||
123 | } | ||
124 | |||
125 | container.contentPanel = panelToShow; | ||
126 | this.ownerComponent.handleSelectionChange(); | ||
127 | } | ||
128 | }, | ||
129 | |||
130 | ///// Style event handlers | 75 | ///// Style event handlers |
131 | //// ------------------------------------- | 76 | //// ------------------------------------- |
132 | 77 | ||
@@ -270,6 +215,60 @@ exports.StylesViewMediator = Montage.create(Component, { | |||
270 | } | 215 | } |
271 | }, | 216 | }, |
272 | 217 | ||
218 | /// Toolbar Button Actions | ||
219 | /// ----------------------- | ||
220 | |||
221 | ///// Add rule button action | ||
222 | handleAddAction : { | ||
223 | value: function(e) { | ||
224 | var selector, | ||
225 | newRule, | ||
226 | applies = true; | ||
227 | |||
228 | ///// Get selection prefix | ||
229 | if(this.ruleListContainer.displayedList.selection.length > 1) { | ||
230 | selector = this.stylesController.generateClassName(null, true); | ||
231 | } else { | ||
232 | selector = this.stylesController.generateClassName(this.newClassPrefix); | ||
233 | } | ||
234 | |||
235 | ///// Create the rule with generated selector | ||
236 | newRule = this.application.ninja.stylesController.addRule('.'+selector, ' { }'); | ||
237 | |||
238 | ///// Add the generated class to each element in selection | ||
239 | ///// and check whether it applies to the element | ||
240 | this.ruleListContainer.displayedList.selection.forEach(function(el) { | ||
241 | this.stylesController.addClass(el, selector); | ||
242 | |||
243 | if(applies) { | ||
244 | applies = (this._doesSelectorTargetElement('.'+selector, el)); | ||
245 | } | ||
246 | },this); | ||
247 | |||
248 | ///// Add rule directly to the rule list | ||
249 | this.ruleListContainer.displayedList.component.addRule(newRule).applied = applies; | ||
250 | |||
251 | } | ||
252 | }, | ||
253 | |||
254 | ///// Show/hide computed style sub panel | ||
255 | handleComputedAction : { | ||
256 | value: function(e) { | ||
257 | var container = this.ownerComponent, | ||
258 | panelToShow = (container.contentPanel === "computed") ? "rules" : "computed"; | ||
259 | |||
260 | ///// Handle showing and hiding of the add button | ||
261 | if(panelToShow === "computed") { | ||
262 | container.toolbar.hideButton('add'); | ||
263 | } else { | ||
264 | container.toolbar.showButton('add'); | ||
265 | } | ||
266 | |||
267 | container.contentPanel = panelToShow; | ||
268 | this.ownerComponent.handleSelectionChange(); | ||
269 | } | ||
270 | }, | ||
271 | |||
273 | ///// Utilities | 272 | ///// Utilities |
274 | //// ------------------------------------- | 273 | //// ------------------------------------- |
275 | 274 | ||