aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-08 12:59:13 -0700
committerValerio Virgillito2012-06-08 12:59:13 -0700
commita50814178be2775892ed999c28041d8e81291e22 (patch)
tree309af98cd840d3841be74c32e87c30fa8739ff1e /js
parent4070475b8da7257eca629be7288bf7a31d5e384e (diff)
parentd14249dd2d76e9eb8d14733c10393d36bd2ea8ee (diff)
downloadninja-a50814178be2775892ed999c28041d8e81291e22.tar.gz
Merge branch 'refs/heads/master' into timeline-resizer-fix
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/body-controller.js5
-rwxr-xr-xjs/controllers/elements/controller-factory.js4
-rwxr-xr-xjs/controllers/styles-controller.js4
-rwxr-xr-xjs/document/mediators/template.js98
-rwxr-xr-xjs/document/models/base.js41
-rwxr-xr-xjs/document/models/html.js2
-rwxr-xr-xjs/document/views/design.js14
-rw-r--r--js/mediators/io-mediator.js10
-rwxr-xr-xjs/models/element-model.js6
-rwxr-xr-xjs/panels/properties.reel/properties.js4
-rwxr-xr-xjs/panels/properties.reel/sections/custom.reel/custom.js2
11 files changed, 141 insertions, 49 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 9c427c62..0dc11b82 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -30,7 +30,8 @@ exports.BodyController = Montage.create(ElementController, {
30 value: function(el, p) { 30 value: function(el, p) {
31 switch(p) { 31 switch(p) {
32 case "background" : 32 case "background" :
33 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", false, true)); 33 case "background-color":
34 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color"));
34 case "border": 35 case "border":
35 return 0; 36 return 0;
36 case "height": 37 case "height":
@@ -47,8 +48,8 @@ exports.BodyController = Montage.create(ElementController, {
47 setProperty: { 48 setProperty: {
48 value: function(el, p, value) { 49 value: function(el, p, value) {
49 switch(p) { 50 switch(p) {
50 case "body-background":
51 case "background": 51 case "background":
52 case "background-color":
52 this.application.ninja.stylesController.setElementStyle(el, "background-color", value); 53 this.application.ninja.stylesController.setElementStyle(el, "background-color", value);
53 break; 54 break;
54 case "overflow": 55 case "overflow":
diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js
index 3ac3fe14..2d2a5cd1 100755
--- a/js/controllers/elements/controller-factory.js
+++ b/js/controllers/elements/controller-factory.js
@@ -8,7 +8,6 @@ var Montage = require("montage/core/core").Montage;
8 8
9var BodyController = require("js/controllers/elements/body-controller").BodyController, 9var BodyController = require("js/controllers/elements/body-controller").BodyController,
10 BlockController = require("js/controllers/elements/block-controller").BlockController, 10 BlockController = require("js/controllers/elements/block-controller").BlockController,
11 StageController = require("js/controllers/elements/stage-controller").StageController,
12 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, 11 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController,
13 ImageController = require("js/controllers/elements/image-controller").ImageController, 12 ImageController = require("js/controllers/elements/image-controller").ImageController,
14 VideoController = require("js/controllers/elements/video-controller").VideoController, 13 VideoController = require("js/controllers/elements/video-controller").VideoController,
@@ -27,7 +26,8 @@ exports.ControllerFactory = Montage.create(Montage, {
27 if(value.indexOf("block") !== -1) { 26 if(value.indexOf("block") !== -1) {
28 return BlockController; 27 return BlockController;
29 } else if(value.indexOf("stage") !== -1) { 28 } else if(value.indexOf("stage") !== -1) {
30 return StageController; 29// return StageController;
30 alert("Calling the stage controller. Should not be calling this object");
31 } else if(value.indexOf("body") !== -1) { 31 } else if(value.indexOf("body") !== -1) {
32 return BodyController; 32 return BodyController;
33 } else if(value.indexOf("shape") !== -1) { 33 } else if(value.indexOf("shape") !== -1) {
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 83722184..a25a05df 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -154,6 +154,10 @@ var stylesController = exports.StylesController = Montage.create(Component, {
154 styles['-webkit-transform-style'] = 'preserve-3d'; 154 styles['-webkit-transform-style'] = 'preserve-3d';
155 needsRule = true; 155 needsRule = true;
156 } 156 }
157 if(this.getElementStyle(this.currentDocument.model.documentRoot, "background-color", false, false) == null) {
158 styles['background-color'] = "transparent";
159 needsRule = true;
160 }
157 161
158 if(needsRule) { 162 if(needsRule) {
159 rule = this.addRule('.ninja-body{}'); 163 rule = this.addRule('.ninja-body{}');
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index 068a1f48..e04c16d9 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -8,7 +8,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
8// 8//
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component, 10 Component = require("montage/ui/component").Component,
11 TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator; 11 TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator,
12 ClassUuid = require("js/components/core/class-uuid").ClassUuid;
12//////////////////////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////////////////////
13// 14//
14exports.TemplateDocumentMediator = Montage.create(Component, { 15exports.TemplateDocumentMediator = Montage.create(Component, {
@@ -83,9 +84,22 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
83 parseHtmlToNinjaTemplate: { 84 parseHtmlToNinjaTemplate: {
84 value: function (html) { 85 value: function (html) {
85 //Creating temp object to mimic HTML 86 //Creating temp object to mimic HTML
86 var doc = window.document.implementation.createHTMLDocument(), template; 87 var doc = window.document.implementation.createHTMLDocument(), template, docHtmlTag,
88 hackHtml = document.createElement('html'), hackTag;
87 //Setting content to temp 89 //Setting content to temp
88 doc.getElementsByTagName('html')[0].innerHTML = html; 90 doc.getElementsByTagName('html')[0].innerHTML = html;
91 //TODO: Improve this, very bad way of copying attributes (in a pinch to get it working)
92 hackHtml.innerHTML = html.replace(/html/gi, 'ninjahtmlhack');
93 hackTag = hackHtml.getElementsByTagName('ninjahtmlhack')[0];
94 docHtmlTag = doc.getElementsByTagName('html')[0];
95 //Looping through the attributes to copy them
96 for (var m in hackTag.attributes) {
97 if (hackTag.attributes[m].value) {
98 docHtmlTag.setAttribute(hackTag.attributes[m].name.replace(/ninjahtmlhack/gi, 'html'), hackTag.attributes[m].value.replace(/ninjahtmlhack/gi, 'html'));
99 }
100 }
101 //Garbage collection
102 hackHtml = hackTag = null;
89 //Creating return object 103 //Creating return object
90 return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; 104 return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc};
91 } 105 }
@@ -93,7 +107,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
93 //////////////////////////////////////////////////////////////////// 107 ////////////////////////////////////////////////////////////////////
94 //TODO: Expand to allow more templates, clean up variables 108 //TODO: Expand to allow more templates, clean up variables
95 parseNinjaTemplateToHtml: { 109 parseNinjaTemplateToHtml: {
96 value: function (template, ninjaWrapper, libCopyCallback) { 110 value: function (saveExternalData, template, ninjaWrapper, libCopyCallback) {
97 //TODO: Improve reference for rootUrl 111 //TODO: Improve reference for rootUrl
98 var regexRootUrl, 112 var regexRootUrl,
99 rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), 113 rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])),
@@ -116,20 +130,36 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
116 template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); 130 template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, '');
117 template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); 131 template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, '');
118 } 132 }
133 //Removes all attributes from node
134 function wipeAttributes (node) {
135 for (var f in node.attributes) {
136 node.removeAttribute(node.attributes[f].name);
137 }
138 }
119 //Copying attributes to maintain same properties as the <body> 139 //Copying attributes to maintain same properties as the <body>
140 wipeAttributes(template.file.content.document.body);
120 for (var n in template.body.attributes) { 141 for (var n in template.body.attributes) {
121 if (template.body.attributes[n].value) { 142 if (template.body.attributes[n].value) {
122 //
123 template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); 143 template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value);
124 } 144 }
125 } 145 }
126 146 wipeAttributes(template.file.content.document.head);
127 147 //Copying attributes to maintain same properties as the <head>
128 148 for (var m in template.document.head.attributes) {
129 //TODO: Add attribute copying for <HEAD> and <HTML> 149 if (template.document.head.attributes[m].value) {
130 150 template.file.content.document.head.setAttribute(template.document.head.attributes[m].name, template.document.head.attributes[m].value);
131 151 }
132 152 }
153 //Copying attributes to maintain same properties as the <html>
154 var htmlTagMem = template.document.getElementsByTagName('html')[0], htmlTagDoc = template.file.content.document.getElementsByTagName('html')[0];
155 wipeAttributes(htmlTagDoc);
156 for (var m in htmlTagMem.attributes) {
157 if (htmlTagMem.attributes[m].value) {
158 if (htmlTagMem.attributes[m].value.replace(/montage-app-bootstrapping/gi, '').length>0) {
159 htmlTagDoc.setAttribute(htmlTagMem.attributes[m].name, htmlTagMem.attributes[m].value.replace(/ montage-app-bootstrapping/gi, ''));
160 }
161 }
162 }
133 //Getting list of current nodes (Ninja DOM) 163 //Getting list of current nodes (Ninja DOM)
134 presentNodes = template.file.content.document.getElementsByTagName('*'); 164 presentNodes = template.file.content.document.getElementsByTagName('*');
135 //Looping through nodes to determine origin and removing if not inserted by Ninja 165 //Looping through nodes to determine origin and removing if not inserted by Ninja
@@ -328,7 +358,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
328 358
329 359
330 360
331 //TODO: Make proper webGL/Canvas method 361
332 362
333 // 363 //
334 var webgltag, webgllibtag, webglrdgetag, mjstag, mjslibtag, matchingtags = [], 364 var webgltag, webgllibtag, webglrdgetag, mjstag, mjslibtag, matchingtags = [],
@@ -357,19 +387,33 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
357 } 387 }
358 } 388 }
359 } 389 }
390
391
392
393
394 //TODO: Make proper webGL/Canvas method
395
396