From a402ae19732f7aeb53de27e3f25f72e9c42a453c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 16 Jul 2012 14:50:50 -0700 Subject: New: Added switching view functionality to document UI This now let's you switch between code and design views in all documents opened that support design view. Code view for these documents is currently unsupported, so this is just to hook up the UI to the new methods. Code view will be added next. --- js/controllers/document-controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 588481bb..5020e27d 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -68,7 +68,7 @@ exports.DocumentController = Montage.create(Component, { return; } - if(this._currentDocument) { + if(this._currentDocument && this._currentDocument.model.currentView) { this._currentDocument.model.currentView.hide(); } @@ -80,12 +80,12 @@ exports.DocumentController = Montage.create(Component, { } else if(this._currentDocument.currentView === "design") { document.getElementById("codeViewContainer").style.display = "none"; document.getElementById("iframeContainer").style.display = "block"; - this._currentDocument.model.currentView.show(); + if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); } else { document.getElementById("iframeContainer").style.display = "none"; this._currentDocument.model.parentContainer.style["display"] = "block"; - this._currentDocument.model.currentView.show(); + if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); } } -- cgit v1.2.3 From d799a03a52fbf4eaad4e469fabbf84c9bf2cb41d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 18 Jul 2012 12:26:08 -0700 Subject: parameterize the parentContainer for text document Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 5020e27d..ee7ca82c 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -356,7 +356,7 @@ exports.DocumentController = Montage.create(Component, { break; default: //Open in code view - Montage.create(TextDocument).init(file, this.application.ninja, this.application.ninja.openDocument, 'code'); + Montage.create(TextDocument).init(file, this.application.ninja, this.application.ninja.openDocument, 'code', document.getElementById("codeViewContainer")); break; } } -- cgit v1.2.3 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/controllers/document-controller.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ee7ca82c..83c1f58c 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -80,6 +80,7 @@ exports.DocumentController = Montage.create(Component, { } else if(this._currentDocument.currentView === "design") { document.getElementById("codeViewContainer").style.display = "none"; document.getElementById("iframeContainer").style.display = "block"; + this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false); if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); } else { @@ -91,6 +92,23 @@ exports.DocumentController = Montage.create(Component, { } }, + handleChange: { + value: function(notification) { + if(notification.currentPropertyPath === "model.currentViewIdentifier") { + if(this.currentDocument.model.currentView.identifier === "design-code") { +// document.getElementById("iframeContainer").style.display = "none"; +// this._currentDocument.model.parentContainer.style["display"] = "block"; +// if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); + } else { + document.getElementById("codeViewContainer").style.display = "none"; + document.getElementById("iframeContainer").style.display = "block"; + if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); + this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); + } + } + } + }, + deserializedFromTemplate: { value: function() { //TODO: Add event naming consistency (save, fileOpen and newFile should be consistent, all file events should be executeFile[operation name]) this.eventManager.addEventListener("appLoaded", this, false); -- cgit v1.2.3