aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
diff options
context:
space:
mode:
authorJonathan Duran2012-03-08 19:55:13 -0800
committerJonathan Duran2012-03-08 19:55:13 -0800
commitdae6290c5f779dbff1d3b508615898b1ec26bb18 (patch)
tree40825a2f6ed82b015aaf76b1b79238e269a89ea6 /js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
parent1c61c69265b9c0230b834c0d4d7c78a11f9d5b19 (diff)
parentb96c5803a90e028af20f8ebce441d7a57608b99e (diff)
downloadninja-dae6290c5f779dbff1d3b508615898b1ec26bb18.tar.gz
Merge branch 'refs/heads/SerialKiller' into TimelineUber
Diffstat (limited to 'js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js565
1 files changed, 300 insertions, 265 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index 087bf3cd..28363398 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -19,24 +19,43 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
19 19
20 /* === BEGIN: Models === */ 20 /* === BEGIN: Models === */
21 _arrLayers:{ 21 _arrLayers:{
22 serializable: true,
22 value:[] 23 value:[]
23 }, 24 },
24 25
25 arrLayers:{ 26 arrLayers:{
27 serializable: true,
26 get:function () { 28 get:function () {
27 return this._arrLayers; 29 return this._arrLayers;
28 }, 30 },
29 set:function (newVal) { 31 set:function (newVal) {
30 this._arrLayers = newVal; 32 this._arrLayers = newVal;
33 this.needsDraw = true;
31 this._cacheArrays(); 34 this._cacheArrays();
32 } 35 }
33 }, 36 },
34 37
38 _temparrLayers:{
39 value:[]
40 },
41
42 temparrLayers:{
43 get:function () {
44 return this._temparrLayers;
45 },
46 set:function (newVal) {
47 this._temparrLayers = newVal;
48 }
49 },
50
51
35 _layerRepetition:{ 52 _layerRepetition:{
53 serializable: true,
36 value:null 54 value:null
37 }, 55 },
38 56
39 layerRepetition:{ 57 layerRepetition:{
58 serializable: true,
40 get:function () { 59 get:function () {
41 return this._layerRepetition; 60 return this._layerRepetition;
42 }, 61 },
@@ -46,17 +65,17 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
46 }, 65 },
47 66
48 _cacheArrays : { 67 _cacheArrays : {
49 value: function() { 68 value: function() {
50 if (this._boolCacheArrays) { 69 if (this._boolCacheArrays) {
51 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; 70 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers;
52 71
53 } 72 }
54 } 73 }
55 }, 74 },
56 75
57 // Set to false to skip array caching array sets in current document 76 // Set to false to skip array caching array sets in current document
58 _boolCacheArrays : { 77 _boolCacheArrays : {
59 value: true 78 value: true
60 }, 79 },
61 80
62 _currentLayerNumber:{ 81 _currentLayerNumber:{
@@ -217,9 +236,10 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
217 prepareForDraw:{ 236 prepareForDraw:{
218 value:function () { 237 value:function () {
219 this.initTimeline(); 238 this.initTimeline();
220 this.eventManager.addEventListener("onOpenDocument", this, false); 239 // Bind the event handler for the document change events
221 this.eventManager.addEventListener("closeDocument", this, false); 240 this.eventManager.addEventListener("onOpenDocument", this.handleDocumentChange.bind(this), false);
222 this.eventManager.addEventListener("switchDocument", this, false); 241 this.eventManager.addEventListener("closeDocument", this.handleDocumentChange.bind(this), false);
242 this.eventManager.addEventListener("switchDocument", this.handleDocumentChange.bind(this), false);
223 } 243 }
224 }, 244 },
225 245
@@ -233,39 +253,66 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
233 }, 253 },
234 /* === END: Draw cycle === */ 254 /* === END: Draw cycle === */
235 /* === BEGIN: Controllers === */ 255 /* === BEGIN: Controllers === */
236 // Bind all document-specific events (pass in true to unbind) 256 // Create an empty layer template object with minimal defaults and return it for use
237 _bindDocumentEvents : { 257 createLayerTemplate : {
238 value: function(boolUnbind) { 258 value : function() {
239 var arrEvents = ["deleteLayerClick", 259 var returnObj = {};
240 "newLayer", 260 returnObj.layerData = {};
241 "deleteLayer", 261 returnObj.layerData.layerName = null;
242 "elementAdded", 262 returnObj.layerData.layerID = null;
243 "elementDeleted", 263 returnObj.layerData.isMainCollapsed = true;
244 "selectionChange"], 264 returnObj.layerData.isPositionCollapsed = true;
245 i, 265 returnObj.layerData.isTransformCollapsed = true;
246 arrEventsLength = arrEvents.length; 266 returnObj.layerData.isStyleCollapsed = true;
247 267 returnObj.layerData.arrLayerStyles = [];
248 if (boolUnbind) { 268 returnObj.layerData.elementsList = [];
249 for (i = 0; i < arrEventsLength; i++) { 269 returnObj.layerData.deleted = false;
250 this.eventManager.removeEventListener(arrEvents[i], this, false); 270 returnObj.layerData.isSelected = false;
251 } 271 returnObj.layerData.layerPosition = null;
252 } else { 272 returnObj.layerData.created=false;
253 for (i = 0; i < arrEventsLength; i++) { 273 returnObj.layerData.isTrackAnimated = false;
254 this.eventManager.addEventListener(arrEvents[i], this, false); 274 returnObj.layerData.currentKeyframeRule = null;
255 } 275 returnObj.layerData.trackPosition = 0;
276 returnObj.layerData.arrStyleTracks = [];
277 returnObj.layerData.tweens = [];
278 returnObj.parentElementUUID = null;
279 returnObj.parentElement = null;
280 return returnObj;
281 }
282 },
283 // Bind all document-specific events (pass in true to unbind)
284 _bindDocumentEvents : {
285 value: function(boolUnbind) {
286 var arrEvents = ["deleteLayerClick",
287 "newLayer",
288 "deleteLayer",
289 "elementAdded",
290 "elementDeleted",
291 "selectionChange"],
292 i,
293 arrEventsLength = arrEvents.length;
294
295 if (boolUnbind) {
296 for (i = 0; i < arrEventsLength; i++) {
297 this.eventManager.removeEventListener(arrEvents[i], this, false);
298 }
299 } else {
300 for (i = 0; i < arrEventsLength; i++) {
301 this.eventManager.addEventListener(arrEvents[i], this, false);
302 }
256 Object.defineBinding(this, "breadCrumbContainer", { 303 Object.defineBinding(this, "breadCrumbContainer", {
257 boundObject: this.application.ninja, 304 boundObject: this.application.ninja,
258 boundObjectPropertyPath:"currentSelectedContainer", 305 boundObjectPropertyPath:"currentSelectedContainer",
259 oneway: true 306 oneway: true
260 }); 307 });
261 } 308 }
262 } 309 }
263 }, 310 },
264 311
265 initTimeline : { 312 initTimeline : {
266 value: function() { 313 value: function() {
267 // Set up basic Timeline functions: event listeners, etc. Things that only need to be run once. 314 // Set up basic Timeline functions: event listeners, etc. Things that only need to be run once.
268 this.layout_tracks = this.element.querySelector(".layout-tracks"); 315 this.layout_tracks = this.element.querySelector(".layout-tracks");
269 this.layout_markers = this.element.querySelector(".layout_markers"); 316 this.layout_markers = this.element.querySelector(".layout_markers");
270 317
271 this.newlayer_button.identifier = "addLayer"; 318 this.newlayer_button.identifier = "addLayer";
@@ -276,123 +323,129 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
276 this.layout_tracks.addEventListener("scroll", this.updateLayerScroll.bind(this), false); 323 this.layout_tracks.addEventListener("scroll", this.updateLayerScroll.bind(this), false);
277 this.user_layers.addEventListener("scroll", this.updateLayerScroll.bind(this), false); 324 this.user_layers.addEventListener("scroll", this.updateLayerScroll.bind(this), false);
278 this.end_hottext.addEventListener("changing", this.updateTrackContainerWidth.bind(this), false); 325 this.end_hottext.addEventListener("changing", this.updateTrackContainerWidth.bind(this), false);
279 326 this.playhead.addEventListener("mousedown", this.startPlayheadTracking.bind(this), false);
280 } 327 this.playhead.addEventListener("mouseup", this.stopPlayheadTracking.bind(this), false);
281 }, 328 this.time_markers.addEventListener("click", this.updatePlayhead.bind(this), false);
282 329 }
330 },
331
283 initTimelineForDocument:{ 332 initTimelineForDocument