aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-07-24 12:11:53 -0700
committerJose Antonio Marquez2012-07-24 12:11:53 -0700
commit5454cc462903c83a8c3651065b03cc1855db125e (patch)
tree3d35de3f87215f7e956d8c3e77b98039119c1218
parent2b4439fed88fbb785ee14a3372ae9480d186bae4 (diff)
downloadninja-5454cc462903c83a8c3651065b03cc1855db125e.tar.gz
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.
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.js35
-rwxr-xr-xjs/document/document-html.js2
2 files changed, 22 insertions, 15 deletions
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, {
233 value: function (view, render, aBtn, iBtn) { 233 value: function (view, render, aBtn, iBtn) {
234 //TODO: Remove reference to string view 234 //TODO: Remove reference to string view
235 if (this._currentDocument.model.currentView !== view) { 235 if (this._currentDocument.model.currentView !== view) {
236 // 236 var doc;
237 //Switching view and changing button modes
237 this._currentDocument.model.switchViewTo(view); 238 this._currentDocument.model.switchViewTo(view);
238 iBtn.setAttribute('class', 'inactive'); 239 iBtn.setAttribute('class', 'inactive');
239 aBtn.removeAttribute('class'); 240 aBtn.removeAttribute('class');
240 //TODO: Add document parsing to reload view 241 //Checking for view to get other view document (object to code and string to design)
241 this._currentDocument.reloadView(view, this.fileTemplate, { 242 if (view === 'code') {
242 mode: 'html', 243 doc = {
243 libs: this._currentDocument.model.libs, 244 mode: 'html',
244 file: this._currentDocument.model.file, 245 libs: this._currentDocument.model.libs,
245 webgl: this._currentDocument.model.webGlHelper.glData, 246 file: this._currentDocument.model.file,
246 styles: this._currentDocument.model.getStyleSheets(), 247 webgl: this._currentDocument.model.webGlHelper.glData,
247 template: this._currentDocument.fileTemplate, 248 styles: this._currentDocument.model.getStyleSheets(),
248 document: this._currentDocument.model.views.design.iframe.contentWindow.document, 249 template: this._currentDocument.fileTemplate,
249 head: this._currentDocument.model.views.design.iframe.contentWindow.document.head, 250 document: this._currentDocument.model.views.design.iframe.contentWindow.document,
250 body: this._currentDocument.model.views.design.iframe.contentWindow.document.body, 251 head: this._currentDocument.model.views.design.iframe.contentWindow.document.head,
251 mjsTemplateCreator: this._currentDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator 252 body: this._currentDocument.model.views.design.iframe.contentWindow.document.body,
252 }); 253 mjsTemplateCreator: this._currentDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator
254 }
255 } else if (view === 'design') {
256 doc = this._currentDocument.model.views.code.textArea.value;
257 }
258 //Reloading the document from changes made
259 this._currentDocument.reloadView(view, this.fileTemplate, doc);
253 } 260 }
254 } 261 }
255 }, 262 },
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 81a8912b..a59f5848 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -156,7 +156,7 @@ exports.HtmlDocument = Montage.create(Component, {
156 //Showing design iFrame 156 //Showing design iFrame
157 this.model.views.design.show(); 157 this.model.views.design.show();
158 this.model.views.design.iframe.style.opacity = 0; 158 this.model.views.design.iframe.style.opacity = 0;
159 this.model.views.design.content = this.model.file.content; 159 this.model.views.design.content = this.application.ninja.ioMediator.tmplt.parseHtmlToNinjaTemplate(doc);
160 //TODO: Improve reference (probably through binding values) 160 //TODO: Improve reference (probably through binding values)
161 this.model.views.design._webGlHelper = this.model.webGlHelper; 161 this.model.views.design._webGlHelper = this.model.webGlHelper;
162 //Rendering design view, using observers to know when template is ready 162 //Rendering design view, using observers to know when template is ready