From 1c73ff78bb6a251ded84ab34ed7f341844c030f1 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 10 May 2012 17:14:12 -0700 Subject: CSS Panel - Fixed removing rules and checking to see if rules apply on add. --- js/panels/css-panel/rule-list.reel/rule-list.js | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'js/panels/css-panel/rule-list.reel') 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, { }, addRule: { - value: function(rule, atIndex) { + value: function(rule, atIndex, applies, drawCallback) { var insertIndex = atIndex || this.childComponents.length; this.rulesToDraw.push({ rule: rule, index: insertIndex, - instance : null + instance : null, + applies : applies, + callback : drawCallback }); this.needsDraw = true; } }, + removeRule: { + value: function(ruleComponent) { + this.rulesToRemove.push(ruleComponent); + this.needsDraw = true; + } + }, + willDraw : { value: function() { this.rulesToDraw.forEach(function(ruleObj) { @@ -110,6 +119,7 @@ exports.RuleList = Montage.create(Component, { instance = Montage.create(componentBase); instance.element = document.createElement(this.ruleNodeName); instance.rule = ruleObj.rule; + instance.applied = ruleObj.applies; if(this.focusDelegate) { instance.focusDelegate = this.focusDelegate; @@ -156,17 +166,23 @@ exports.RuleList = Montage.create(Component, { ruleObj.instance.needsDraw = true; }, this); - ///// Null out any rules that were just drawn - this.rulesToDraw.length = 0; - } }, didDraw : { value: function() { + this.rulesToDraw.forEach(function(ruleObj) { + if(typeof ruleObj.callback === 'function') { + ruleObj.callback(ruleObj.instance); + } + }); + this.rulesToRemove.forEach(function(ruleObj) { ruleObj.instance = null; }, this); + + ///// Null out any rules that were just drawn + this.rulesToDraw.length = 0; this.rulesToRemove.length = 0; } } -- cgit v1.2.3