aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/rule-list-container.reel
diff options
context:
space:
mode:
authorEric Guzman2012-05-10 13:20:19 -0700
committerEric Guzman2012-05-10 13:20:19 -0700
commit830b6577ee25a6955bd4e275f216e1cadeff168c (patch)
treeca4abd50c63f17e1dfa612c3be99875b756618e9 /js/panels/css-panel/rule-list-container.reel
parent0cbfa32fa4e62be128b6478dcba0aa9db902f78b (diff)
downloadninja-830b6577ee25a6955bd4e275f216e1cadeff168c.tar.gz
CSS Panel - Rule List refactor
Improved adding, updating, and sorting of rules in rule list.
Diffstat (limited to 'js/panels/css-panel/rule-list-container.reel')
-rw-r--r--js/panels/css-panel/rule-list-container.reel/rule-list-container.js33
1 files changed, 18 insertions, 15 deletions
diff --git a/js/panels/css-panel/rule-list-container.reel/rule-list-container.js b/js/panels/css-panel/rule-list-container.reel/rule-list-container.js
index 5371ec9a..d9aae867 100644
--- a/js/panels/css-panel/rule-list-container.reel/rule-list-container.js
+++ b/js/panels/css-panel/rule-list-container.reel/rule-list-container.js
@@ -11,8 +11,8 @@ exports.RuleListContainer = Montage.create(Component, {
11 _instanceToAdd : { value: null }, 11 _instanceToAdd : { value: null },
12 _appendElement : { value: null }, 12 _appendElement : { value: null },
13 _lastDisplayedList : { value: null }, 13 _lastDisplayedList : { value: null },
14 _displayedList : { value: null },
15 14
15 _displayedList : { value: null },
16 displayedList : { 16 displayedList : {
17 get: function() { 17 get: function() {
18 return this._displayedList; 18 return this._displayedList;
@@ -74,22 +74,21 @@ exports.RuleListContainer = Montage.create(Component, {
74 add : { 74 add : {
75 value: function(selection) { 75 value: function(selection) {
76 var stylesController = this.application.ninja.stylesController, 76 var stylesController = this.application.ninja.stylesController,
77 listInstance = Montage.create(this.ruleListComponent), 77 instance = Montage.create(this.ruleListComponent),
78 container = document.createElement('div'), 78 container = document.createElement('div'),
79 rules, ruleListLog; 79 rules, ruleListLog;
80 80
81 rules = this.getRulesForSelection(selection); 81 rules = this.getRulesForSelection(selection);
82 82
83 this._instanceToAdd = listInstance; 83 this._instanceToAdd = instance;
84 listInstance.rules = rules; 84 instance.rules = rules;
85 85
86 ruleListLog = { 86 ruleListLog = {
87 selection: selection, 87 selection: selection,
88 component : listInstance 88 component : instance
89 }; 89 };
90 90
91 this.ruleLists.push(ruleListLog); 91 this.ruleLists.push(ruleListLog);
92
93 this._appendElement = container; 92 this._appendElement = container;
94 this.needsDraw = true; 93 this.needsDraw = true;
95 94
@@ -120,17 +119,21 @@ exports.RuleListContainer = Montage.create(Component, {
120 119
121 update : { 120 update : {
122 value: function() { 121 value: function() {
123 var stylesController = this.application.ninja.stylesController, 122 this.displayedList.component.rules = this.getRulesForSelection(this.displayedList.selection);
124 rules = this.getRulesForSelection(this.displayedList.selection), 123
125 newRules;
126 124
127 newRules = rules.filter(function(rule) { 125 ///// Update the currently displayed list
128 return rule.type !== 'inline' && this.displayedList.component.rules.indexOf(rule) === -1; 126 //this.displayedList.component.update();
129 }, this);
130 127
131 newRules.forEach(function(rule) { 128 ///// Find the new rules which need to be added to the rule-list
132 this.displayedList.component.addRule(rule); 129// newRules = rules.filter(function(rule) {
133 },this); 130// return rule.type !== 'inline' && this.displayedList.component.rules.indexOf(rule) === -1;
131// }, this);
132//
133// ///// Add the new rules
134// newRules.forEach(function(rule) {
135// this.displayedList.component.addRule(rule);
136// },this);
134 } 137 }
135 }, 138 },
136 139