aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/elements/body-controller.js3
-rwxr-xr-xjs/document/mediators/template.js18
-rwxr-xr-xjs/document/views/design.js20
3 files changed, 37 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, {
13 set3DProperties: { 13 set3DProperties: {
14 value: function(el, props, update3DModel) { 14 value: function(el, props, update3DModel) {
15 var dist = props["dist"], mat = props["mat"]; 15 var dist = props["dist"], mat = props["mat"];
16 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); 16// this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")");
17 el.style["-webkit-transform"] = "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")";
17 18
18 el.elementModel.props3D.matrix3d = mat; 19 el.elementModel.props3D.matrix3d = mat;
19 el.elementModel.props3D.perspectiveDist = dist; 20 el.elementModel.props3D.perspectiveDist = dist;
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index 50fad1c3..e770e07f 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -145,6 +145,14 @@ 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.body && template.body.getAttribute('data-ninja-style') !== null) {
150 template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style'));
151 template.file.content.document.body.removeAttribute('data-ninja-style');
152 } else if (template.body && template.body.getAttribute('data-ninja-style') === null) {
153 template.file.content.document.body.removeAttribute('style');
154 template.file.content.document.body.removeAttribute('data-ninja-style');
155 }
148 wipeAttributes(template.file.content.document.head); 156 wipeAttributes(template.file.content.document.head);
149 //Copying attributes to maintain same properties as the <head> 157 //Copying attributes to maintain same properties as the <head>
150 for (var m in template.document.head.attributes) { 158 for (var m in template.document.head.attributes) {
@@ -155,6 +163,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
155 //Copying attributes to maintain same properties as the <html> 163 //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]; 164 var htmlTagMem = template.document.getElementsByTagName('html')[0], htmlTagDoc = template.file.content.document.getElementsByTagName('html')[0];
157 wipeAttributes(htmlTagDoc); 165 wipeAttributes(htmlTagDoc);
166 //
158 for (var m in htmlTagMem.attributes) { 167 for (var m in htmlTagMem.attributes) {
159 if (htmlTagMem.attributes[m].value) { 168 if (htmlTagMem.attributes[m].value) {
160 if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) { 169 if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) {
@@ -162,10 +171,19 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
162 } 171 }
163 } 172 }
164 } 173 }
174 //
175 if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') !== null) {
176 htmlTagDoc.setAttribute('style', htmlTagMem.getAttribute('data-ninja-style'));
177 htmlTagDoc.removeAttribute('data-ninja-style');
178 } else if (htmlTagMem && htmlTagMem.getAttribute('data-ninja-style') === null) {
179 htmlTagDoc.removeAttribute('style');
180 htmlTagDoc.removeAttribute('data-ninja-style');
181 }
165 //Getting list of current nodes (Ninja DOM) 182 //Getting list of current nodes (Ninja DOM)
166 presentNodes = template.file.content.document.getElementsByTagName('*'); 183 presentNodes = template.file.content.document.getElementsByTagName('*');
167 //Looping through nodes to determine origin and removing if not inserted by Ninja 184 //Looping through nodes to determine origin and removing if not inserted by Ninja
168 for (var n in presentNodes) { 185 for (var n in presentNodes) {
186 //
169 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) { 187 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) {
170 toremovetags.push(presentNodes[n]); 188 toremovetags.push(presentNodes[n]);
171 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) { 189 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) {
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, {
280 //Removing loading container (should be removed) 280 //Removing loading container (should be removed)
281 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); 281 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]);
282 //Getting style and link tags in document 282 //Getting style and link tags in document
283 var stags = this.document.getElementsByTagName('style'), 283 var htags = this.document.getElementsByTagName('html'),
284 btags = this.document.getElementsByTagName('body'),
285 userStyles,
286 stags = this.document.getElementsByTagName('style'),
284 ltags = this.document.getElementsByTagName('link'), i, orgNodes, 287 ltags = this.document.getElementsByTagName('link'), i, orgNodes,
285 scripttags = this.document.getElementsByTagName('script'); 288 scripttags = this.document.getElementsByTagName('script');
286 //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) 289 //Temporarily checking for disabled special case (we must enabled for Ninja to access styles)
@@ -319,7 +322,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
319 //Else there is not data to parse 322 //Else there is not data to parse
320 if(this._viewCallback) { 323 if(this._viewCallback) {
321 this._viewCallback.viewCallback.call(this._viewCallback.context); 324 this._viewCallback.viewCallback.call(this._viewCallback.context);
322 } 325 }
323 } 326 }
324 //TODO: Verify appropiate location for this operation 327 //TODO: Verify appropiate location for this operation
325 if (this._template && this._template.type === 'banner') { 328 if (this._template && this._template.type === 'banner') {
@@ -335,7 +338,18 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
335 for (var n in orgNodes) { 338 for (var n in orgNodes) {
336 if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); 339 if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true');
337 } 340 }
338 341
342 // Save initial HTML and Body style attributes so we don't override them on save
343 if(htags.length) {
344 if(userStyles = htags[0].getAttribute('style')) {
345 htags[0].setAttribute('data-ninja-style', userStyles);
346 }
347 }
348 if(btags.length) {
349 if(userStyles = btags[0].getAttribute('style')) {
350 btags[0].setAttribute('data-ninja-style', userStyles);
351 }
352 }
339 //Makign callback if specified 353 //Makign callback if specified
340 if (this._callback) this._callback(); 354 if (this._callback) this._callback();
341 } 355 }