aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/style-sheet.reel/style-sheet.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/css-panel/style-sheet.reel/style-sheet.js')
-rw-r--r--js/panels/css-panel/style-sheet.reel/style-sheet.js221
1 files changed, 221 insertions, 0 deletions
diff --git a/js/panels/css-panel/style-sheet.reel/style-sheet.js b/js/panels/css-panel/style-sheet.reel/style-sheet.js
new file mode 100644
index 00000000..9ad48a62
--- /dev/null
+++ b/js/panels/css-panel/style-sheet.reel/style-sheet.js
@@ -0,0 +1,221 @@
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.StyleSheet = Montage.create(Component, {
11 _translateDistance: {
12 value: null
13 },
14
15 willDraw : {
16 value: function() {
17 if(this.editing) {
18 document.body.addEventListener('mousedown', this, false);
19 this._translateDistance = this._element.offsetWidth - this.editButton._element.offsetWidth;
20
21 } else {
22 document.body.removeEventListener('mousedown', this, false);
23 }
24 }
25 },
26 draw : {
27 value: function() {
28 var transStr = '-webkit-transform';
29
30 this.mediaInput.value = this._source.media.mediaText;
31
32 if(this.editing) {
33 this.editView.classList.add('expanded');
34 this.editView.style.setProperty(transStr, 'translate3d(-'+ this._translateDistance + 'px,0,0)');
35 } else {
36 this.editView.classList.remove('expanded');
37 this.editView.style.removeProperty(transStr);
38 }
39
40 if(this._readOnly) {
41 this._element.classList.add('ss-locked');
42 this.importButton.element.classList.remove('ss-invisible');
43 } else {
44 this._element.classList.remove('ss-locked');
45 this.importButton.element.classList.add('ss-invisible');
46 }
47
48 }
49 },
50
51 /* ------ Events------ */
52
53 handleMousedown : {
54 value: function(e) {
55 var nonBlurringElements = [
56 this.editView,
57 this.deleteButton.element,
58 this.disableButton.element,
59 this.importButton.element];
60
61 console.log("handle mousedown");
62
63 if(nonBlurringElements.indexOf(e.target) === -1) {
64 this.editing = false;
65 }
66 }
67 },
68
69 handleEditButtonAction: {
70 value: function(e) {
71 this.editing = true;
72 }
73 },
74
75 handleImportButtonAction: {
76 value: function(e) {
77 e.stopPropagation();
78 }
79 },
80
81 handleDisableButtonAction: {
82 value: function(e) {
83 e.stopPropagation();
84 this.disabled = !this.disabled;
85 }
86 },
87
88 handleDeleteButtonAction : {
89 value: function(e) {
90 e.stopPropagation();
91 debugger;
92 }
93 },
94
95 /* ------ State properties ------ */
96
97 _editing : {
98 value: null
99 },
100 editing : {
101 get: function() {
102 return this._editing;
103 },
104 set: function(enterEditingMode) {
105 this._editing = enterEditingMode;
106 this.needsDraw = true;
107 }
108 },
109
110 _name: {
111 value: "Style Tag",
112 distinct: true
113 },
114 name : {
115 get: function() {
116 return this._name;
117 },
118 set: function(text) {
119 this._name = text;
120 }
121 },
122 _readOnly : { value: null },
123 readOnly : {
124 get: function() {
125 return this._readOnly;
126 },
127 set: function(isReadOnly) {
128 this._readOnly = isReadOnly;
129 this.needsDraw = true;
130 }
131 },
132
133 _disabled : {
134 value: null
135 },
136 disabled: {
137 get: function() {
138 return this._disabled;
139 },
140 set: function(disable) {
141 var label = (disable) ? "Enable" : "Disable";
142 this._source.ownerNode.disabled = disable;
143 this.disableButton.label = label;
144
145 this._disabled = disable;
146 }
147 },
148
149 external : {
150 value: null
151 },
152
153 _source : {
154 value: null
155 },
156 source : {
157 get: function() {
158 return this._source;
159 },
160 set: function(sheet) {
161 console.log('sheet being set: ', this);
162
163 this._extractData(sheet.ownerNode);
164 this._source = sheet;
165 }
166 },
167
168 _extractData : {
169 value: function(sheetNode) {
170 var data = sheetNode.dataset, key;
171
172 for(key in data) {
173 this[key] = data[key];
174 }
175 }
176 },
177
178 /* ------ Data Attribute Properties ------ */
179
180 _ninjaExternalUrl: { value: null },
181 ninjaExternalUrl : {
182 get: function() { return this._ninjaExternalUrl; },
183 set: function(url) {
184 this.external = true;
185 this._ninjaExternalUrl = url;
186 }
187 },
188
189 _ninjaFileName: { value: null },
190 ninjaFileName : {
191 get: function() { return this._ninjaFileName; },
192 set: function(fileName) {
193 this.name = fileName;
194 this._ninjaFileName = fileName;
195 }
196 },
197
198 _ninjaFileUrl: { value: null },
199 ninjaFileUrl : {
200 get: function() { return this._ninjaFileUrl; },
201 set: function(fileUrl) {
202 this._ninjaFileUrl = fileUrl;
203 }
204 },
205
206 _ninjaFileReadOnly: { value: null },
207 ninjaFileReadOnly : {
208 get: function() { return this._ninjaFileReadOnly; },
209 set: function(isReadOnly) {
210 this._ninjaFileReadOnly = this.readOnly = isReadOnly === "true";
211 }
212 },
213
214 _ninjaUri: { value: null },
215 ninjaUri : {
216 get: function() { return this._ninjaUri; },
217 set: function(uri) {
218 this._ninjaUri = uri;
219 }
220 }
221}); \ No newline at end of file