diff options
author | Jose Antonio Marquez | 2012-06-15 15:16:42 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-06-15 15:16:42 -0700 |
commit | 616b31a644ee221edcbc19f821b2194e8edf9fad (patch) | |
tree | 48c76c16e73ac992298a34792062f177b81718d1 | |
parent | 473f5941ad518f6efe69d3924734c2cd434316db (diff) | |
parent | e570fc8518cf03dd03c15982edcf17c5ba0a293d (diff) | |
download | ninja-616b31a644ee221edcbc19f821b2194e8edf9fad.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into FileIO
-rwxr-xr-x | js/document/mediators/template.js | 29 | ||||
-rwxr-xr-x | js/document/views/design.js | 11 |
2 files changed, 27 insertions, 13 deletions
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index e770e07f..c5b46c3a 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js | |||
@@ -146,13 +146,28 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
146 | } | 146 | } |
147 | } | 147 | } |
148 | // | 148 | // |
149 | if (template.body && template.body.getAttribute('data-ninja-style') !== null) { | 149 | if(template.template) { |
150 | template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); | 150 | // |
151 | template.file.content.document.body.removeAttribute('data-ninja-style'); | 151 | // TODO - Need to handle banner and animation templates. |
152 | } else if (template.body && template.body.getAttribute('data-ninja-style') === null) { | 152 | //Copying attributes to maintain same properties as <ninja-content> |
153 | template.file.content.document.body.removeAttribute('style'); | 153 | var ninjaContentTagMem = template.document.getElementsByTagName('ninja-content')[0], ninjaContentTagDoc = template.file.content.document.getElementsByTagName('ninja-content')[0]; |
154 | template.file.content.document.body.removeAttribute('data-ninja-style'); | 154 | if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') !== null) { |
155 | } | 155 | ninjaContentTagDoc.setAttribute('style', ninjaContentTagMem.getAttribute('data-ninja-style')); |
156 | ninjaContentTagDoc.removeAttribute('data-ninja-style'); | ||
157 | } else if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') === null) { | ||
158 | ninjaContentTagDoc.removeAttribute('style'); | ||
159 | ninjaContentTagDoc.removeAttribute('data-ninja-style'); | ||
160 | } | ||
161 | } else { | ||
162 | if (template.body && template.body.getAttribute('data-ninja-style') !== null) { | ||
163 | template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); | ||
164 | template.file.content.document.body.removeAttribute('data-ninja-style'); | ||
165 | } else if (template.body && template.body.getAttribute('data-ninja-style') === null) { | ||
166 | template.file.content.document.body.removeAttribute('style'); | ||
167 | template.file.content.document.body.removeAttribute('data-ninja-style'); | ||
168 | } | ||
169 | } | ||
170 | |||
156 | wipeAttributes(template.file.content.document.head); | 171 | wipeAttributes(template.file.content.document.head); |
157 | //Copying attributes to maintain same properties as the <head> | 172 | //Copying attributes to maintain same properties as the <head> |
158 | for (var m in template.document.head.attributes) { | 173 | for (var m in template.document.head.attributes) { |
diff --git a/js/document/views/design.js b/js/document/views/design.js index 325259ea..44c61617 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -281,7 +281,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
281 | this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); | 281 | this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); |
282 | //Getting style and link tags in document | 282 | //Getting style and link tags in document |
283 | var htags = this.document.getElementsByTagName('html'), | 283 | var htags = this.document.getElementsByTagName('html'), |
284 | btags = this.document.getElementsByTagName('body'), | ||
285 | userStyles, | 284 | userStyles, |
286 | stags = this.document.getElementsByTagName('style'), | 285 | stags = this.document.getElementsByTagName('style'), |
287 | ltags = this.document.getElementsByTagName('link'), i, orgNodes, | 286 | ltags = this.document.getElementsByTagName('link'), i, orgNodes, |
@@ -339,18 +338,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
339 | if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); | 338 | if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); |
340 | } | 339 | } |
341 | 340 | ||
342 | // Save initial HTML and Body style attributes so we don't override them on save | 341 | // Save initial HTML and Body/ninja-content style attributes so we don't override them on save |
343 | if(htags.length) { | 342 | if(htags.length) { |
344 | if(userStyles = htags[0].getAttribute('style')) { | 343 | if(userStyles = htags[0].getAttribute('style')) { |
345 | htags[0].setAttribute('data-ninja-style', userStyles); | 344 | htags[0].setAttribute('data-ninja-style', userStyles); |
346 | } | 345 | } |
347 | } | 346 | } |
348 | if(btags.length) { | 347 | if(this.documentRoot) { |
349 | if(userStyles = btags[0].getAttribute('style')) { | 348 | if(userStyles = this.documentRoot.getAttribute('style')) { |
350 | btags[0].setAttribute('data-ninja-style', userStyles); | 349 | this.documentRoot.setAttribute('data-ninja-style', userStyles); |
351 | } | 350 | } |
352 | } | 351 | } |
353 | //Makign callback if specified | 352 | //Making callback if specified |
354 | if (this._callback) this._callback(); | 353 | if (this._callback) this._callback(); |
355 | } | 354 | } |
356 | }, | 355 | }, |