From fc22cd3b5c65dc6f137fbb59443e2061cbbcac26 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Thu, 19 Apr 2012 14:26:57 -0700 Subject: Timeline: Bug fix: Maintain selection between document switching. --- js/panels/Timeline/Layer.reel/Layer.js | 48 ++++++++++------------ .../Timeline/TimelinePanel.reel/TimelinePanel.js | 15 +++---- 2 files changed, 28 insertions(+), 35 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js index 36c77018..5b1ce594 100644 --- a/js/panels/Timeline/Layer.reel/Layer.js +++ b/js/panels/Timeline/Layer.reel/Layer.js @@ -113,7 +113,18 @@ var Layer = exports.Layer = Montage.create(Component, { this.layerData.layerTag = newVal; } }, - + _docUUID : { + value: null + }, + docUUID : { + serializable: true, + get: function() { + return this._docUUID; + }, + set: function(newVal) { + this._docUUID = newVal; + } + }, /* Position and Transform hottext values */ _dtextPositionX : { value:null, @@ -555,10 +566,15 @@ var Layer = exports.Layer = Montage.create(Component, { }, didDraw: { value: function() { - if ((this.isSelected === true) && (this._isFirstDraw === true)) { - // Once we're done drawing the first time we need to tell the TimelinePanel if - // this layer is supposed to be selected. - this.parentComponent.parentComponent.selectedLayerID = this.layerID; + if (this._isFirstDraw === true) { + if (this.isSelected === true) { + if (this.application.ninja.currentDocument._uuid === this._docUUID) { + // Once we're done drawing the first time we need to tell the TimelinePanel if + // this layer is supposed to be selected. + //console.log('layerName ' + this.layerName); + this.parentComponent.parentComponent.selectedLayerID = this.layerID; + } + } this._isFirstDraw = false; } } @@ -567,36 +583,16 @@ var Layer = exports.Layer = Montage.create(Component, { /* Begin: Controllers */ - // Initialize a just-created layer with some basic defaults and needed selectors. + // Initialize a just-created layer init: { value: function() { - // Default some vars - //this.arrLayerStyles = []; - // Get some selectors. this.label = this.element.querySelector(".label-layer"); this.titleSelector = this.label.querySelector(".collapsible-label"); this.buttonAddStyle = this.element.querySelector(".button-add"); this.buttonDeleteStyle = this.element.querySelector(".button-delete"); - - - } }, - selectLayer:{ - value:function(){ - // this.mainCollapser.header.classList.add("layerSelected"); - this.element.classList.add("layerSelected"); - this.isSelected = true; - } - }, - deselectLayer:{ - value:function(){ - // this.mainCollapser.header.classList.remove("layerSelected"); - this.element.classList.remove("layerSelected"); - this.isSelected = false; - } - }, addStyle : { value: function() { // Add a new style rule. It should be added above the currently selected rule, diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 33b99760..eeb74625 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -112,7 +112,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { var selectIndex = this.getLayerIndexByID(newVal); this._selectedLayerID = newVal; this._captureSelection = true; - this.selectLayer(selectIndex); + //console.log(selectIndex); + //debugger; + this.selectLayer(selectIndex, true); } } }, @@ -410,6 +412,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { returnObj.layerData.isTrackAnimated = false; returnObj.parentElementUUID = null; returnObj.parentElement = null; + returnObj.docUUID = this.application.ninja.currentDocument._uuid; return returnObj; } @@ -536,14 +539,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // Initialize BreadCrumb this.application.ninja.breadCrumbClick = false; this.enablePanel(false); - - /* - Object.defineBinding(this, "breadCrumbContainer", { - boundObject:this.application.ninja, - boundObjectPropertyPath:"currentSelectedContainer", - oneway:true - }); - */ + } }, @@ -684,6 +680,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // Clear the timeline but not the cache //console.log('TimelinePanel.handleDocumentChange'); if ((event.type === "closeDocument") && (this.application.ninja.documentController._documents.length > 0)) { + // Ignore extra closeDocument event that fires while there are still documents open. return; } this._boolCacheArrays = false; -- cgit v1.2.3