From 0d6693f1a6af1303e99ee72794eb879be8665610 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 14 Jun 2012 16:46:01 -0700 Subject: Adding clean up for ninja style attributes. I/O step in template. --- js/document/mediators/template.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/document/mediators') 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, { //Copying attributes to maintain same properties as the var htmlTagMem = template.document.getElementsByTagName('html')[0], htmlTagDoc = template.file.content.document.getElementsByTagName('html')[0]; wipeAttributes(htmlTagDoc); + // for (var m in htmlTagMem.attributes) { if (htmlTagMem.attributes[m].value) { if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) { @@ -162,16 +163,33 @@ exports.TemplateDocumentMediator = Montage.create(Component, { } } } + // + if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') !== null) { + htmlTagDoc.setAttribute('style', htmlTagMem.getAttribute('data-ninja-style')); + htmlTagDoc.removeAttribute('data-ninja-style'); + } else if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') === null) { + htmlTagDoc.removeAttribute('style'); + htmlTagDoc.removeAttribute('data-ninja-style'); + } //Getting list of current nodes (Ninja DOM) presentNodes = template.file.content.document.getElementsByTagName('*'); //Looping through nodes to determine origin and removing if not inserted by Ninja for (var n in presentNodes) { + // if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) { toremovetags.push(presentNodes[n]); } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) { //Removing attribute presentNodes[n].removeAttribute('data-ninja-node'); } + // + if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') !== null) { + presentNodes[n].setAttribute('style', presentNodes[n].getAttribute('data-ninja-style')); + presentNodes[n].removeAttribute('data-ninja-style'); + } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') === null) { + presentNodes[n].removeAttribute('style'); + presentNodes[n].removeAttribute('data-ninja-style'); + } } //Getting all CSS (style or link) tags var styletags = template.file.content.document.getElementsByTagName('style'), -- cgit v1.2.3 From b39e13b9a53e6c75f4f9364e686dc90df02b09bb Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 14 Jun 2012 16:54:54 -0700 Subject: Moving location to copy body style attribute Fixes issue with removing styles from other elements. This now only applies to HTML and Body tags --- js/document/mediators/template.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'js/document/mediators') diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index 0d48355f..e770e07f 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js @@ -145,6 +145,14 @@ exports.TemplateDocumentMediator = Montage.create(Component, { template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); } } + // + if (template.body && template.body.getAttribute('data-ninja-style') !== null) { + template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } else if (template.body && template.body.getAttribute('data-ninja-style') === null) { + template.file.content.document.body.removeAttribute('style'); + template.file.content.document.body.removeAttribute('data-ninja-style'); + } wipeAttributes(template.file.content.document.head); //Copying attributes to maintain same properties as the
for (var m in template.document.head.attributes) { @@ -182,14 +190,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { //Removing attribute presentNodes[n].removeAttribute('data-ninja-node'); } - // - if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') !== null) { - presentNodes[n].setAttribute('style', presentNodes[n].getAttribute('data-ninja-style')); - presentNodes[n].removeAttribute('data-ninja-style'); - } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-style') === null) { - presentNodes[n].removeAttribute('style'); - presentNodes[n].removeAttribute('data-ninja-style'); - } } //Getting all CSS (style or link) tags var styletags = template.file.content.document.getElementsByTagName('style'), -- cgit v1.2.3 From 965557ffb8e11918ebc1215738a8a9657a172a84 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 14 Jun 2012 22:11:39 -0700 Subject: Remove ninja's author-time styles for banner and animation templates on publish/save. Missed the banner and animation case in the previous checkin. Signed-off-by: Nivesh Rajbhandari