aboutsummaryrefslogtreecommitdiff
path: root/js/document/mediators/template.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-06-19 00:45:26 -0700
committerArmen Kesablyan2012-06-19 00:45:26 -0700
commitc59eb371559a3061ce53223e249ca97daace5968 (patch)
treef9540e26c0f273d35f92010605da65dd85bbe70c /js/document/mediators/template.js
parent0f040acabfb7a4bf3138debec5aff869487ceb11 (diff)
parent918a4f5870e972b6e4e301c3237e065a1ffd26f5 (diff)
downloadninja-c59eb371559a3061ce53223e249ca97daace5968.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'js/document/mediators/template.js')
-rwxr-xr-xjs/document/mediators/template.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index 50fad1c3..c5b46c3a 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -145,6 +145,29 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
145 template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); 145 template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value);
146 } 146 }
147 } 147 }
148 //
149 if(template.template) {
150 //
151 // TODO - Need to handle banner and animation templates.
152 //Copying attributes to maintain same properties as <ninja-content>
153 var ninjaContentTagMem = template.document.getElementsByTagName('ninja-content')[0], ninjaContentTagDoc = template.file.content.document.getElementsByTagName('ninja-content')[0];
154 if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') !== null) {
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
148 wipeAttributes(template.file.content.document.head); 171 wipeAttributes(template.file.content.document.head);
149 //Copying attributes to maintain same properties as the <head> 172 //Copying attributes to maintain same properties as the <head>
150 for (var m in template.document.head.attributes) { 173 for (var m in template.document.head.attributes) {
@@ -155,6 +178,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
155 //Copying attributes to maintain same properties as the <html> 178 //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]; 179 var htmlTagMem = template.document.getElementsByTagName('html')[0], htmlTagDoc = template.file.content.document.getElementsByTagName('html')[0];
157 wipeAttributes(htmlTagDoc); 180 wipeAttributes(htmlTagDoc);
181 //
158 for (var m in htmlTagMem.attributes) { 182 for (var m in htmlTagMem.attributes) {
159 if (htmlTagMem.attributes[m].value) { 183 if (htmlTagMem.attributes[m].value) {
160 if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) { 184 if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) {
@@ -162,10 +186,19 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
162 } 186 }
163 } 187 }
164 } 188 }
189 //
190 if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') !== null) {
191 htmlTagDoc.setAttribute('style', htmlTagMem.getAttribute('data-ninja-style'));
192 htmlTagDoc.removeAttribute('data-ninja-style');
193 } else if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') === null) {
194 htmlTagDoc.removeAttribute('style');
195 htmlTagDoc.removeAttribute('data-ninja-style');
196 }
165 //Getting list of current nodes (Ninja DOM) 197 //Getting list of current nodes (Ninja DOM)
166 presentNodes = template.file.content.document.getElementsByTagName('*'); 198 presentNodes = template.file.content.document.getElementsByTagName('*');
167 //Looping through nodes to determine origin and removing if not inserted by Ninja 199 //Looping through nodes to determine origin and removing if not inserted by Ninja
168 for (var n in presentNodes) { 200 for (var n in presentNodes) {
201 //
169 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) { 202 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) {
170 toremovetags.push(presentNodes[n]); 203 toremovetags.push(presentNodes[n]);
171 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) { 204 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) {