From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'js/stage/stage.reel/stage.js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index c7afb95c..e00d2b54 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -155,25 +155,41 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userContentBorder = value; } }, - _activeDocument : { + _currentDocument: { value : null, enumerable : false }, - activeDocument : { + currentDocument : { get : function() { - return this._activeDocument; + return this._currentDocument; }, - set : function(document) { - ///// If the document is null set default stylesheets to null + set : function(value) { + // TODO: WRONG! Fails when going from design to code view + if (value === this._currentDocument || value.getProperty("currentView") !== "design") { + console.log("Stage - current document not set since the same value of " + this._currentDocument + " and value " + value); + return; + } - if(!document) { - return false; + if(!value) { + // Show the rulers + this.showRulers(); + // Show the canvas + this.hideCanvas(false); } - ///// setting document via binding - this._activeDocument = document; + //console.log("Stage - set current document with value of " + value); + this._currentDocument = value; + + if(this._currentDocument.currentView === "design") { + this.clearAllCanvas(); + this.initWithDocument(false); + } + if(!this._currentDocument) { + this.hideRulers(); + this.hideCanvas(true); + } }, enumerable : false }, @@ -295,9 +311,6 @@ exports.Stage = Montage.create(Component, { this._scrollLeft = 0; this._scrollTop = 0; - this.stageDeps.handleOpenDocument(); - this.layout.handleOpenDocument(); - if(designView._template) { var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2); -- cgit v1.2.3