aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js
diff options
context:
space:
mode:
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.js121
1 files changed, 121 insertions, 0 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
new file mode 100644
index 00000000..ac22878e
--- /dev/null
+++ b/js/panels/css-panel/rule-components/css-style-rule.reel/css-style-rule.js
@@ -0,0 +1,121 @@
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.CssStyleRule = Montage.create(Component, {
11 unappliedClass : {
12 value: 'unapplied-css-rule'
13 },
14 cssText: {
15 value: null
16 },
17 hasTemplate: {
18 value: true
19 },
20 focusDelegate : {
21 value: null
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 },
38
39 _rule : {
40 value : null
41 },
42 rule : {
43 get: function() {
44 return this._rule;
45 },
46 set: function(rule) {
47 this.cssText = rule.cssText;
48
49 if(rule.type === 'inline') {
50 this.sheetName = 'Inline Style';
51 } else {
52 this.sheetName = rule.href || 'Style Tag';
53 }
54
55 this.selector = rule.selectorText;
56 this.declaration = rule.style;
57
58 console.log('Rule with selector "' +rule.selectorText+ '" is set on componenet.');
59
60 this._rule = rule;
61 }
62 },
63 declarationComponent: {
64 value: null
65 },
66 _declaration: {
67 value: null
68 },
69 declaration: {
70 get: function() {
71 return this._declaration;
72 },
73 set: function(dec) {
74 this._declaration = dec;
75 }
76 },
77 condition: {
78 value: false
79 },
80
81 handleChange : {
82 value: function(e) {
83 if(this.focusDelegate) {
84 this.focusDelegate.handleSelectorChange(this.rule, this.selectorField.value, this);
85 }
86 }
87 },
88
89 templateDidLoad : {
90 value: function() {
91 //console.log("css style rule : template did load");
92 }
93 },
94 prepareForDraw : {
95 value: function() {
96 this.selectorField.addEventListener('change', this, false);
97
98 //console.log("css style rule : prepare for draw");
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";
108 }
109 }
110 },
111 draw : {
112 value: function() {
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 }
119 }
120 }
121});