From c00ba985a16ca0a229089243c6e04280cbff758c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 6 Aug 2012 10:29:47 -0700 Subject: Fix: Added support for code/design view switching for banner templates Fixed a bug with toggling views on banner templates, I was not handling meta data correctly nor parsing the document between the switching. This is a temp fix, should be better implement when dynamic sizing is added to the templates. --- js/components/layout/document-bar.reel/document-bar.js | 4 ++-- js/document/document-html.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 098e9e68..88c4a24b 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js @@ -246,7 +246,7 @@ exports.DocumentBar = Montage.create(Component, { file: this._currentDocument.model.file, webgl: this._currentDocument.model.webGlHelper.glData, styles: this._currentDocument.model.getStyleSheets(), - template: this._currentDocument.fileTemplate, + template: this._currentDocument.model.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, @@ -256,7 +256,7 @@ exports.DocumentBar = Montage.create(Component, { doc = this._currentDocument.model.views.code.textArea.value; } //Reloading the document from changes made - this._currentDocument.reloadView(view, this.fileTemplate, doc); + this._currentDocument.reloadView(view, doc.template, doc); } } }, diff --git a/js/document/document-html.js b/js/document/document-html.js index f3163339..d610c69d 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -157,6 +157,14 @@ exports.HtmlDocument = Montage.create(Component, { this.model.views.design.show(); this.model.views.design.iframe.style.opacity = 0; this.model.views.design.content = this.application.ninja.ioMediator.tmplt.parseHtmlToNinjaTemplate(doc); + // + if (!template) { + if (this.model.views.design.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { + dimensions = (this.model.views.design.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x'); + dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])}; + template = {type: 'banner', size: dimensions}; + } + } //TODO: Improve reference (probably through binding values) this.model.views.design._webGlHelper = this.model.webGlHelper; //Rendering design view, using observers to know when template is ready -- cgit v1.2.3