From db4f235dc9fd6f2242dee481d2f377005cf23596 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 24 Jul 2012 16:56:52 -0700 Subject: adding a viewIdentifier to the model to enable design/code switch Todo: - Cleanup and remove listeners - Finish stage reload - Add remaining bindings. Signed-off-by: Valerio Virgillito --- js/stage/binding-view.reel/binding-view.js | 24 +++++++++++++++++++----- js/stage/stage.reel/stage.js | 20 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 7 deletions(-) (limited to 'js/stage') diff --git a/js/stage/binding-view.reel/binding-view.js b/js/stage/binding-view.reel/binding-view.js index b207cc3d..5ad2d364 100755 --- a/js/stage/binding-view.reel/binding-view.js +++ b/js/stage/binding-view.reel/binding-view.js @@ -207,22 +207,36 @@ exports.BindingView = Montage.create(Component, { } }, - _currentDocument : { value: null }, - currentDocument : { - get : function() { return this._currentDocument; }, - set : function(value) { - if(value === this._currentDocument) { return; } + _currentDocument: { + value: null + }, + currentDocument: { + get: function() { + return this._currentDocument; + }, + set: function(value) { + if(value === this._currentDocument) { + return; + } this._currentDocument = value; + if(value) { this.hide = (value.currentView === 'code'); + this.currentDocument.addPropertyChangeListener("model.currentView", this, false); } this.needsDraw = true; } }, + handleChange: { + value: function() { + this.hide = this.currentDocument.model.currentView.identifier === "design-code"; + } + }, + _hide : { value: true }, hide : { get : function() { return this._hide; }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 817220d4..39336b57 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -368,6 +368,8 @@ exports.Stage = Montage.create(Component, { this.clearAllCanvas(); this.initWithDocument(); + + this._currentDocument.addPropertyChangeListener("model.currentView", this, false); } else { this.collapseAllPanels(); this.hideCanvas(true); @@ -376,6 +378,20 @@ exports.Stage = Montage.create(Component, { } }, + handleDocumentViewChange: { + value: function() { + if(this.currentDocument.model.currentView.identifier === "design-code") { + this.collapseAllPanels(); + this.hideRulers(); + this.hideCanvas(true); + } else { + this.restoreAllPanels(true); + this.hideCanvas(false); + this.showRulers(); + } + } + }, + _userPaddingLeft: { value: 0 }, _userPaddingTop: { value: 0 }, @@ -492,8 +508,6 @@ exports.Stage = Montage.create(Component, { this.eventManager.addEventListener( "elementChange", this, false); this.addPropertyChangeListener("currentDocument.model.domContainer", this, true); -// this.addPropertyChangeListener("currentDocument.model.domContainer", this); - } }, @@ -586,6 +600,8 @@ exports.Stage = Montage.create(Component, { drawUtils.drawXZ = false; this.updatedStage = true; } + } else if(notification.currentPropertyPath === "model.currentView") { + this.handleDocumentViewChange(); } /* else if(notification.currentPropertyPath === "currentDocument.model.domContainer") { -- cgit v1.2.3