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.js106
1 files changed, 106 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..0faff07e
--- /dev/null
+++ b/js/panels/css-panel/rule-list.reel/rule-list.js
@@ -0,0 +1,106 @@
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 focusDelegate : {
12 value: null
13 },
14 ruleNodeName : { value: 'li' },
15
16 _rules: { value: null },
17 rules: {
18 get: function() {
19 return this._rules;
20 },
21 set: function(list) {
22 if(!list) {
23 return null;
24 }
25 //debugger;
26 console.log('list: ', list);
27 this._rules = list;
28
29 ///// remove previsouly added rules
30 if(this.childComponents){
31 this.childComponents.forEach(function(ruleComponent) {
32 this.removeRule(ruleComponent);
33 }, this);
34 }
35
36 this._rules.forEach(function(rule) {
37 this.addRule(rule);
38 }, this);
39
40 this.needsDraw = true;
41
42 }
43 },
44
45 childComponents : {
46 value: [],
47 distinct: true
48 },
49
50 rulesToDraw : {
51 value: [],
52 distinct: true
53 },
54
55 addRule: {
56 value: function(rule) {
57 var componentBase = this.supportedRules[rule.type],
58 instance, el;
59
60 ///// Draw the rule if we have a template for the rule type
61 if(componentBase) {
62 instance = Montage.create(componentBase);
63 instance.rule = rule;
64
65 if(this.focusDelegate) {
66 instance.focusDelegate = this.focusDelegate;
67 }
68
69 this.rulesToDraw.push(instance);
70 this.needsDraw = true;
71 }
72 }
73 },
74
75 update : {
76 value: function() {
77 this.childComponents.forEach(function(component) {
78 component.update();
79 }, this);
80
81 //// TODO: find new styles based on selection
82 }
83 },
84
85 willDraw : {
86 value: function() {
87 this.rulesToDraw.forEach(function(component) {
88 component.element = document.createElement(this.ruleNodeName);
89 }, this);
90
91 }
92 },
93
94 draw : {
95 value: function() {
96 //// Iterate through all rules that need draw and append them
97 this.rulesToDraw.forEach(function(component) {
98 this.element.appendChild(component.element);
99 component.needsDraw = true;
100 }, this);
101
102 ///// Null out any rules that were just drawn
103 this.rulesToDraw.length = 0;
104 }
105 }
106});