From 402a369c7bf164c3c6686be3a33f5e36f25e4130 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 23:19:32 -0700 Subject: document controller and stage view code cleanup Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 33 ++++++++++++++++----------------- js/document/document-html.js | 21 ++++++++++++++++++--- js/document/html-document.js | 26 -------------------------- js/document/models/html.js | 5 +++++ js/stage/stage-view.reel/stage-view.js | 17 ++++++++++++++++- 5 files changed, 55 insertions(+), 47 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1796f9b5..cf46e73e 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -458,8 +458,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(this.activeDocument) { // There is a document currently opened -// this.application.ninja.stage.stageView.showCodeViewBar(false); -// this.application.ninja.stage.stageView.restoreAllPanels(); + + + //this.application.ninja.stage.stageView.showCodeViewBar(false); + //this.application.ninja.stage.stageView.restoreAllPanels(); // /* @@ -472,6 +474,18 @@ var DocumentController = exports.DocumentController = Montage.create(Component, 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 } else { // There is no document opened @@ -564,21 +578,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - _showCurrentDocument: { - value: function() { - if(this.activeDocument) { - 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"; - } - } - } - }, - handleStyleSheetDirty:{ value:function(){ if(!this._hackInitialStyles) { diff --git a/js/document/document-html.js b/js/document/document-html.js index a26b74d5..56d9db02 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -134,14 +134,29 @@ exports.HtmlDocument = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - saveAppState: { + serializeDocument: { value: function () { - //TODO: Import functionality + // There are not needed for now ssince we cannot change them + //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; + //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; + + // Serialize the current scroll position + // TODO: Implement + + // Serialize the selection + this.model.selection = this.application.ninja.selectedElements.slice(0); + this.draw3DGrid = this.application.ninja.appModel.show3dGrid; + + // Serialize the undo + // TODO: Save the montage undo queue + + // Pause the videos + this.model.views.design.pauseVideos(); } }, //////////////////////////////////////////////////////////////////// // - restoreAppState: { + deserializeDocument: { value: function () { //TODO: Import functionality } diff --git a/js/document/html-document.js b/js/document/html-document.js index 6a84abdf..68c2a9fb 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -920,32 +920,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } }, - //////////////////////////////////////////////////////////////////// - saveAppState:{ - enumerable: false, - value: function () { - - this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft; - this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop; - - this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; - this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; - - if(typeof this.application.ninja.selectedElements !== 'undefined'){ - this.selectionModel = this.application.ninja.selectedElements.slice(0); - } - - this.draw3DGrid = this.application.ninja.appModel.show3dGrid; - - //persist a clone of history per document - this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); - this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); - this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start - - //pause videos on switching or closing the document, so that the browser does not keep downloading the media data - this.pauseVideos(); - } - }, //////////////////////////////////////////////////////////////////// restoreAppState:{ diff --git a/js/document/models/html.js b/js/document/models/html.js index b57ff832..67457863 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -16,6 +16,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // hasTemplate: { value: false + }, + //////////////////////////////////////////////////////////////////// + // + selection: { + value: [] }, //////////////////////////////////////////////////////////////////// // diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 7680103d..ba94fadf 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -120,7 +120,22 @@ 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(); + + +// this.application.ninja.documentController._showCurrentDocument(); + // Inline function below + if(this.activeDocument) { + 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"; + } + } + + //focus editor if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ this.application.ninja.documentController.activeDocument.editor.focus(); -- cgit v1.2.3