aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/rule-list.reel/rule-list.js
diff options
context:
space:
mode:
authorEric Guzman2012-05-10 17:14:12 -0700
committerEric Guzman2012-05-10 17:14:12 -0700
commit1c73ff78bb6a251ded84ab34ed7f341844c030f1 (patch)
tree04dd3ddaf4234da6c035ff215f7fc273bd54ab9d /js/panels/css-panel/rule-list.reel/rule-list.js
parent7358c12a45ac2923e7553b17a1cc7c15af70e4c8 (diff)
downloadninja-1c73ff78bb6a251ded84ab34ed7f341844c030f1.tar.gz
CSS Panel - Fixed removing rules and checking to see if rules apply on add.
Diffstat (limited to 'js/panels/css-panel/rule-list.reel/rule-list.js')
-rw-r--r--js/panels/css-panel/rule-list.reel/rule-list.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/js/panels/css-panel/rule-list.reel/rule-list.js b/js/panels/css-panel/rule-list.reel/rule-list.js
index 5f6afee5..bca298df 100644
--- a/js/panels/css-panel/rule-list.reel/rule-list.js
+++ b/js/panels/css-panel/rule-list.reel/rule-list.js
@@ -83,19 +83,28 @@ exports.RuleList = Montage.create(Component, {
83 }, 83 },
84 84
85 addRule: { 85 addRule: {
86 value: function(rule, atIndex) { 86 value: function(rule, atIndex, applies, drawCallback) {
87 var insertIndex = atIndex || this.childComponents.length; 87 var insertIndex = atIndex || this.childComponents.length;
88 88
89 this.rulesToDraw.push({ 89 this.rulesToDraw.push({
90 rule: rule, 90 rule: rule,
91 index: insertIndex, 91 index: insertIndex,
92 instance : null 92 instance : null,
93 applies : applies,
94 callback : drawCallback
93 }); 95 });
94 96
95 this.needsDraw = true; 97 this.needsDraw = true;
96 } 98 }
97 }, 99 },
98 100
101 removeRule: {
102 value: function(ruleComponent) {
103 this.rulesToRemove.push(ruleComponent);
104 this.needsDraw = true;
105 }
106 },
107
99 willDraw : { 108 willDraw : {
100 value: function() { 109 value: function() {
101 this.rulesToDraw.forEach(function(ruleObj) { 110 this.rulesToDraw.forEach(function(ruleObj) {
@@ -110,6 +119,7 @@ exports.RuleList = Montage.create(Component, {
110 instance = Montage.create(componentBase); 119 instance = Montage.create(componentBase);
111 instance.element = document.createElement(this.ruleNodeName); 120 instance.element = document.createElement(this.ruleNodeName);
112 instance.rule = ruleObj.rule; 121 instance.rule = ruleObj.rule;
122 instance.applied = ruleObj.applies;
113 123
114 if(this.focusDelegate) { 124 if(this.focusDelegate) {
115 instance.focusDelegate = this.focusDelegate; 125 instance.focusDelegate = this.focusDelegate;
@@ -156,17 +166,23 @@ exports.RuleList = Montage.create(Component, {
156 ruleObj.instance.needsDraw = true; 166 ruleObj.instance.needsDraw = true;
157 }, this); 167 }, this);
158 168
159 ///// Null out any rules that were just drawn
160 this.rulesToDraw.length = 0;
161
162 } 169 }
163 }, 170 },
164 171
165 didDraw : { 172 didDraw : {
166 value: function() { 173 value: function() {
174 this.rulesToDraw.forEach(function(ruleObj) {
175 if(typeof ruleObj.callback === 'function') {
176 ruleObj.callback(ruleObj.instance);
177 }
178 });
179
167 this.rulesToRemove.forEach(function(ruleObj) { 180 this.rulesToRemove.forEach(function(ruleObj) {
168 ruleObj.instance = null; 181 ruleObj.instance = null;
169 }, this); 182 }, this);
183
184 ///// Null out any rules that were just drawn
185 this.rulesToDraw.length = 0;
170 this.rulesToRemove.length = 0; 186 this.rulesToRemove.length = 0;
171 } 187 }
172 } 188 }