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/controllers/elements/body-controller.js | 3 ++- js/document/views/design.js | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 27989c65..0ca6c417 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -13,7 +13,8 @@ exports.BodyController = Montage.create(ElementController, { set3DProperties: { value: function(el, props, update3DModel) { var dist = props["dist"], mat = props["mat"]; - this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); +// this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); + el.style["-webkit-transform"] = "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"; el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; 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