aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-14 16:46:01 -0700
committerJose Antonio Marquez2012-06-14 16:46:01 -0700
commit0d6693f1a6af1303e99ee72794eb879be8665610 (patch)
treef5d1ac68119b59119f44b602c6f8db2aafc2ec03 /js
parent358192a29533b34fa4938d59825f29bfd8d02b14 (diff)
downloadninja-0d6693f1a6af1303e99ee72794eb879be8665610.tar.gz
Adding clean up for ninja style attributes.
I/O step in template.
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/mediators/template.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index 50fad1c3..0d48355f 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -155,6 +155,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
155 //Copying attributes to maintain same properties as the <html> 155 //Copying attributes to maintain same properties as the <html>
156 var htmlTagMem = template.document.getElementsByTagName('html')[0], htmlTagDoc = template.file.content.document.getElementsByTagName('html')[0]; 156 var htmlTagMem = template.document.getElementsByTagName('html')[0], htmlTagDoc = template.file.content.document.getElementsByTagName('html')[0];
157 wipeAttributes(htmlTagDoc); 157 wipeAttributes(htmlTagDoc);
158 //
158 for (var m in htmlTagMem.attributes) { 159 for (var m in htmlTagMem.attributes) {
159 if (htmlTagMem.attributes[m].value) { 160 if (htmlTagMem.attributes[m].value) {
160 if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) { 161 if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) {
@@ -162,16 +163,33 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
162 } 163 }
163 } 164 }
164 } 165 }
166 //
167 if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') !== null) {
168 htmlTagDoc.setAttribute('style', htmlTagMem.getAttribute('data-ninja-style'));
169 htmlTagDoc.removeAttribute('data-ninja-style');
170 } else if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') === null) {
171 htmlTagDoc.removeAttribute('style');
172 htmlTagDoc.removeAttribute('data-ninja-style');
173 }
165 //Getting list of current nodes (Ninja DOM) 174 //Getting list of current nodes (Ninja DOM)
166 presentNodes = template.file.content.document.getElementsByTagName('*'); 175 presentNodes = template.file.content.document.getElementsByTagName('*');
167 //Looping through nodes to determine origin and removing if not inserted by Ninja 176 //Looping through nodes to determine origin and removing if not inserted by Ninja
168 for (var n in presentNodes) { 177 for (var n in presentNodes) {
178 //
169 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) { 179 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) {
170 toremovetags.push(presentNodes[n]); 180 toremovetags.push(presentNodes[n]);
171 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) { 181 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) {
172 //Removing attribute 182 //Removing attribute
173 presentNodes[n].removeAttribute('data-ninja-node'); 183 presentNodes[n].removeAttribute('data-ninja-node');
174 } 184 }
185 //
186 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') !== null) {
187 presentNodes[n].setAttribute('style', presentNodes[n].getAttribute('data-ninja-style'));
188 presentNodes[n].removeAttribute('data-ninja-style');
189 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') === null) {
190 presentNodes[n].removeAttribute('style');
191 presentNodes[n].removeAttribute('data-ninja-style');
192 }
175 } 193 }
176 //Getting all CSS (style or link) tags 194 //Getting all CSS (style or link) tags
177 var styletags = template.file.content.document.getElementsByTagName('style'), 195 var styletags = template.file.content.document.getElementsByTagName('style'),