From eff40602cac6821f8272177c24b6bf3de399f8b1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 17 May 2012 21:11:33 -0700 Subject: multiple documents - enable opening multiple documents and initial switching Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 71 +++++++++++++++++------------------ js/document/document-html.js | 2 - 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index cf46e73e..50874725 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -454,58 +454,57 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Open document callback _onOpenDocument: { value: function(doc){ - + var currentDocument; if(this.activeDocument) { // There is a document currently opened - - + currentDocument = this.activeDocument; //this.application.ninja.stage.stageView.showCodeViewBar(false); //this.application.ninja.stage.stageView.restoreAllPanels(); - // - /* - if(this.activeDocument.currentView === "design"){ - this.activeDocument.saveAppState(); - this.activeDocument.container.parentNode.style["display"] = "none"; - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.stageView.hideRulers(); - } + //this.activeDocument.saveAppState(); - this.activeDocument.container.style["display"] = "none"; - */ - - /* - this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design"){ - this.activeDocument.container.parentNode.style["display"] = "block"; - this.activeDocument.restoreAppState(); - }else{ - //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display = "none"; - } - - */ - // hide current document + // 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 - // Set the active document - this.activeDocument = doc; + // Show the rulers + // TODO: Move this indo design view + this.application.ninja.stage.stageView.showRulers(); // Show the canvas this.application.ninja.stage.hideCanvas(false); + } - // Show the rulers - // TODO: Move this indo design view - this.application.ninja.stage.stageView.showRulers(); - // Initialize the documentRoot styles - this.initializeRootStyles(doc.documentRoot); - // Flag to stop stylesheet dirty event - this._hackInitialStyles = false; + // Set the active document + this.activeDocument = doc; + + // Initialize the documentRoot styles + this.initializeRootStyles(doc.documentRoot); + // 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; + + } + }, + + switchDocuments: { + value: function(current, newDocument) { + newDocument.model.views.design.iframe.style.opacity = 1; - NJevent("onOpenDocument", doc); + if(current) { + current.model.views.design.hide(); } } }, diff --git a/js/document/document-html.js b/js/document/document-html.js index 56d9db02..c77ed7bc 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -119,8 +119,6 @@ exports.HtmlDocument = Montage.create(Component, { this._observer = null; //Making callback after view is loaded this.loaded.callback.call(this.loaded.context, this); - //Setting opacity to be viewable after load - this.model.views.design.iframe.style.opacity = 1; } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3