diff options
Diffstat (limited to 'js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js')
-rw-r--r-- | js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js b/js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js index d85b5797..ac22878e 100644 --- a/js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js +++ b/js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js | |||
@@ -8,6 +8,9 @@ var Montage = require("montage/core/core").Montage, | |||
8 | Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | exports.CssStyleRule = Montage.create(Component, { | 10 | exports.CssStyleRule = Montage.create(Component, { |
11 | unappliedClass : { | ||
12 | value: 'unapplied-css-rule' | ||
13 | }, | ||
11 | cssText: { | 14 | cssText: { |
12 | value: null | 15 | value: null |
13 | }, | 16 | }, |
@@ -17,6 +20,21 @@ exports.CssStyleRule = Montage.create(Component, { | |||
17 | focusDelegate : { | 20 | focusDelegate : { |
18 | value: null | 21 | value: null |
19 | }, | 22 | }, |
23 | _applied : { | ||
24 | value: true, | ||
25 | distinct: true | ||
26 | }, | ||
27 | applied : { | ||
28 | get: function() { | ||
29 | return this._applied; | ||
30 | }, | ||
31 | set: function(value) { | ||
32 | if(this._applied === value) { return false; } | ||
33 | |||
34 | this._applied = value; | ||
35 | this.needsDraw = true; | ||
36 | } | ||
37 | }, | ||
20 | 38 | ||
21 | _rule : { | 39 | _rule : { |
22 | value : null | 40 | value : null |
@@ -44,13 +62,7 @@ exports.CssStyleRule = Montage.create(Component, { | |||
44 | }, | 62 | }, |
45 | declarationComponent: { | 63 | declarationComponent: { |
46 | value: null | 64 | value: null |
47 | } , | 65 | }, |
48 | // declarationNodeName: { | ||
49 | // value: "dl" | ||
50 | // }, | ||
51 | // declarationElement: { | ||
52 | // value: null | ||
53 | // }, | ||
54 | _declaration: { | 66 | _declaration: { |
55 | value: null | 67 | value: null |
56 | }, | 68 | }, |
@@ -65,35 +77,45 @@ exports.CssStyleRule = Montage.create(Component, { | |||
65 | condition: { | 77 | condition: { |
66 | value: false | 78 | value: false |
67 | }, | 79 | }, |
68 | templateDidLoad : { | ||
69 | value: function() { | ||
70 | console.log("css style rule : template did load"); | ||
71 | if(this._declaration) { | ||
72 | this.declarationComponent.declaration = this._declaration; | ||
73 | } | ||
74 | 80 | ||
81 | handleChange : { | ||
82 | value: function(e) { | ||
75 | if(this.focusDelegate) { | 83 | if(this.focusDelegate) { |
76 | this.declarationComponent.focusDelegate = this.focusDelegate; | 84 | this.focusDelegate.handleSelectorChange(this.rule, this.selectorField.value, this); |
77 | } | 85 | } |
78 | } | 86 | } |
79 | }, | 87 | }, |
88 | |||
89 | templateDidLoad : { | ||
90 | value: function() { | ||
91 | //console.log("css style rule : template did load"); | ||
92 | } | ||
93 | }, | ||
80 | prepareForDraw : { | 94 | prepareForDraw : { |
81 | value: function() { | 95 | value: function() { |
82 | console.log("css style rule : prepare for draw"); | 96 | this.selectorField.addEventListener('change', this, false); |
83 | |||
84 | if(!this.declarationElement) { | ||
85 | ///// Create element to contain declaration | ||
86 | this.declarationElement = document.createElement(this.declarationNodeName); | ||
87 | } | ||
88 | 97 | ||
89 | if(!this._declaration && this._rule) { | 98 | //console.log("css style rule : prepare for draw"); |
90 | 99 | ||
100 | } | ||
101 | }, | ||
102 | willDraw : { | ||
103 | value: function() { | ||
104 | if(this.applied) { | ||
105 | this.element.removeAttribute('title'); | ||
106 | } else { | ||
107 | this.element.title = "Rule does not apply to selection"; | ||
91 | } | 108 | } |
92 | } | 109 | } |
93 | }, | 110 | }, |
94 | draw : { | 111 | draw : { |
95 | value: function() { | 112 | value: function() { |
96 | console.log("css style rule : draw"); | 113 | //console.log("css style rule : draw"); |
114 | if(this.applied) { | ||
115 | this.element.classList.remove(this.unappliedClass); | ||
116 | } else { | ||
117 | this.element.classList.add(this.unappliedClass); | ||
118 | } | ||
97 | } | 119 | } |
98 | } | 120 | } |
99 | }); | 121 | }); |