From 7283884c39df537694b21419a3ea9e3ca7793b4b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 13:43:35 -0800 Subject: switch html document - re-initialize draw-utils and snap-manager on opening a document and while switching documents Signed-off-by: Ananya Sen --- js/stage/stage-deps.js | 38 ++++++++++++++++++++-------------- js/stage/stage-view.reel/stage-view.js | 14 +++++-------- js/stage/stage.reel/stage.js | 4 ++++ 3 files changed, 31 insertions(+), 25 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index d46e2b81..316a5bb0 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -23,6 +23,10 @@ exports.StageDeps = Montage.create(Component, { value: snapManager }, + drawUtils: { + value: drawUtils + }, + currentStage: { value: null }, @@ -119,29 +123,31 @@ exports.StageDeps = Montage.create(Component, { }, handleOpenDocument: { - value: function() { + value: function() { + + workingPlane = Vector.create( [0,0,1,0] ); - workingPlane = Vector.create( [0,0,1,0] ); + snapManager.setCurrentStage(this.currentStage); - snapManager.setCurrentStage(this.currentStage); + viewUtils.setCurrentDocument(this.currentDocument); + viewUtils.setRootElement(this.currentStage.parentNode); + viewUtils.setStageElement(this.currentStage); - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); + drawUtils.viewUtils = viewUtils; + drawUtils.snapManager = snapManager; + drawUtils.ElementPlanes = ElementPlanes; - drawUtils.setDrawingSurfaceElement(this.stage.canvas); - drawUtils.setSourceSpaceElement( this.currentStage ); - drawUtils.setWorkingPlane( workingPlane ); - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; + snapManager._isCacheInvalid=true; - snapManager.setupDragPlaneFromPlane ( workingPlane ); + snapManager.setupDragPlaneFromPlane ( workingPlane ); - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + DrawingToolBase.stage = this.currentStage; + DrawingToolBase.stageComponent = this.stage; + drawUtils.initializeFromDocument(); + } } - } + + }); \ No newline at end of file diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index dc9980f0..0b688c75 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -122,10 +122,6 @@ exports.StageView = Montage.create(Component, { switchDocument:{ value: function(doc){ - //save editor cursor position - if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ - this.application.ninja.documentController.activeDocument.hline = this.application.ninja.documentController.activeDocument.editor.getCursor(true); - } this.application.ninja.documentController._hideCurrentDocument(); this.application.ninja.documentController.activeDocument = doc; @@ -133,17 +129,17 @@ exports.StageView = Montage.create(Component, { this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe this.application.ninja.documentController._showCurrentDocument(); - var documentController = this.application.ninja.documentController; - - //restore editor cursor position + //focus current document if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ - this.application.ninja.documentController.activeDocument.editor.setCursor(this.application.ninja.documentController.activeDocument.hline); document.getElementById("codeMirror_"+this.application.ninja.documentController.activeDocument.uuid).getElementsByClassName("CodeMirror")[0].focus(); } if(this.application.ninja.documentController.activeDocument.currentView === "design") { this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe - this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; + this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; + + this.application.ninja.stage.snapManager._isCacheInvalid=true; + this.application.ninja.stage.drawUtils.initializeFromDocument(); // TODO dispatch event here // appDelegateModule.MyAppDelegate.onSetActiveDocument(); diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 44e14827..6bb626c2 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -37,6 +37,10 @@ exports.Stage = Montage.create(Component, { get: function() { return this.stageDeps.snapManager; } }, + drawUtils: { + get: function() { return this.stageDeps.drawUtils; } + }, + resizeCanvases: { get: function() { return this._resizeCanvases; -- cgit v1.2.3 From 6e66f411ba02eaaeb33471115345ecf3c7ce4ce9 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 17:55:59 -0800 Subject: refresh draw-utils, snap-manager, view-utils for html document stitching Signed-off-by: Ananya Sen --- js/stage/stage-deps.js | 56 +++++++++++++++++++++++++--------- js/stage/stage-view.reel/stage-view.js | 9 +++--- js/stage/stage.reel/stage.js | 10 +++--- 3 files changed, 50 insertions(+), 25 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 316a5bb0..16f2c652 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -123,30 +123,56 @@ exports.StageDeps = Montage.create(Component, { }, handleOpenDocument: { - value: function() { + value: function() { - workingPlane = Vector.create( [0,0,1,0] ); + workingPlane = Vector.create( [0,0,1,0] ); - snapManager.setCurrentStage(this.currentStage); + snapManager.setCurrentStage(this.currentStage); - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); + viewUtils.setCurrentDocument(this.currentDocument); + viewUtils.setRootElement(this.currentStage.parentNode); + viewUtils.setStageElement(this.currentStage); - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; + drawUtils.viewUtils = viewUtils; + drawUtils.snapManager = snapManager; + drawUtils.ElementPlanes = ElementPlanes; - snapManager._isCacheInvalid=true; + snapManager._isCacheInvalid=true; - snapManager.setupDragPlaneFromPlane ( workingPlane ); + snapManager.setupDragPlaneFromPlane ( workingPlane ); - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + DrawingToolBase.stage = this.currentStage; + DrawingToolBase.stageComponent = this.stage; - drawUtils.initializeFromDocument(); - } + drawUtils.initializeFromDocument(); + } + }, + + reinitializeForSwitchDocument: { + value: function() { + + workingPlane = Vector.create( [0,0,1,0] ); + + snapManager.setCurrentStage(this.currentStage); + + viewUtils.setCurrentDocument(this.currentDocument); + viewUtils.setRootElement(this.currentStage.parentNode); + viewUtils.setStageElement(this.currentStage); + + drawUtils.viewUtils = viewUtils; + drawUtils.snapManager = snapManager; + drawUtils.ElementPlanes = ElementPlanes; + + snapManager._isCacheInvalid=true; + + snapManager.setupDragPlaneFromPlane ( workingPlane ); + + DrawingToolBase.stage = this.currentStage; + DrawingToolBase.stageComponent = this.stage; + + drawUtils.initializeFromDocument(); } + } diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 0b688c75..ab02661d 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -118,8 +118,7 @@ exports.StageView = Montage.create(Component, { } }, - - + //called for switching between html documents switchDocument:{ value: function(doc){ this.application.ninja.documentController._hideCurrentDocument(); @@ -138,8 +137,10 @@ exports.StageView = Montage.create(Component, { this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; - this.application.ninja.stage.snapManager._isCacheInvalid=true; - this.application.ninja.stage.drawUtils.initializeFromDocument(); + //reinitialize draw-util, snapmanager and view-util + this.application.ninja.stage.stageDeps.reinitializeForSwitchDocument(); + + //this.application.ninja.stage.layout.reinitializeForSwitchDocument(); // TODO dispatch event here // appDelegateModule.MyAppDelegate.onSetActiveDocument(); diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 755c7ff1..9784f14d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -148,12 +148,12 @@ exports.Stage = Montage.create(Component, { userContentLeft: { get: function() { return this._userContentLeft; }, - set: function(value) { this._userContentLeft = value; } + set: function(value) { this._userContentLeft = value;} }, userContentTop: { get: function() { return this._userContentTop; }, - set: function(value) { this._userContentTop = value; } + set: function(value) { this._userContentTop = value;} }, userContentBorder: { @@ -439,12 +439,11 @@ exports.Stage = Montage.create(Component, { */ handleScroll: { value: function() { - this._scrollLeft = this._iframeContainer.scrollLeft; this._scrollTop = this._iframeContainer.scrollTop; - this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; - this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; + this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; + this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; // Need to clear the snap cache and set up the drag plane //snapManager.setupDragPlaneFromPlane( workingPlane ); @@ -452,7 +451,6 @@ exports.Stage = Montage.create(Component, { this.needsDraw = true; this.layout.draw(); - //this._toolsList.action("DrawHandles"); } -- cgit v1.2.3 From 85d59d57ea556b114c5cad9b2ec67ccc27119380 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 24 Feb 2012 12:05:16 -0800 Subject: - added flag for timeline to identify new file flow - added switchDocument event for timeline Signed-off-by: Ananya Sen --- js/stage/stage-view.reel/stage-view.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index ab02661d..91047e51 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -146,6 +146,8 @@ exports.StageView = Montage.create(Component, { // appDelegateModule.MyAppDelegate.onSetActiveDocument(); } + NJevent("switchDocument"); + } }, -- cgit v1.2.3 From b056b4bef5982466d80d72e5cbb31e63087990e1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 24 Feb 2012 15:30:55 -0800 Subject: - added closeDocument event for timeline - minor bug fixes Signed-off-by: Ananya Sen --- js/stage/layout.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index a94dd10c..de4c67c1 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -98,6 +98,11 @@ exports.Layout = Montage.create(Component, { handleSelectionChange: { value: function(event) { + + if(this.application.ninja.documentController.activeDocument === null){ + return; + } + // Make an array copy of the line node list which is not an array like object this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); -- cgit v1.2.3