From ffe6c157279e115f4658d8c66622085f05cfbf43 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 15:27:03 -0700 Subject: fixing the switching between various types of documents Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 41 +++++----------------------------- js/controllers/selection-controller.js | 6 ++++- js/stage/stage.reel/stage.js | 10 +++++++++ 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 72a669b3..0fe1636a 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -45,11 +45,6 @@ exports.DocumentController = Montage.create(Component, { if(this._currentDocument) { this._currentDocument.model.currentView.hide(); - - if(this._currentDocument.model.parentContainer !== value.model.parentContainer) { - this._currentDocument.model.parentContainer.style["display"] = "none"; - value.model.parentContainer.style["display"] = "block"; - } } this._currentDocument = value; @@ -58,10 +53,13 @@ exports.DocumentController = Montage.create(Component, { document.getElementById("iframeContainer").style.display = "block"; document.getElementById("codeViewContainer").style.display = "block"; } else if(this._currentDocument.currentView === "design") { + document.getElementById("codeViewContainer").style.display = "none"; + document.getElementById("iframeContainer").style.display = "block"; this._currentDocument.model.currentView.show(); this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); } else { document.getElementById("iframeContainer").style.display = "none"; + this._currentDocument.model.parentContainer.style["display"] = "block"; this._currentDocument.model.currentView.show(); } @@ -355,26 +353,8 @@ exports.DocumentController = Montage.create(Component, { switchDocuments: { value: function(currentDocument, newDocument, didCreate) { - if(currentDocument) { - if(currentDocument.currentView === "design") { - currentDocument.serializeDocument(); - } - - - - if(currentDocument.currentView === "code" && newDocument.currentView === "design") { - this.application.ninja.stage.showCodeViewBar(false); - this.application.ninja.stage.restoreAllPanels(); - this.application.ninja.stage.hideCanvas(false); - this.application.ninja.stage.showRulers(); - } - } - - if(newDocument.currentView === "code") { - this.application.ninja.stage.showCodeViewBar(true); - this.application.ninja.stage.collapseAllPanels(); - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.hideRulers(); + if(currentDocument.currentView === "design") { + currentDocument.serializeDocument(); } if(didCreate) { @@ -384,19 +364,8 @@ exports.DocumentController = Montage.create(Component, { newDocument.model.parentContainer.style["display"] = "block"; } } else { - this.activeDocument = newDocument; - - newDocument.model.currentView.show(); - if(newDocument.currentView === "design") { newDocument.deserializeDocument(); - NJevent("onSwitchDocument"); - } else { - this.application.ninja.currentDocument = newDocument; - newDocument.model.views.code.editor.focus(); - - newDocument.model.isActive = true; - this.application.ninja.codeEditorController.applySettings();//should be called after activeDocument is updated } } } diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index a219c597..28c0f3d3 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -33,17 +33,19 @@ exports.SelectionController = Montage.create(Component, { return; } - if(this._currentDocument) { + if(this._currentDocument && this._currentDocument.currentView === "design") { this._currentDocument.model.selection = this.application.ninja.selectedElements; this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; } this._currentDocument = value; + /* if(!value) { } else if(this._currentDocument.currentView === "design") { } else { } + */ } }, @@ -57,6 +59,8 @@ exports.SelectionController = Montage.create(Component, { return this._selectedElements; }, set: function(value) { + if(this.currentDocument && this.currentDocument.currentView === "code") return; + if(value) { this._selectedElements = value; diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 4c4ba6c9..cd08c55d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -187,8 +187,18 @@ exports.Stage = Montage.create(Component, { drawUtils._eltArray.length = 0; drawUtils._planesArray.length = 0; } else if(this._currentDocument.currentView === "design") { + this.showCodeViewBar(false); + this.restoreAllPanels(); + this.hideCanvas(false); + this.showRulers(); + this.clearAllCanvas(); this.initWithDocument(false); + } else { + this.showCodeViewBar(true); + this.collapseAllPanels(); + this.hideCanvas(true); + this.hideRulers(); } } }, -- cgit v1.2.3