From 9ff89d41048d056ddab4c15b4e9e74bc5417c883 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 9 May 2012 18:12:48 -0700 Subject: Adding support to save body's css styles on preview. Signed-off-by: Nivesh Rajbhandari --- js/controllers/document-controller.js | 33 +++++++++++++++++++++++++++++++++ js/io/templates/files/html.txt | 4 ---- 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, this.webTemplate = false; + this._initializeBodyStyles(); NJevent("onOpenDocument", doc); this.application.ninja.stage.stageView.showCodeViewBar(false); @@ -645,5 +646,37 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value:function(){ this.activeDocument.needsSave = true; } + }, + + _initializeBodyStyles: { + value: function() { + var sc = this.application.ninja.stylesController, + docRoot = this.application.ninja.currentDocument.documentRoot, + styles = {}, + needsRule = false, + rule; + + if(sc.getElementStyle(docRoot, "width", false, false) == null) { + styles['width'] = '100%'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "height", false, false) == null) { + styles['height'] = '100%'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "-webkit-transform", false, false) == null) { + styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "-webkit-transform-style", false, false) == null) { + styles['-webkit-transform-style'] = 'preserve-3d'; + needsRule = true; + } + + if(needsRule) { + rule = sc.addRule('body{}'); + sc.setStyles(rule, styles); + } + } } }); 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 @@ -- cgit v1.2.3