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 --- js/document/mediators/template.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'js/document/mediators') 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, { } } // - 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'); - } + if(template.template) { + // + // TODO - Need to handle banner and animation templates. + //Copying attributes to maintain same properties as + var ninjaContentTagMem = template.document.getElementsByTagName('ninja-content')[0], ninjaContentTagDoc = template.file.content.document.getElementsByTagName('ninja-content')[0]; + if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') !== null) { + ninjaContentTagDoc.setAttribute('style', ninjaContentTagMem.getAttribute('data-ninja-style')); + ninjaContentTagDoc.removeAttribute('data-ninja-style'); + } else if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') === null) { + ninjaContentTagDoc.removeAttribute('style'); + ninjaContentTagDoc.removeAttribute('data-ninja-style'); + } + } else { + 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) { -- cgit v1.2.3