From 24d1873302b2fffc25d254e15e8aa36f59eedb88 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 01:36:05 -0700 Subject: fixed a switch documents bug where the layout was getting called before setting the container. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 4 +++- js/ninja.reel/ninja.js | 6 ++++-- js/stage/stage.reel/stage.js | 8 ++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ea4022b8..f1523d87 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -492,6 +492,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, currentDocument.model.views.design.hide(); } + this.application.ninja.stage.clearAllCanvas(); + if(didCreate) { newDocument.model.views.design.iframe.style.opacity = 1; NJevent("onOpenDocument", newDocument); @@ -499,7 +501,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument = newDocument; newDocument.model.views.design.show(); newDocument.deserializeDocument(); - NJevent("switchDocument"); + NJevent("onSwitchDocument"); } } }, diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 067a005f..6d41cd53 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -175,7 +175,7 @@ exports.Ninja = Montage.create(Component, { this.eventManager.addEventListener("selectTool", this, false); this.eventManager.addEventListener("selectSubTool", this, false); this.eventManager.addEventListener("onOpenDocument", this, false); - this.eventManager.addEventListener("switchDocument", this, false); + this.eventManager.addEventListener("onSwitchDocument", this, false); this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false); @@ -291,13 +291,15 @@ exports.Ninja = Montage.create(Component, { } }, - handleSwitchDocument: { + handleOnSwitchDocument: { value: function() { this.currentDocument = this.documentController.activeDocument; if(this.currentDocument.documentRoot) { this._currentSelectedContainer = this.selectionController._currentSelectedContainer = this.currentDocument.documentRoot; } + + NJevent("switchDocument"); } }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index cac99326..8da89fb9 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -593,6 +593,14 @@ exports.Stage = Montage.create(Component, { } }, + clearAllCanvas: { + value: function() { + this._drawingContext.clearRect(0, 0, this._drawingCanvas.width, this._drawingCanvas.height); + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.layout.clearCanvas(); + } + }, + SelectTool: { value: function(cursor) { this._drawingCanvas.style.cursor = cursor; -- cgit v1.2.3