From 5454cc462903c83a8c3651065b03cc1855db125e Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 24 Jul 2012 12:11:53 -0700 Subject: New: Adding method to switch from code to design view Added functionality to parse the code view string back into a Ninja template object to redraw design view. Only outstanding bugs are timeline errors and code view layout issues. --- .../layout/document-bar.reel/document-bar.js | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'js/components') diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 77f05bc1..bf84c652 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -233,23 +233,30 @@ exports.DocumentBar = Montage.create(Component, { value: function (view, render, aBtn, iBtn) { //TODO: Remove reference to string view if (this._currentDocument.model.currentView !== view) { - // + var doc; + //Switching view and changing button modes this._currentDocument.model.switchViewTo(view); iBtn.setAttribute('class', 'inactive'); aBtn.removeAttribute('class'); - //TODO: Add document parsing to reload view - this._currentDocument.reloadView(view, this.fileTemplate, { - mode: 'html', - libs: this._currentDocument.model.libs, - file: this._currentDocument.model.file, - webgl: this._currentDocument.model.webGlHelper.glData, - styles: this._currentDocument.model.getStyleSheets(), - template: this._currentDocument.fileTemplate, - document: this._currentDocument.model.views.design.iframe.contentWindow.document, - head: this._currentDocument.model.views.design.iframe.contentWindow.document.head, - body: this._currentDocument.model.views.design.iframe.contentWindow.document.body, - mjsTemplateCreator: this._currentDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator - }); + //Checking for view to get other view document (object to code and string to design) + if (view === 'code') { + doc = { + mode: 'html', + libs: this._currentDocument.model.libs, + file: this._currentDocument.model.file, + webgl: this._currentDocument.model.webGlHelper.glData, + styles: this._currentDocument.model.getStyleSheets(), + template: this._currentDocument.fileTemplate, + document: this._currentDocument.model.views.design.iframe.contentWindow.document, + head: this._currentDocument.model.views.design.iframe.contentWindow.document.head, + body: this._currentDocument.model.views.design.iframe.contentWindow.document.body, + mjsTemplateCreator: this._currentDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator + } + } else if (view === 'design') { + doc = this._currentDocument.model.views.code.textArea.value; + } + //Reloading the document from changes made + this._currentDocument.reloadView(view, this.fileTemplate, doc); } } }, -- cgit v1.2.3