diff options
author | Eric Guzman | 2012-05-22 09:24:39 -0700 |
---|---|---|
committer | Eric Guzman | 2012-05-22 09:24:39 -0700 |
commit | 6686f2f0bc3ea1b4f589409c78a99bd07a41e7c3 (patch) | |
tree | e376202840e66ec4d22c67ebaeac7b0c8fea7ba4 | |
parent | b5bbf69e59dbadf6504955875cc13d893efe3259 (diff) | |
download | ninja-6686f2f0bc3ea1b4f589409c78a99bd07a41e7c3.tar.gz |
CSS Panel - Add Rule - apply new class after use specifies selector
-rw-r--r-- | js/panels/css-panel/styles-view-delegate.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/js/panels/css-panel/styles-view-delegate.js b/js/panels/css-panel/styles-view-delegate.js index 56727d40..583eb0ba 100644 --- a/js/panels/css-panel/styles-view-delegate.js +++ b/js/panels/css-panel/styles-view-delegate.js | |||
@@ -53,6 +53,19 @@ exports.StylesViewMediator = Montage.create(Component, { | |||
53 | return false; | 53 | return false; |
54 | } | 54 | } |
55 | 55 | ||
56 | if(!ruleComponent.firstChangeHappened) { | ||
57 | var lastClass = newSelector.substring(newSelector.lastIndexOf('.')+1); | ||
58 | |||
59 | if(lastClass !== newSelector) { | ||
60 | ///// Add the generated class to each element in selection | ||
61 | ///// and check whether it applies to the element | ||
62 | this.ruleListContainer.displayedList.selection.forEach(function(el) { | ||
63 | this.stylesController.addClass(el, lastClass); | ||
64 | },this); | ||
65 | } | ||
66 | ruleComponent.firstChangeHappened = true; | ||
67 | } | ||
68 | |||
56 | rule.selectorText = newSelector; | 69 | rule.selectorText = newSelector; |
57 | 70 | ||
58 | ruleComponent.applied = this.ruleListContainer.displayedList.selection.every(function(el) { | 71 | ruleComponent.applied = this.ruleListContainer.displayedList.selection.every(function(el) { |
@@ -225,13 +238,13 @@ exports.StylesViewMediator = Montage.create(Component, { | |||
225 | 238 | ||
226 | ///// Add the generated class to each element in selection | 239 | ///// Add the generated class to each element in selection |
227 | ///// and check whether it applies to the element | 240 | ///// and check whether it applies to the element |
228 | this.ruleListContainer.displayedList.selection.forEach(function(el) { | 241 | // this.ruleListContainer.displayedList.selection.forEach(function(el) { |
229 | this.stylesController.addClass(el, selector); | 242 | // this.stylesController.addClass(el, selector); |
230 | 243 | // | |
231 | if(applies) { | 244 | // if(applies) { |
232 | applies = (this._doesSelectorTargetElement('.'+selector, el)); | 245 | // applies = (this._doesSelectorTargetElement('.'+selector, el)); |
233 | } | 246 | // } |
234 | },this); | 247 | // },this); |
235 | 248 | ||
236 | ///// Add rule directly to the rule list | 249 | ///// Add rule directly to the rule list |
237 | this.ruleListContainer.displayedList.component.addRule(newRule, null, applies, function(ruleComponent) { | 250 | this.ruleListContainer.displayedList.component.addRule(newRule, null, applies, function(ruleComponent) { |