aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/rule-list.reel/rule-list.js
diff options
context:
space:
mode:
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.js99
1 files changed, 99 insertions, 0 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
new file mode 100644
index 00000000..ebd7428b
--- /dev/null
+++ b/js/panels/css-panel/rule-list.reel/rule-list.js
@@ -0,0 +1,99 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.RuleList = Montage.create(Component, {
11
12 ruleNodeName : { value: 'li' },
13
14 _rules: { value: null },
15 rules: {
16 get: function() {
17 return this._rules;
18 },
19 set: function(list) {
20 if(!list) {
21 return null;
22 }
23 //debugger;
24 console.log('list: ', list);
25 this._rules = list;
26
27 ///// remove previsouly added rules
28 if(this.childComponents){
29 this.childComponents.forEach(function(ruleComponent) {
30 this.removeRule(ruleComponent);
31 }, this);
32 }
33
34 this._rules.forEach(function(rule) {
35 this.addRule(rule);
36 }, this);
37
38 this.needsDraw = true;
39
40 }
41 },
42
43 childComponents : {
44 value: [],
45 distinct: true
46 },
47
48 rulesToDraw : {
49 value: [],
50 distinct: true
51 },
52
53 addRule: {
54 value: function(rule) {
55 var componentBase = this.supportedRules[rule.type],
56 instance, el;
57
58 ///// Draw the rule if we have a template for the rule type
59 if(componentBase) {
60 instance = Montage.create(componentBase);
61 instance.rule = rule;
62 this.rulesToDraw.push(instance);
63 this.needsDraw = true;
64 }
65 }
66 },
67
68 update : {
69 value: function() {
70 this.childComponents.forEach(function(component) {
71 component.update();
72 }, this);
73
74 //// TODO: find new styles based on selection
75 }
76 },
77
78 willDraw : {
79 value: function() {
80 this.rulesToDraw.forEach(function(component) {
81 component.element = document.createElement(this.ruleNodeName);
82 }, this);
83
84 }
85 },
86
87 draw : {
88 value: function() {
89 //// Iterate through all rules that need draw and append them
90 this.rulesToDraw.forEach(function(component) {
91 this.element.appendChild(component.element);
92 component.needsDraw = true;
93 }, this);
94
95 ///// Null out any rules that were just drawn
96 this.rulesToDraw.length = 0;
97 }
98 }
99});