From 7fcb10270f9e19415f8452c261c2d0c86916a29a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 00:54:02 -0700 Subject: fixed the 3d grid when switching documents and some cleanup Signed-off-by: Valerio Virgillito --- .../code-editor-view-options.js | 2 +- js/controllers/document-controller.js | 21 ----------------- js/document/document-html.js | 21 ----------------- js/models/app-model.js | 26 ++++++++++++++++++++++ js/ninja.reel/ninja.html | 5 ++++- js/ninja.reel/ninja.js | 8 ------- 6 files changed, 31 insertions(+), 52 deletions(-) diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js index e4d622e3..dabce6e0 100644 --- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js +++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js @@ -12,7 +12,7 @@ var Montage = require("montage/core/core").Montage, exports.CodeEditorViewOptions = Montage.create(Component, { _currentDocument: { - value : null + value : null }, currentDocument : { diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 0fe1636a..a90375af 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -348,26 +348,5 @@ exports.DocumentController = Montage.create(Component, { value: function(document) { document.closeDocument(this.application.ninja, this.application.ninja.closeFile); } - }, - - switchDocuments: { - value: function(currentDocument, newDocument, didCreate) { - - if(currentDocument.currentView === "design") { - currentDocument.serializeDocument(); - } - - if(didCreate) { - if(newDocument.currentView === "design") { - - } else { - newDocument.model.parentContainer.style["display"] = "block"; - } - } else { - if(newDocument.currentView === "design") { - newDocument.deserializeDocument(); - } - } - } } }); diff --git a/js/document/document-html.js b/js/document/document-html.js index c60a12a2..8cc61026 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -117,10 +117,6 @@ exports.HtmlDocument = Montage.create(Component, { // serializeDocument: { value: function () { - // There are not needed for now since 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: Move these properties to the design view class this.model.scrollLeft = this.application.ninja.stage._scrollLeft; @@ -132,11 +128,6 @@ exports.HtmlDocument = Montage.create(Component, { // Serialize the selection, the container and grid //TODO: Move this property to the design view class this.model.selection = this.application.ninja.selectedElements.slice(0); - this.model.selectionContainer = this.application.ninja.currentSelectedContainer; - this.draw3DGrid = this.application.ninja.appModel.show3dGrid; - - // Serialize the undo - // TODO: Save the montage undo queue // Pause the videos //TODO: Move these to be handled on the show/hide methods in the view @@ -147,27 +138,15 @@ exports.HtmlDocument = Montage.create(Component, { // deserializeDocument: { value: function () { - // There are not needed for now since we cannot change them - //this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; - //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; - // Deserialize the current scroll position //TODO: Move these properties to the design view class this.application.ninja.stage._scrollLeft = this.model.scrollLeft; this.application.ninja.stage._scrollTop = this.model.scrollTop; this.application.ninja.stage._userContentLeft = this.model.userContentLeft; this.application.ninja.stage._userContentTop = this.model.userContentTop; - - //TODO: Move this property to the design view class - this.application.ninja.selectedElements = this.model.selection.slice(0); -// this.application.ninja.currentSelectedContainer = this.model.selectionContainer; - this.application.ninja.appModel.show3dGrid = this.draw3DGrid; // Serialize the undo // TODO: Save the montage undo queue - - //TODO: Move this to the document controller - this.model.isActive = true; } } //////////////////////////////////////////////////////////////////// diff --git a/js/models/app-model.js b/js/models/app-model.js index 1c599a32..ceba653e 100755 --- a/js/models/app-model.js +++ b/js/models/app-model.js @@ -9,6 +9,32 @@ var Montage = require("montage/core/core").Montage, exports.AppModel = Montage.create(Component, { + _currentDocument: { + value : null + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + if(this._currentDocument && this._currentDocument.currentView === "design") { + this._currentDocument.model.draw3DGrid = this.show3dGrid; + } + + this._currentDocument = value; + + if(this._currentDocument && this._currentDocument.currentView === "design") { + this.show3dGrid = this._currentDocument.model.draw3DGrid; + } + + } + }, + _livePreview: { value: false }, diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index a6422f6e..0c0944e7 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -25,7 +25,10 @@ }, "appModel": { - "prototype": "js/models/app-model" + "prototype": "js/models/app-model", + "bindings": { + "currentDocument": {"<-": "@documentList.selectedObjects.0"} + } }, "materialsModel": { diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index e9e1e31c..9593973e 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -296,9 +296,6 @@ exports.Ninja = Montage.create(Component, { openDocument: { value: function(doc) { - - - this.documentList.content.push(doc); // This is not needed with the latest 0.10 montage. // TODO: Remove this when integrating the next montage @@ -308,11 +305,6 @@ exports.Ninja = Montage.create(Component, { // TODO: Bind directly to the model of the document in components instead of this property this.currentSelectedContainer = doc.model.documentRoot; } - - -// this.appModel.show3dGrid = this.currentDocument.draw3DGrid; - - } }, -- cgit v1.2.3