From 9185145b3ab37070c7f32befaec1ab38486745b3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 14 Jun 2012 16:00:53 -0700 Subject: Save user's html and body styles and inline body styles for 3d so they don't get saved out with the document. This still requires some changes by Jose. Signed-off-by: Nivesh Rajbhandari --- js/document/views/design.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'js/document/views') diff --git a/js/document/views/design.js b/js/document/views/design.js index 1a5b071e..325259ea 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -280,7 +280,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //Removing loading container (should be removed) this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); //Getting style and link tags in document - var stags = this.document.getElementsByTagName('style'), + var htags = this.document.getElementsByTagName('html'), + btags = this.document.getElementsByTagName('body'), + userStyles, + stags = this.document.getElementsByTagName('style'), ltags = this.document.getElementsByTagName('link'), i, orgNodes, scripttags = this.document.getElementsByTagName('script'); //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) @@ -319,7 +322,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //Else there is not data to parse if(this._viewCallback) { this._viewCallback.viewCallback.call(this._viewCallback.context); - } + } } //TODO: Verify appropiate location for this operation if (this._template && this._template.type === 'banner') { @@ -335,7 +338,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { for (var n in orgNodes) { if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); } - + + // Save initial HTML and Body style attributes so we don't override them on save + if(htags.length) { + if(userStyles = htags[0].getAttribute('style')) { + htags[0].setAttribute('data-ninja-style', userStyles); + } + } + if(btags.length) { + if(userStyles = btags[0].getAttribute('style')) { + btags[0].setAttribute('data-ninja-style', userStyles); + } + } //Makign callback if specified if (this._callback) this._callback(); } -- 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 --- js/document/views/design.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'js/document/views') 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, { this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); //Getting style and link tags in document var htags = this.document.getElementsByTagName('html'), - btags = this.document.getElementsByTagName('body'), userStyles, stags = this.document.getElementsByTagName('style'), ltags = this.document.getElementsByTagName('link'), i, orgNodes, @@ -339,18 +338,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); } - // Save initial HTML and Body style attributes so we don't override them on save + // Save initial HTML and Body/ninja-content style attributes so we don't override them on save if(htags.length) { if(userStyles = htags[0].getAttribute('style')) { htags[0].setAttribute('data-ninja-style', userStyles); } } - if(btags.length) { - if(userStyles = btags[0].getAttribute('style')) { - btags[0].setAttribute('data-ninja-style', userStyles); + if(this.documentRoot) { + if(userStyles = this.documentRoot.getAttribute('style')) { + this.documentRoot.setAttribute('data-ninja-style', userStyles); } } - //Makign callback if specified + //Making callback if specified if (this._callback) this._callback(); } }, -- cgit v1.2.3