From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 37 +++++++++++++++------------------- js/controllers/selection-controller.js | 4 ++-- 2 files changed, 18 insertions(+), 23 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 50874725..fc1f2c0f 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -459,16 +459,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // There is a document currently opened currentDocument = this.activeDocument; - //this.application.ninja.stage.stageView.showCodeViewBar(false); //this.application.ninja.stage.stageView.restoreAllPanels(); - - //this.activeDocument.saveAppState(); - - // TODO: Do we need this? - //this.application.ninja.stage.hideCanvas(true); - //this.application.ninja.stage.stageView.hideRulers(); - - //this.activeDocument.restoreAppState(); } else { // There is no document opened @@ -480,7 +471,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.hideCanvas(false); } - // Set the active document this.activeDocument = doc; @@ -489,22 +479,27 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Flag to stop stylesheet dirty event this._hackInitialStyles = false; - this.switchDocuments(currentDocument, doc); - - NJevent("onOpenDocument", doc); - - //Setting opacity to be viewable after load - //doc.model.views.design.iframe.style.opacity = 1; - + this.switchDocuments(currentDocument, doc, true); } }, switchDocuments: { - value: function(current, newDocument) { - newDocument.model.views.design.iframe.style.opacity = 1; + value: function(currentDocument, newDocument, didCreate) { + + if(currentDocument) { + currentDocument.serializeDocument(); - if(current) { - current.model.views.design.hide(); + currentDocument.model.views.design.hide(); + } + + if(didCreate) { + newDocument.model.views.design.iframe.style.opacity = 1; + NJevent("onOpenDocument", newDocument); + } else { + this.activeDocument = newDocument; + newDocument.model.views.design.show(); + newDocument.deserializeDocument(); + NJevent("switchDocument"); } } }, diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 6e40abb5..1092615a 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -81,10 +81,10 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { - if(this.application.ninja.documentController.activeDocument.currentView === "design"){ +// if(this.application.ninja.documentController.activeDocument.currentView === "design"){ this._isDocument = this.application.ninja.selectedElements.length === 0; NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - } +// } } }, -- cgit v1.2.3