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 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'js/controllers') 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); + } + } } }); -- cgit v1.2.3