aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators')
-rwxr-xr-xjs/mediators/element-mediator.js15
-rw-r--r--js/mediators/io-mediator.js50
2 files changed, 33 insertions, 32 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index 127f73e1..d62fa1f8 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -459,13 +459,12 @@ exports.ElementMediator = Montage.create(NJComponent, {
459 459
460 //-------------------------------------------------------------------------------------------------------- 460 //--------------------------------------------------------------------------------------------------------
461 // Routines to get/set color 461 // Routines to get/set color
462 // for now just return the bg/fill color
463 getColor: { 462 getColor: {
464 value: function(el, isFill) { 463 value: function(el, isFill, borderSide) {
465 if(!el.elementModel) { 464 if(!el.elementModel) {
466 NJUtils.makeModelFromElement(el); 465 NJUtils.makeModelFromElement(el);
467 } 466 }
468 return el.elementModel.controller["getColor"](el, isFill); 467 return el.elementModel.controller["getColor"](el, isFill, borderSide);
469 } 468 }
470 }, 469 },
471 470
@@ -621,16 +620,6 @@ exports.ElementMediator = Montage.create(NJComponent, {
621 } 620 }
622 }, 621 },
623 622
624 getColor2: {
625 value: function(el, prop, mutator) {
626 if(!el.elementModel) {
627 NJUtils.makeModelFromElement(el);
628 }
629
630 return this.getColor(el, (prop === "background"));
631 }
632 },
633
634 //-------------------------------------------------------------------------------------------------------- 623 //--------------------------------------------------------------------------------------------------------
635 // Routines to get/set 3D properties 624 // Routines to get/set 3D properties
636 get3DProperty: { 625 get3DProperty: {
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index c22d95be..d81f4543 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -355,13 +355,21 @@ exports.IoMediator = Montage.create(Component, {
355 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { 355 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') {
356 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 356 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
357 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 357 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
358 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, rdgeDirName); 358 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, rdgeDirName, hackRename.bind(this));
359 //TODO: Remove, this is copying the library into a static name
360 function hackRename (status) {
361 if (status) {
362 setTimeout(function () {
363 this.application.ninja.coreIoApi.copyDirectory({sourceUri: template.document.root+rdgeDirName, destUri: template.document.root+'assets'});
364 }.bind(this), 3000);
365 }
366 }
359 } else { 367 } else {
360 //TODO: Error handle no available library to copy 368 //TODO: Error handle no available library to copy
361 } 369 }
362 } 370 }
363 // 371 //
364 var json, matchingtags = [], webgltag, scripts = template.document.content.document.getElementsByTagName('script'), webgljstag, webgllibtag; 372 var json, matchingtags = [], webgltag, scripts = template.document.content.document.getElementsByTagName('script'), webgljstag, webgllibtag, webglrdgetag;
365 // 373 //
366 for (var i in scripts) { 374 for (var i in scripts) {
367 if (scripts[i].getAttribute) { 375 if (scripts[i].getAttribute) {
@@ -374,6 +382,9 @@ exports.IoMediator = Montage.create(Component, {
374 if (scripts[i].getAttribute('data-ninja-webgl-lib') !== null) { 382 if (scripts[i].getAttribute('data-ninja-webgl-lib') !== null) {
375 webgllibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags 383 webgllibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags
376 } 384 }
385 if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) {
386 webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags
387 }
377 } 388 }
378 } 389 }
379 // 390 //
@@ -386,10 +397,18 @@ exports.IoMediator = Montage.create(Component, {
386 } 397 }
387 } 398 }
388 // 399 //
400 if (!webglrdgetag) {
401 webglrdgetag = template.document.content.document.createElement('script');
402 webglrdgetag.setAttribute('type', 'text/javascript');
403 webglrdgetag.setAttribute('src', rdgeDirName+'/rdge-compiled.js');
404 webglrdgetag.setAttribute('data-ninja-webgl-rdge', 'true');
405 template.document.content.document.head.appendChild(webglrdgetag);
406 }
407 //
389 if (!webgllibtag) { 408 if (!webgllibtag) {
390 webgllibtag = template.document.content.document.createElement('script'); 409 webgllibtag = template.document.content.document.createElement('script');
391 webgllibtag.setAttribute('type', 'text/javascript'); 410 webgllibtag.setAttribute('type', 'text/javascript');
392 webgllibtag.setAttribute('src', rdgeDirName+'/CanvasDataManager.js'); 411 webgllibtag.setAttribute('src', rdgeDirName+'/canvas-runtime.js');
393 webgllibtag.setAttribute('data-ninja-webgl-lib', 'true'); 412 webgllibtag.setAttribute('data-ninja-webgl-lib', 'true');
394 template.document.content.document.head.appendChild(webgllibtag); 413 template.document.content.document.head.appendChild(webgllibtag);
395 } 414 }
@@ -399,7 +418,7 @@ exports.IoMediator = Montage.create(Component, {
399 webgltag.setAttribute('data-ninja-webgl', 'true'); 418 webgltag.setAttribute('data-ninja-webgl', 'true');
400 template.document.content.document.head.appendChild(webgltag); 419 template.document.content.document.head.appendChild(webgltag);
401 } 420 }
402 // 421 //TODO: Remove this tag and place inside JS file
403 if (!webgljstag) { 422 if (!webgljstag) {
404 webgljstag = template.document.content.document.createElement('script'); 423 webgljstag = template.document.content.document.createElement('script');
405 webgljstag.setAttribute('type', 'text/javascript'); 424 webgljstag.setAttribute('type', 'text/javascript');
@@ -407,25 +426,18 @@ exports.IoMediator = Montage.create(Component, {
407 template.document.content.document.head.appendChild(webgljstag); 426 template.document.content.document.head.appendChild(webgljstag);
408 } 427 }
409 //TODO: Decide if this should be over-writter or only written on creation 428 //TODO: Decide if this should be over-writter or only written on creation
429 var rootElement = 'document.body'; //TODO: Set actual root element
410 webgljstag.innerHTML = "\ 430 webgljstag.innerHTML = "\
411//Loading webGL/canvas data on window load\n\ 431//Loading webGL/canvas data on window load\n\
412window.addEventListener('load', initWebGl, false);\n\ 432window.addEventListener('load', loadWebGL, false);\n\
413function initWebGl (e) {\n\ 433function loadWebGL (e) {\n\
414 window.removeEventListener('load', initWebGl, false);\n\ 434 window.removeEventListener('load', loadWebGL, false);\n\
415 var cvsDataMngr, ninjaWebGlData = JSON.parse((document.querySelectorAll(['script[data-ninja-webgl]'])[0].innerHTML.replace(\"(\", \"\")).replace(\")\", \"\"));\n\ 435 //Calling method to initialize all webGL/canvas(es)\n\
416 if (ninjaWebGlData && ninjaWebGlData.data) {\n\ 436 initWebGl("+rootElement+", '"+rdgeDirName+"/');\n\
417 for (var n=0; ninjaWebGlData.data[n]; n++) {\n\
418 ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]);\n\
419 }\n\
420 }\n\
421 //Creating data manager\n\
422 cvsDataMngr = new CanvasDataManager();\n\
423 //Loading data to canvas(es)\n\
424 cvsDataMngr.loadGLData(document.body, ninjaWebGlData, '"+rdgeDirName+"');\n\
425}\ 437}\
426 "; 438 ";
427 //TODO: Add version and other data for RDGE 439 //TODO: This data should be saved to a JSON file eventually
428 json = '\n({\n\t"version": "'+rdgeVersion+'",\n\t"data": ['; 440 json = '\n({\n\t"version": "'+rdgeVersion+'",\n\t"directory": "'+rdgeDirName+'/",\n\t"data": [';
429 //Looping through data to create escaped array 441 //Looping through data to create escaped array
430 for (var j=0; template.webgl[j]; j++) { 442 for (var j=0; template.webgl[j]; j++) {
431 if (j === 0) { 443 if (j === 0) {