aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js128
1 files changed, 92 insertions, 36 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index 1c023fdb..470062ba 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -117,28 +117,42 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
117 if (value === this._currentDocument) { 117 if (value === this._currentDocument) {
118 return; 118 return;
119 } 119 }
120
121 if(!this._currentDocument && value.currentView === "design") {
122 this.enablePanel(true);
123 }
124
125 this._currentDocument = value; 120 this._currentDocument = value;
121
122 var boolDoc = false,
123 boolView = false;
124
125 // Should we enable the panel?
126 // Only if we have both a document and we're in design view.
127 if (typeof(value) !== "undefined") {
128 if (value.currentView === "design") {
129 // We are in design view.
130 boolView = true;
131 }
132 }
133 if (typeof(this._currentDocument) !== "undefined") {
134 // We have a document, or at least we have initialized the panel.
135 boolDoc = true;
136 }
126 137
127 if(!value) { 138 if(boolDoc === false) {
128 this._boolCacheArrays = false; 139 this._boolCacheArrays = false;
129 this.clearTimelinePanel(); 140 this.clearTimelinePanel();
130 this._boolCacheArrays = true; 141 this._boolCacheArrays = true;
131 this.enablePanel(false); 142 this.enablePanel(false);
132 } else if(this._currentDocument.currentView === "design") { 143 } else {
133 this._boolCacheArrays = false; 144 if(boolView === true) {
134 this.clearTimelinePanel(); 145 this._boolCacheArrays = false;
135 this._boolCacheArrays = true; 146 this.clearTimelinePanel();
136 147 this._boolCacheArrays = true;
137 // Rebind the document events for the new document context 148
138 this._bindDocumentEvents(); 149 // Rebind the document events for the new document context
139 150 this._bindDocumentEvents();
140 // Initialize the timeline for the document. 151
141 this.initTimelineForDocument(); 152 // Initialize the timeline for the document.
153 this.initTimelineForDocument();
154 this.enablePanel(true);
155 }
142 } 156 }
143 } 157 }
144 }, 158 },
@@ -595,7 +609,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
595 prepareForDraw:{ 609 prepareForDraw:{
596 value:function () { 610 value:function () {
597 this.initTimeline(); 611 this.initTimeline();
598
599 } 612 }
600 }, 613 },
601 614
@@ -726,11 +739,27 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
726 if (this._boolCacheArrays) { 739 if (this._boolCacheArrays) {
727 // ... but only if we're supposed to. 740 // ... but only if we're supposed to.
728 if(this.currentDocument) { 741 if(this.currentDocument) {
742 var i = 0,
743 hashLength = this.application.ninja.currentDocument.tlBreadcrumbHash.length,
744 boolHash = false;
745
729 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; 746 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers;
730 this.application.ninja.currentDocument.tlCurrentSelectedContainer = this.currentDocument.model.domContainer; 747 this.application.ninja.currentDocument.tlCurrentSelectedContainer = this.currentDocument.model.domContainer;
731 this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; 748 this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber;
732 this.application.ninja.currentDocument.tlCurrentLayerSelected = this.currentLayerSelected; 749 this.application.ninja.currentDocument.tlCurrentLayerSelected = this.currentLayerSelected;
733 this.application.ninja.currentDocument.tlCurrentLayersSelected = this.currentLayersSelected; 750 this.application.ninja.currentDocument.tlCurrentLayersSelected = this.currentLayersSelected;
751 for (i = 0; i < hashLength; i++ ) {
752 if (this.application.ninja.currentDocument.tlBreadcrumbHash[i].containerUuid === this.currentDocument.model.domContainer.uuid) {
753 this.application.ninja.currentDocument.tlBreadcrumbHash[i].arrLayers = this.arrLayers;
754 boolHash = true;
755 }
756 }
757 if (boolHash === false) {
758 var newHash = {};
759 newHash.containerUuid = this.currentDocument.model.domContainer.uuid;
760 newHash.arrLayers = this.arrLayers;
761 this.application.ninja.currentDocument.tlBreadcrumbHash.push(newHash);
762 }
734 } 763 }
735 this.application.ninja.currentDocument.tlCurrentElementsSelected = this.currentElementsSelected; 764 this.application.ninja.currentDocument.tlCurrentElementsSelected = this.currentElementsSelected;
736 } 765 }
@@ -748,6 +777,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
748 this.application.ninja.currentDocument.tlCurrentLayersSelected = false; 777 this.application.ninja.currentDocument.tlCurrentLayersSelected = false;
749 this.application.ninja.currentDocument.tlCurrentElementsSelected = []; 778 this.application.ninja.currentDocument.tlCurrentElementsSelected = [];
750 this.application.ninja.currentDocument.lockedElements = []; 779 this.application.ninja.currentDocument.lockedElements = [];
780 this.application.ninja.currentDocument.tlBreadcrumbHash = [];
751 } 781 }
752 }, 782 },
753 783
@@ -869,12 +899,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
869 this.checkable_lock.addEventListener("click",this.handleLockLayerClick.bind(this),false); 899 this.checkable_lock.addEventListener("click",this.handleLockLayerClick.bind(this),false);
870 this.checkable_visible.addEventListener("click",this.handleLayerVisibleClick.bind(this),false); 900 this.checkable_visible.addEventListener("click",this.handleLayerVisibleClick.bind(this),false);
871 901
872 // Bind some bindings
873 Object.defineBinding(this, "currentSelectedContainer", {
874 boundObject:this.application.ninja,
875 boundObjectPropertyPath:"currentSelectedContainer",
876 oneway:true
877 });
878 this.addPropertyChangeListener("currentDocument.model.domContainer", this); 902 this.addPropertyChangeListener("currentDocument.model.domContainer", this);
879 903
880 // Start the panel out in disabled mode by default 904 // Start the panel out in disabled mode by default
@@ -897,7 +921,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
897 this.drawTimeMarkers(); 921 this.drawTimeMarkers();
898 // Document switching 922 // Document switching
899 // Check to see if we have saved timeline information in the currentDocument. 923 // Check to see if we have saved timeline information in the currentDocument.
900 //console.log("TimelinePanel.initTimelineForDocument"); 924 // console.log("TimelinePanel.initTimelineForDocument");
901 925
902 if ((typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined")) { 926 if ((typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined")) {
903 // console.log('TimelinePanel.initTimelineForDocument: new Document'); 927 // console.log('TimelinePanel.initTimelineForDocument: new Document');
@@ -930,20 +954,36 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
930 } else if (this.application.ninja.currentDocument.setLevel) { 954 } else if (this.application.ninja.currentDocument.setLevel) {
931 // console.log('TimelinePanel.initTimelineForDocument: breadCrumbClick'); 955 // console.log('TimelinePanel.initTimelineForDocument: breadCrumbClick');
932 // Information stored, but we're moving up or down in the breadcrumb. 956 // Information stored, but we're moving up or down in the breadcrumb.
933 // Get the current selection and restore timeline info for its children. 957
934 var parentNode = this.currentDocument.model.domContainer, 958 var i = 0,
959 hash = this.application.ninja.currentDocument.tlBreadcrumbHash,
960 hashLength = hash.length,
961 boolHashed = false,
962 parentNode = this.currentDocument.model.domContainer,
935 storedCurrentLayerNumber = this.application.ninja.currentDocument.tllayerNumber; 963 storedCurrentLayerNumber = this.application.ninja.currentDocument.tllayerNumber;
936 this.temparrLayers = []; 964 this.temparrLayers = [];
937 965
938 for (myIndex = 0; parentNode.children[myIndex]; myIndex++) { 966 // It's possible there is something stored in the breadcrumb hash in currentdocument, so check there first.
939 this._openDoc = true; 967 for (i = 0; i < hashLength; i++ ) {
940 this.restoreLayer(parentNode.children[myIndex]); 968 if (hash[i].containerUuid === this.currentDocument.model.domContainer.uuid) {
941 969 this.temparrLayers = hash[i].arrLayers
942 } 970 boolHashed = true;
971 }
972 }
973
974 // Possibly nothing was in the hash, so check and if so fall back to old restoreLayer method.
975 if (boolHashed === false) {
976 for (myIndex = 0; parentNode.children[myIndex]; myIndex++) {
977 this._openDoc = true;
978 this.restoreLayer(parentNode.children[myIndex]);
979 }
980 }
981
943 // Draw the repetition. 982 // Draw the repetition.
944 this.arrLayers = this.temparrLayers; 983 this.arrLayers = this.temparrLayers;
945 this.currentLayerNumber = storedCurrentLayerNumber; 984 this.currentLayerNumber = storedCurrentLayerNumber;
946 this.application.ninja.currentDocument.setLevel = false; 985 this.application.ninja.currentDocument.setLevel = false;
986 this.resetMasterDuration();
947 987
948 } else { 988 } else {
949 // console.log('TimelinePanel.initTimelineForDocument: else fallback'); 989 // console.log('TimelinePanel.initTimelineForDocument: else fallback');
@@ -1361,27 +1401,43 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1361 1401
1362 timelineLeftPaneKeydown: { 1402 timelineLeftPaneKeydown: {
1363