aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelinePanel.reel
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-04 10:20:57 -0700
committerValerio Virgillito2012-06-04 10:20:57 -0700
commitc1ec69879028220b0c3f11ad6e24035bf527802c (patch)
tree043bfe4ec9e08f4f598a4845ae5fbcddacc7c8fb /js/panels/Timeline/TimelinePanel.reel
parent3abba04025dbc0daadb08184833a2558c442b8e1 (diff)
parent266460e52831c5b3a3473be420756fd88bb8aced (diff)
downloadninja-c1ec69879028220b0c3f11ad6e24035bf527802c.tar.gz
Merge pull request #264 from mencio/document-bindings-fix
Document bindings fix - Changing the documents architecture to use bindings instead of events
Diffstat (limited to 'js/panels/Timeline/TimelinePanel.reel')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js89
1 files changed, 46 insertions, 43 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index c55e5a24..6e9513f2 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -15,6 +15,41 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
15 }, 15 },
16 16
17 /* === BEGIN: Models === */ 17 /* === BEGIN: Models === */
18 _currentDocument: {
19 value : null
20 },
21
22 currentDocument : {
23 get : function() {
24 return this._currentDocument;
25 },
26 set : function(value) {
27 if (value === this._currentDocument) {
28 return;
29 }
30
31 if(!this._currentDocument && value.currentView === "design") {
32 this.enablePanel(true);
33 }
34
35 this._currentDocument = value;
36
37 if(!value) {
38 this.enablePanel(false);
39 } else if(this._currentDocument.currentView === "design") {
40 this._boolCacheArrays = false;
41 this.clearTimelinePanel();
42 this._boolCacheArrays = true;
43
44 // Rebind the document events for the new document context
45 this._bindDocumentEvents();
46
47 // TODO: Fix the init function so that it can be called here instead of when container changes
48 // this.initTimelineForDocument();
49 }
50 }
51 },
52
18 _arrLayers:{ 53 _arrLayers:{
19 value:[] 54 value:[]
20 }, 55 },
@@ -144,8 +179,16 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
144 return this._currentSelectedContainer; 179 return this._currentSelectedContainer;
145 }, 180 },
146 set: function(newVal) { 181 set: function(newVal) {
147 this._currentSelectedContainer = newVal; 182 if(this._currentSelectedContainer !== newVal) {
148 this.handleDocumentChange(); 183 this._currentSelectedContainer = newVal;
184
185 this._boolCacheArrays = false;
186 this.clearTimelinePanel();
187 this._boolCacheArrays = true;
188
189 // TODO: Fix the function so that we can remove this call here.
190 this.initTimelineForDocument();
191 }
149 } 192 }
150 }, 193 },
151 194
@@ -233,7 +276,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
233 set:function (value) { 276 set:function (value) {
234 if (this._breadCrumbContainer !== value) { 277 if (this._breadCrumbContainer !== value) {
235 this._breadCrumbContainer = value; 278 this._breadCrumbContainer = value;
236 //this.LayerBinding();
237 } 279 }
238 } 280 }
239 }, 281 },
@@ -334,12 +376,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
334 prepareForDraw:{ 376 prepareForDraw:{
335 value:function () { 377 value:function () {
336 this.initTimeline(); 378 this.initTimeline();
337 // Bind the event handler for the document change events 379
338 //this.eventManager.addEventListener("onOpenDocument", this.handleDocumentChange.bind(this), false);
339 this.eventManager.addEventListener("closeDocument", this.handleDocumentChange.bind(this), false);
340 //this.eventManager.addEventListener("switchDocument", this.handleDocumentChange.bind(this), false);
341 //this.eventManager.addEventListener("breadCrumbBinding",this,false);
342
343 // Bind drag and drop event handlers 380 // Bind drag and drop event handlers
344 this.container_layers.addEventListener("dragstart", this.handleLayerDragStart.bind(this), false); 381 this.container_layers.addEventListener("dragstart", this.handleLayerDragStart.bind(this), false);
345 this.container_layers.addEventListener("dragend", this.handleLayerDragEnd.bind(this), false); 382 this.container_layers.addEventListener("dragend", this.handleLayerDragEnd.bind(this), false);
@@ -711,44 +748,10 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
711 748
712 handleDocumentChange:{ 749 handleDocumentChange:{
713 value:function () { 750 value:function () {
714 if (this.application.ninja.currentDocument == null) {
715 // On app initialization, the binding is triggered before
716 // there is a currentDocument. We don't do anything at that time.
717 return;
718 }
719 // this.application.ninja.currentDocument.setLevel = true;
720 this._boolCacheArrays = false;
721 this.clearTimelinePanel();
722 this._boolCacheArrays = true;
723
724 // Rebind the document events for the new document context
725 this._bindDocumentEvents();
726
727 // Reinitialize the timeline...but only if there are open documents.
728 if (this.application.ninja.documentController._documents.length > 0) {
729 this.enablePanel(true);
730 this.initTimelineForDocument();
731
732 } else {
733 this.enablePanel(false);
734 }
735 }
736 },
737
738 LayerBinding:{
739 value:function (node) {
740 var i = 0;
741 751
742 if(this._firstTimeLoaded){
743 this._firstTimeLoaded = false;
744 return;
745 }
746
747 this.handleDocumentChange(node);
748 } 752 }
749 }, 753 },
750 754
751
752 updateTrackContainerWidth:{ 755 updateTrackContainerWidth:{
753 value:function () { 756 value:function () {
754 this.container_tracks.style.width = (this.end_hottext.value * 80) + "px"; 757 this.container_tracks.style.width = (this.end_hottext.value * 80) + "px";