aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-05-09 18:12:48 -0700
committerNivesh Rajbhandari2012-05-09 18:12:48 -0700
commit9ff89d41048d056ddab4c15b4e9e74bc5417c883 (patch)
tree980a420079b6b9fbd6914c1ece7c67e787ed94b6
parentf8c467bd268e10d4f07136ca932c6eaffc94bc12 (diff)
downloadninja-9ff89d41048d056ddab4c15b4e9e74bc5417c883.tar.gz
Adding support to save body's css styles on preview.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rwxr-xr-xjs/controllers/document-controller.js33
-rwxr-xr-xjs/io/templates/files/html.txt4
2 files changed, 33 insertions, 4 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 17ae8cc3..682bd6a6 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -498,6 +498,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
498 498
499 this.webTemplate = false; 499 this.webTemplate = false;
500 500
501 this._initializeBodyStyles();
501 NJevent("onOpenDocument", doc); 502 NJevent("onOpenDocument", doc);
502 503
503 this.application.ninja.stage.stageView.showCodeViewBar(false); 504 this.application.ninja.stage.stageView.showCodeViewBar(false);
@@ -645,5 +646,37 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
645 value:function(){ 646 value:function(){
646 this.activeDocument.needsSave = true; 647 this.activeDocument.needsSave = true;
647 } 648 }
649 },
650
651 _initializeBodyStyles: {
652 value: function() {
653 var sc = this.application.ninja.stylesController,
654 docRoot = this.application.ninja.currentDocument.documentRoot,
655 styles = {},
656 needsRule = false,
657 rule;
658
659 if(sc.getElementStyle(docRoot, "width", false, false) == null) {
660 styles['width'] = '100%';
661 needsRule = true;
662 }
663 if(sc.getElementStyle(docRoot, "height", false, false) == null) {
664 styles['height'] = '100%';
665 needsRule = true;
666 }
667 if(sc.getElementStyle(docRoot, "-webkit-transform", false, false) == null) {
668 styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
669 needsRule = true;
670 }
671 if(sc.getElementStyle(docRoot, "-webkit-transform-style", false, false) == null) {
672 styles['-webkit-transform-style'] = 'preserve-3d';
673 needsRule = true;
674 }
675
676 if(needsRule) {
677 rule = sc.addRule('body{}');
678 sc.setStyles(rule, styles);
679 }
680 }
648 } 681 }
649}); 682});
diff --git a/js/io/templates/files/html.txt b/js/io/templates/files/html.txt
index 5a9010cf..3449ae39 100755
--- a/js/io/templates/files/html.txt
+++ b/js/io/templates/files/html.txt
@@ -10,10 +10,6 @@
10 <meta name="generator" content="Motorola Mobility Ninja"> 10 <meta name="generator" content="Motorola Mobility Ninja">
11 11
12 <style type="text/css"> 12 <style type="text/css">
13 html, body {
14 width: 100%;
15 height: 100%;
16 }
17 </style> 13 </style>
18 14
19 </head> 15 </head>