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.html | 18 +++++++++--------- js/stage/stage.reel/stage.js | 37 +++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 21 deletions(-) (limited to 'js/stage/stage.reel') diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 30c3d231..89b674ab 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -18,25 +18,25 @@ } }, - "StageDeps1": { + "stageDeps": { "prototype": "js/stage/stage-deps", "properties": { "stage": {"@": "owner"} + }, + "bindings": { + "currentDocument": {"<-": "@owner.currentDocument"} } }, - "layout1": { + "layout": { "prototype": "js/stage/layout", "properties": { "canvas": {"#": "layoutCanvas"}, "stage": {"@": "owner"} }, "bindings": { - "layoutView": { - "boundObject": {"@": "owner" }, - "boundObjectPropertyPath": "appModel.layoutView", - "oneway": true - } + "layoutView": {"<-": "@owner.appModel.layoutView"}, + "currentDocument": {"<-": "@owner.currentDocument"} } }, @@ -59,8 +59,8 @@ "_layoutCanvas": {"#": "layoutCanvas"}, "_canvas": {"#": "stageCanvas"}, "_drawingCanvas": {"#": "drawingCanvas"}, - "stageDeps": {"@": "StageDeps1"}, - "layout": {"@": "layout1"}, + "stageDeps": {"@": "stageDeps"}, + "layout": {"@": "layout"}, "stageView": {"@": "stageView"}, "textTool": {"@": "textTool"}, "focusManager": {"@": "focusManager"} 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