aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/rule-list.reel/rule-list.js
diff options
context:
space:
mode:
authorEric Guzman2012-05-01 11:15:14 -0700
committerEric Guzman2012-05-01 11:15:14 -0700
commit9a94c6fb5f82d18139b48341788a0ffca23ae0af (patch)
treec76f84915d7135c81e38f1abc003b6a3b34ff2c3 /js/panels/css-panel/rule-list.reel/rule-list.js
parent23d8efd4ed9e8fd43f516595009679fb44c8096d (diff)
downloadninja-9a94c6fb5f82d18139b48341788a0ffca23ae0af.tar.gz
CSS Panel - Added removing of rules/styles
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.js22
1 files changed, 20 insertions, 2 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 4ed3ec11..8d179248 100644
--- a/js/panels/css-panel/rule-list.reel/rule-list.js
+++ b/js/panels/css-panel/rule-list.reel/rule-list.js
@@ -25,7 +25,7 @@ exports.RuleList = Montage.create(Component, {
25 console.log('list: ', list); 25 console.log('list: ', list);
26 this._rules = list; 26 this._rules = list;
27 27
28 ///// remove previsouly added rules 28 ///// remove previously added rules
29 if(this.childComponents){ 29 if(this.childComponents){
30 this.childComponents.forEach(function(ruleComponent) { 30 this.childComponents.forEach(function(ruleComponent) {
31 this.removeRule(ruleComponent); 31 this.removeRule(ruleComponent);
@@ -50,7 +50,10 @@ exports.RuleList = Montage.create(Component, {
50 value: [], 50 value: [],
51 distinct: true 51 distinct: true
52 }, 52 },
53 53 rulesToRemove : {
54 value: [],
55 distinct: true
56 },
54 addRule: { 57 addRule: {
55 value: function(rule) { 58 value: function(rule) {
56 var componentBase = this.supportedRules[rule.type], 59 var componentBase = this.supportedRules[rule.type],
@@ -73,6 +76,14 @@ exports.RuleList = Montage.create(Component, {
73 } 76 }
74 }, 77 },
75 78
79 removeRule : {
80 value: function(rule) {
81 this.childComponents.splice(this.childComponents.indexOf(rule), 1);
82 this.rulesToRemove.push(rule);
83 this.needsDraw = true;
84 }
85 },
86
76 update : { 87 update : {
77 value: function() { 88 value: function() {
78 this.childComponents.forEach(function(component) { 89 this.childComponents.forEach(function(component) {
@@ -106,11 +117,18 @@ exports.RuleList = Montage.create(Component, {
106 this.rulesToDraw.forEach(function(component) { 117 this.rulesToDraw.forEach(function(component) {
107 this.element.appendChild(component.element); 118 this.element.appendChild(component.element);
108 this._needsScrollToBottom = this.needsDraw = true; 119 this._needsScrollToBottom = this.needsDraw = true;
120 this.childComponents.push(component);
109 component.needsDraw = true; 121 component.needsDraw = true;
110 }, this); 122 }, this);
111 123
124 //// Iterate through all rules that need draw and append them
125 this.rulesToRemove.forEach(function(component) {
126 this.element.removeChild(component.element);
127 }, this);
128
112 ///// Null out any rules that were just drawn 129 ///// Null out any rules that were just drawn
113 this.rulesToDraw.length = 0; 130 this.rulesToDraw.length = 0;
131 this.rulesToRemove.length = 0;
114 } 132 }
115 } 133 }
116}); 134});