aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-09 23:30:33 -0700
committerValerio Virgillito2012-05-09 23:30:33 -0700
commit25e50eed8afbf86606ec5614194dc34f154feecb (patch)
treeb3826880c843435cdaf2d8981400909127466313 /js/controllers
parent2e9a6b271439d934439514f6386424567853f93c (diff)
parent454ba956b0d6f48d37a5ad3f50eb00aaaaa7271b (diff)
downloadninja-25e50eed8afbf86606ec5614194dc34f154feecb.tar.gz
Merge pull request #208 from mqg734/Dom-Architecture
Adding support to save body's css styles on preview.
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js33
1 files changed, 33 insertions, 0 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});