diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/elements/body-controller.js | 20 | ||||
-rwxr-xr-x | js/document/helpers/url-parser.js | 2 | ||||
-rwxr-xr-x | js/document/mediators/template.js | 9 | ||||
-rwxr-xr-x | js/document/views/design.js | 7 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 32 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 12 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/runtime.js | 6 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 2 | ||||
-rwxr-xr-x | js/io/templates/files/html.txt | 6 |
9 files changed, 84 insertions, 12 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 0b6a5bad..bc4d2e42 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js | |||
@@ -19,6 +19,14 @@ exports.BodyController = Montage.create(ElementController, { | |||
19 | el.elementModel.props3D.matrix3d = mat; | 19 | el.elementModel.props3D.matrix3d = mat; |
20 | el.elementModel.props3D.perspectiveDist = dist; | 20 | el.elementModel.props3D.perspectiveDist = dist; |
21 | 21 | ||
22 | if(this.application.ninja.currentDocument.model.views.design._template) { | ||
23 | if(!MathUtils.isIdentityMatrix(mat)) { | ||
24 | el.parentNode.style.backgroundColor = "transparent"; | ||
25 | } else { | ||
26 | el.parentNode.style.removeProperty("background-color"); | ||
27 | } | ||
28 | } | ||
29 | |||
22 | this.application.ninja.stage.updatedStage = true; | 30 | this.application.ninja.stage.updatedStage = true; |
23 | 31 | ||
24 | if(update3DModel) { | 32 | if(update3DModel) { |
@@ -34,7 +42,11 @@ exports.BodyController = Montage.create(ElementController, { | |||
34 | case "background-image": | 42 | case "background-image": |
35 | return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-image")); | 43 | return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-image")); |
36 | case "background-color": | 44 | case "background-color": |
37 | return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color")); | 45 | if(this.application.ninja.currentDocument.model.views.design._template) { |
46 | return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el.parentNode, "background-color")); | ||
47 | } else { | ||
48 | return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color")); | ||
49 | } | ||
38 | case "border": | 50 | case "border": |
39 | return 0; | 51 | return 0; |
40 | case "height": | 52 | case "height": |
@@ -56,7 +68,11 @@ exports.BodyController = Montage.create(ElementController, { | |||
56 | this.application.ninja.stylesController.setElementStyle(el, "background-image", value); | 68 | this.application.ninja.stylesController.setElementStyle(el, "background-image", value); |
57 | break; | 69 | break; |
58 | case "background-color": | 70 | case "background-color": |
59 | this.application.ninja.stylesController.setElementStyle(el, "background-color", value); | 71 | if(this.application.ninja.currentDocument.model.views.design._template) { |
72 | this.application.ninja.stylesController.setElementStyle(el.parentNode, "background-color", value); | ||
73 | } else { | ||
74 | this.application.ninja.stylesController.setElementStyle(el, "background-color", value); | ||
75 | } | ||
60 | break; | 76 | break; |
61 | case "overflow": | 77 | case "overflow": |
62 | case "width": | 78 | case "width": |
diff --git a/js/document/helpers/url-parser.js b/js/document/helpers/url-parser.js index 5e71d148..7bded27d 100755 --- a/js/document/helpers/url-parser.js +++ b/js/document/helpers/url-parser.js | |||
@@ -53,7 +53,7 @@ exports.UrlParser = Montage.create(Component, { | |||
53 | //Getting file URI (not URL since we must load through I/O API) | 53 | //Getting file URI (not URL since we must load through I/O API) |
54 | var css = {}, file; | 54 | var css = {}, file; |
55 | css.cssUrl = href.split(this.application.ninja.coreIoApi.rootUrl)[1]; | 55 | css.cssUrl = href.split(this.application.ninja.coreIoApi.rootUrl)[1]; |
56 | css.fileUri = this.application.ninja.coreIoApi.cloudData.root + css.cssUrl; | 56 | css.fileUri = this.application.ninja.coreIoApi.cloudData.root + unescape(css.cssUrl); |
57 | //Loading data from CSS file | 57 | //Loading data from CSS file |
58 | file = this.application.ninja.coreIoApi.readFile({uri: css.fileUri}); | 58 | file = this.application.ninja.coreIoApi.readFile({uri: css.fileUri}); |
59 | //Checking for file to be writable on disk | 59 | //Checking for file to be writable on disk |
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index c5b46c3a..f43b1a2c 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js | |||
@@ -158,6 +158,15 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
158 | ninjaContentTagDoc.removeAttribute('style'); | 158 | ninjaContentTagDoc.removeAttribute('style'); |
159 | ninjaContentTagDoc.removeAttribute('data-ninja-style'); | 159 | ninjaContentTagDoc.removeAttribute('data-ninja-style'); |
160 | } | 160 | } |
161 | // TODO - clean up into single method | ||
162 | ninjaContentTagMem = template.document.getElementsByTagName('ninja-viewport')[0], ninjaContentTagDoc = template.file.content.document.getElementsByTagName('ninja-viewport')[0]; | ||
163 | if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') !== null) { | ||
164 | ninjaContentTagDoc.setAttribute('style', ninjaContentTagMem.getAttribute('data-ninja-style')); | ||
165 | ninjaContentTagDoc.removeAttribute('data-ninja-style'); | ||
166 | } else if (ninjaContentTagMem && ninjaContentTagMem.getAttribute('data-ninja-style') === null) { | ||
167 | ninjaContentTagDoc.removeAttribute('style'); | ||
168 | ninjaContentTagDoc.removeAttribute('data-ninja-style'); | ||
169 | } | ||
161 | } else { | 170 | } else { |
162 | if (template.body && template.body.getAttribute('data-ninja-style') !== null) { | 171 | if (template.body && template.body.getAttribute('data-ninja-style') !== null) { |
163 | template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); | 172 | template.file.content.document.body.setAttribute('style', template.body.getAttribute('data-ninja-style')); |
diff --git a/js/document/views/design.js b/js/document/views/design.js index 44c61617..d5c5c6c4 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -281,6 +281,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
281 | this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); | 281 | this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); |
282 | //Getting style and link tags in document | 282 | //Getting style and link tags in document |
283 | var htags = this.document.getElementsByTagName('html'), | 283 | var htags = this.document.getElementsByTagName('html'), |
284 | bannerWrapper, | ||
284 | userStyles, | 285 | userStyles, |
285 | stags = this.document.getElementsByTagName('style'), | 286 | stags = this.document.getElementsByTagName('style'), |
286 | ltags = this.document.getElementsByTagName('link'), i, orgNodes, | 287 | ltags = this.document.getElementsByTagName('link'), i, orgNodes, |
@@ -326,6 +327,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
326 | //TODO: Verify appropiate location for this operation | 327 | //TODO: Verify appropiate location for this operation |
327 | if (this._template && this._template.type === 'banner') { | 328 | if (this._template && this._template.type === 'banner') { |
328 | this.documentRoot = this.document.body.getElementsByTagName('ninja-content')[0]; | 329 | this.documentRoot = this.document.body.getElementsByTagName('ninja-content')[0]; |
330 | bannerWrapper = this.documentRoot.parentNode; | ||
329 | } else { | 331 | } else { |
330 | this.documentRoot = this.document.body; | 332 | this.documentRoot = this.document.body; |
331 | } | 333 | } |
@@ -349,6 +351,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
349 | this.documentRoot.setAttribute('data-ninja-style', userStyles); | 351 | this.documentRoot.setAttribute('data-ninja-style', userStyles); |
350 | } | 352 | } |
351 | } | 353 | } |
354 | if(bannerWrapper) { | ||
355 | if(userStyles = bannerWrapper.getAttribute('style')) { | ||
356 | bannerWrapper.setAttribute('data-ninja-style', userStyles); | ||
357 | } | ||
358 | } | ||
352 | //Making callback if specified | 359 | //Making callback if specified |
353 | if (this._callback) this._callback(); | 360 | if (this._callback) this._callback(); |
354 | } | 361 | } |
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index bd47ffc3..87151964 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -1185,8 +1185,38 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1185 | var context = this.application.ninja.stage.gridContext; | 1185 | var context = this.application.ninja.stage.gridContext; |
1186 | var stage = this.application.ninja.stage; | 1186 | var stage = this.application.ninja.stage; |
1187 | var stageRoot = this.application.ninja.currentDocument.model.documentRoot; | 1187 | var stageRoot = this.application.ninja.currentDocument.model.documentRoot; |
1188 | var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot); | ||
1189 | 1188 | ||
1189 | // draw an outline around the template body if stage has any transforms | ||
1190 | if(stage.currentDocument.model.views.design._template && !MathUtils.isIdentityMatrix(this.viewUtils.getMatrixFromElement(stageRoot))) { | ||
1191 | var saveContext = this.getDrawingSurfaceElement(); | ||
1192 | this.setDrawingSurfaceElement(this.application.ninja.stage.gridCanvas); | ||
1193 | |||
1194 | var stagePt = MathUtils.getPointOnPlane([0,0,1,0]); | ||
1195 | var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt); | ||
1196 | var width = this.snapManager.getStageWidth(), | ||
1197 | height = this.snapManager.getStageHeight(), | ||
1198 | pt0 = [0, 0, 0], | ||
1199 | pt1 = [0, height, 0], | ||
1200 | delta = [width, 0, 0]; | ||
1201 | |||
1202 | this._gridLineArray.length = 0; | ||
1203 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
1204 | |||
1205 | pt0 = [0, 0, 0]; | ||
1206 | pt1 = [width, 0, 0]; | ||
1207 | delta = [0, height, 0]; | ||
1208 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
1209 | |||
1210 | this._lineColor = "red"; | ||
1211 | for (var i = 0; i < 4; i++) { | ||
1212 | this.drawIntersectedLine(this._gridLineArray[i], this._drawingContext); | ||
1213 | } | ||
1214 | |||
1215 | this.setDrawingSurfaceElement(saveContext); | ||
1216 | } | ||
1217 | |||
1218 | // draw reference lines across origin | ||
1219 | var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot); | ||
1190 | var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1); | 1220 | var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1); |
1191 | if(!l) return; | 1221 | if(!l) return; |
1192 | var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); | 1222 | var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); |
diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js index 0bbcb05b..53a99c35 100755 --- a/js/helper-classes/RDGE/rdge-compiled.js +++ b/js/helper-classes/RDGE/rdge-compiled.js | |||
@@ -248,13 +248,13 @@ RDGE.SceneGraph.prototype.insertAbove=function(a,b){RDGE.verifyTransformNode(a); | |||
248 | RDGE.SceneGraph.prototype._TraverseDFHelper=function(a,b,c){if("undefined"!=b.children){var d=[];for(d.push({node:b,parent:null});0<d.length;){c=d.pop();b=c.node;c=c.parent;if(void 0!==b.transformNode&&(b=b.transformNode,!1===a.process(b,c)))continue;if(void 0!==b.children)for(c=0;c<b.children.length;++c)d.push({node:b.children[c],parent:b})}}}; | 248 | RDGE.SceneGraph.prototype._TraverseDFHelper=function(a,b,c){if("undefined"!=b.children){var d=[];for(d.push({node:b,parent:null});0<d.length;){c=d.pop();b=c.node;c=c.parent;if(void 0!==b.transformNode&&(b=b.transformNode,!1===a.process(b,c)))continue;if(void 0!==b.children)for(c=0;c<b.children.length;++c)d.push({node:b.children[c],parent:b})}}}; |
249 | RDGE.SceneGraph.prototype._TraverseDFPostOrderHelper=function(a,b,c){if("undefined"!=b.children){var d=[];d.push({node:b,parent:null});for(b=d.length;0<b;){for(var b=d.length,c=g.children[b-1],c=void 0==c.children?0:c.children.length,f=0;f<c;++f)d.push({node:g.children[f],parent:g});if(!(0<c)){var c=d.pop(),g=c.node,c=c.parent;void 0!==g.transformNode&&(g=g.transformNode,a.process(g,c))}}}}; | 249 | RDGE.SceneGraph.prototype._TraverseDFPostOrderHelper=function(a,b,c){if("undefined"!=b.children){var d=[];d.push({node:b,parent:null});for(b=d.length;0<b;){for(var b=d.length,c=g.children[b-1],c=void 0==c.children?0:c.children.length,f=0;f<c;++f)d.push({node:g.children[f],parent:g});if(!(0<c)){var c=d.pop(),g=c.node,c=c.parent;void 0!==g.transformNode&&(g=g.transformNode,a.process(g,c))}}}}; |
250 | RDGE.SceneGraph.prototype.BuildBVHHelper=function(a){if("undefined"!=a.children){a.bbox_world?a.bbox_world.reset():a.bbox_world=new RDGE.box;void 0==a.local&&(a.local=RDGE.mat4.identity());var b=[],c=0;a.id="root";b.push({node:a,xfrm:RDGE.mat4.identity(),parent:null,visited:!1});for(var a=b.length,d=0;0<a;){var a=b.length,d=a-1,f=void 0==b[d].node.transformNode?b[d].node:b[d].node.transformNode,g=b[d].xfrm,h=b[d].parent,d=b[d].visited;void 0==f.id&&(f.id="id"+c);if(!d){if(void 0!==f.local&&(f.bbox_world? | 250 | RDGE.SceneGraph.prototype.BuildBVHHelper=function(a){if("undefined"!=a.children){a.bbox_world?a.bbox_world.reset():a.bbox_world=new RDGE.box;void 0==a.local&&(a.local=RDGE.mat4.identity());var b=[],c=0;a.id="root";b.push({node:a,xfrm:RDGE.mat4.identity(),parent:null,visited:!1});for(var a=b.length,d=0;0<a;){var a=b.length,d=a-1,f=void 0==b[d].node.transformNode?b[d].node:b[d].node.transformNode,g=b[d].xfrm,h=b[d].parent,d=b[d].visited;void 0==f.id&&(f.id="id"+c);if(!d){if(void 0!==f.local&&(f.bbox_world? |
251 | f.bbox_world.reset():f.bbox_world=new RDGE.box,d=this.GetBBoxForNode(f),f.world=RDGE.mat4.mul(f.local,g),d&&(f.bbox_world=d.transform(f.world)),!d||!d.isValid()))g=new RDGE.box,g.set(0,0),f.bbox_world=g;g=void 0==f.children?0:f.children.length;for(d=0;d<g;++d)b.push({node:f.children[d],xfrm:f.world,parent:f,visited:!1});c++;if(0<g)continue}h&&h.bbox_world&&h.bbox_world.isValid()&&f.bbox_world&&f.bbox_world.isValid()&&h.bbox_world.addBox(f.bbox_world);b.pop();a=b.length;if(0<a&&(void 0==b[a-1].node.transformNode? | 251 | f.bbox_world.reset():f.bbox_world=new RDGE.box,d=this.GetBBoxForNode(f),f.world=RDGE.mat4.mul(f.local,g),d&&(f.bbox_world=d.transform(f.world)),!d||!d.isValid()))g=new RDGE.box,g.set(0,0),f.bbox_world=g;g=void 0==f.children?0:f.children.length;for(d=0;d<g;++d)b.push({node:f.children[d],xfrm:f.world,parent:f,visited:!1});c++;if(0<g)continue}h&&(h.bbox_world&&h.bbox_world.isValid()&&f.bbox_world&&f.bbox_world.isValid())&&h.bbox_world.addBox(f.bbox_world);b.pop();a=b.length;if(0<a&&(void 0==b[a-1].node.transformNode? |
252 | b[a-1].node:b[a-1].node.transformNode).id==h.id)b[a-1].visited=!0}}};RDGE.SceneGraph.prototype._TraverseBFHelper=function(a,b){if("undefined"!=b.children){var c=[];for(c.push({node:b,parent:null});0<c.length;){var d=c.shift(),f=d.node,d=d.parent;void 0!==f.transformNode&&(f=f.transformNode,a.process(f,d));if(void 0!==f.children)for(d=0;d<f.children.length;++d)c.push({node:f.children[d],parent:f})}}}; | 252 | b[a-1].node:b[a-1].node.transformNode).id==h.id)b[a-1].visited=!0}}};RDGE.SceneGraph.prototype._TraverseBFHelper=function(a,b){if("undefined"!=b.children){var c=[];for(c.push({node:b,parent:null});0<c.length;){var d=c.shift(),f=d.node,d=d.parent;void 0!==f.transformNode&&(f=f.transformNode,a.process(f,d));if(void 0!==f.children)for(d=0;d<f.children.length;++d)c.push({node:f.children[d],parent:f})}}}; |
253 | RDGE.SceneGraph.prototype.update=function(a){var b=RDGE.globals.engine.getContext().renderer;RDGE.globals.engine.getContext().debug.mat4CallCount=0;for(var c=this.animstack.length-1;0<=c;)this.animstack[c].step(a),--c;this.BuildBVHHelper(this.scene);RDGE.g_particleSystemManager.update(a);a=b.cameraManager().getActiveCamera();void 0!==a&&null!=a&&null!=a.controller&&void 0!==a.controller.world&&a.setWorld(a.controller.world);this.tick++}; | 253 | RDGE.SceneGraph.prototype.update=function(a){var b=RDGE.globals.engine.getContext().renderer;RDGE.globals.engine.getContext().debug.mat4CallCount=0;for(var c=this.animstack.length-1;0<=c;)this.animstack[c].step(a),--c;this.BuildBVHHelper(this.scene);RDGE.g_particleSystemManager.update(a);a=b.cameraManager().getActiveCamera();void 0!==a&&(null!=a&&null!=a.controller&&void 0!==a.controller.world)&&a.setWorld(a.controller.world);this.tick++}; |
254 | RDGE.SceneGraph.prototype.render=function(a,b){if(0!=this.scene.children.length){var c=RDGE.globals.engine.getContext().renderer;RDGE.rdgeGlobalParameters.u_shadowLightFarZ.set([this.mainLight.zFar()]);this.renderList=this._RenderDFHelper(c,a,this.scene,b);this.shadowsEnabled&&(this.Traverse(this.shadowCuller,!0),thi |