aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/Style.reel/Style.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/Style.reel/Style.js')
-rw-r--r--js/panels/Timeline/Style.reel/Style.js603
1 files changed, 603 insertions, 0 deletions
diff --git a/js/panels/Timeline/Style.reel/Style.js b/js/panels/Timeline/Style.reel/Style.js
new file mode 100644
index 00000000..13a5db3e
--- /dev/null
+++ b/js/panels/Timeline/Style.reel/Style.js
@@ -0,0 +1,603 @@
1/*
2 * Style component: Edits and manages a single style rule for a Layer in the Timeline.
3 * Public Properties:
4 * editorProperty: The CSS property for the style.
5 * editorValue: The value for the editorProperty.
6 * whichView: Which view to show, the hintable view (where a new property can be typed in)
7 * or the propval view (where the property's value can be set with the tweener).
8 * Valid values are "hintable" and "propval", defaults to "hintable".
9 *
10 */
11
12var Montage = require("montage/core/core").Montage;
13var Component = require("montage/ui/component").Component;
14
15var LayerStyle = exports.LayerStyle = Montage.create(Component, {
16
17 hasTemplate:{
18 value: true
19 },
20
21 /* === BEGIN: Models === */
22
23 // Property for this editor
24 _editorProperty: {
25 serializable: true,
26 value: ""
27 },
28 editorProperty: {
29 serializable: true,
30 get: function() {
31 return this._editorProperty;
32 },
33 set: function(newVal) {
34 this._editorProperty = newVal;
35 this.needsDraw = true;
36 }
37 },
38
39 // Value for the property for this editor.
40 _editorValue: {
41 serializable: true,
42 value: ""
43 },
44 editorValue: {
45 serializable: true,
46 get: function() {
47 return this._editorValue;
48 },
49 set: function(newVal) {
50 this._editorValue = newVal;
51 this.needsDraw = true;
52 }
53 },
54
55 // The tweener used to change the value for this property.
56 _ruleTweener: {
57 serializable: true,
58 value: false
59 },
60 ruleTweener: {
61 serializable: true,
62 get: function() {
63 return this._ruleTweener;
64 },
65 set: function(newVal) {
66 this._ruleTweener = newVal;
67 this.needsDraw = true;
68 }
69 },
70
71 // The hintable we use to change the Property
72 _myHintable: {
73 value: ""
74 },
75 myHintable: {
76 get: function() {
77 return this._myHintable;
78 },
79 set: function(newVal) {
80 this._myHintable = newVal;
81 }
82 },
83 _myHintableValue : {
84 value: null
85 },
86 myHintableValue: {
87 get: function() {
88 return this._myHintableValue;
89 },
90 set: function(newVal) {
91 this._myHintableValue = newVal;
92 }
93 },
94
95 // swapViews: Is a view swap happening?
96 _swapViews : {
97 value: true
98 },
99
100 // whichView: which view should we show: hintable or propval
101 _whichView : {
102 serializable: true,
103 value: "hintable"
104 },
105 whichView: {
106 serializable: true,
107 get: function() {
108 return this._whichView;
109 },
110 set: function(newVal) {
111 if (this._whichView !== newVal) {
112 if ((newVal !== "hintable") && (newVal !== "propval")) {
113 this.log("Error: Unknown view -"+newVal+"- requested for style.js.");
114 return;
115 }
116 this._whichView = newVal;
117 this._swapViews = true;
118 this.needsDraw = true;
119 }
120 }
121 },
122
123 // styleID: the id for this style;
124 // Used to publish events
125 _styleID : {
126 serializable: true,
127 value: null
128 },
129 styleID: {
130 serializable: true,
131 get: function() {
132 return this._styleID;
133 },
134 set: function(newVal) {
135 this._styleID = newVal;
136 this.needsDraw = true;
137 }
138 },
139
140 /* === END: Models === */
141
142 /* === BEGIN : Draw cycle === */
143 prepareForDraw: {
144 value: function() {
145 this.init();
146 }
147 },
148 draw: {
149 value: function() {
150
151 if (this._swapViews === true) {
152 // Show the right thing
153 this._showView();
154 }
155 }
156 },
157 didDraw: {
158 value: function() {
159 if (this._swapViews === true) {
160 // View swap has been completed.
161 this._swapViews === false;
162 }
163 }
164 },
165 /* === END: Draw cycle === */
166
167 /* === BEGIN: controllers === */
168
169 // handleStylePropertyDblClick: What happens when the user double-clicks on the style property
170 handleStylePropertyDblclick: {
171 value: function(event) {
172 this.whichView = "hintable";
173 }
174 },
175
176 // handleHintableStop: What happens when the hintable issues its stop event
177 handleHintableStop: {
178 value: function(event) {
179 // this should be handled via binding, but somehow is not. Setting manually for now.
180 this.editorProperty = this.myHintable.value;
181
182 // Change views.
183 this.whichView = "propval";
184 }
185 },
186
187 // Init: Initialize the component with some useful selectors and other defaults.
188 init : {
189 value: function() {
190
191 var arrHints = [],
192 i = 0;
193
194 // Get the array of hints from _myTweenables:
195 for (i = 0; i < this._myTweenables.length; i++) {
196 arrHints.push(this._myTweenables[i].property)
197 }
198
199 // Set useful information for the hintable
200 this.myHintable.editingClass = "editable2";
201 this.myHintable.hints = arrHints;
202
203 // Bind a handler to the Hintable's change event
204 this.myHintable.identifier = "hintable";
205 this.myHintable.addEventListener("stop", this, false);
206
207 // Add the click handler to the styleProperty: When the user double-clicks on it, we want to start the editor.
208 this.styleProperty.identifier = "styleProperty";
209 this.styleProperty.addEventListener("dblclick", this, false);
210
211 // Get some selectors that we'll be using
212 this.editorHottextContainer = this.element.querySelector(".editor-hottext");
213 this.editorInputContainer = this.element.querySelector(".editor-input");
214 this.editorColorContainer = this.element.querySelector(".editor-color");
215 this.containerHintable = this.element.querySelector(".row-hintable");
216 this.containerPropvals = this.element.querySelector(".container-propvals");
217 this.valueEditorInput = this.element.querySelector(".editor-input input");
218
219 }
220 },
221
222 // showView: Show the appropriate view
223 _showView : {
224 value: function() {
225 if (this.whichView === "hintable") {
226 this.containerHintable.classList.remove("hidden");
227 this.containerPropvals.classList.add("hidden");
228 this.myHintable.start();
229 } else {
230 this.containerHintable.classList.add("hidden");
231 this.containerPropvals.classList.remove("hidden");
232 this._showTweener();
233 }