diff options
-rwxr-xr-x | js/controllers/document-controller.js | 8 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 28 | ||||
-rwxr-xr-x | js/document/html-document.js | 73 | ||||
-rw-r--r-- | js/document/templates/montage-html/main.reel/main.js | 11 | ||||
-rwxr-xr-x | js/lib/drawing/world.js | 2 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 2 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 4 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 58 | ||||
-rwxr-xr-x | js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js | 8 | ||||
-rw-r--r-- | js/panels/presets/default-animation-presets.js | 48 | ||||
-rw-r--r-- | node_modules/components-data/feed-reader.json | 2 |
11 files changed, 157 insertions, 87 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 539fd13e..d5556fa8 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -64,10 +64,16 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
64 | 64 | ||
65 | this.eventManager.addEventListener("styleSheetDirty", this, false); | 65 | this.eventManager.addEventListener("styleSheetDirty", this, false); |
66 | 66 | ||
67 | this.eventManager.addEventListener("addComponentFirstDraw", this, false); | ||
67 | } | 68 | } |
68 | }, | 69 | }, |
69 | 70 | ||
70 | 71 | handleAddComponentFirstDraw: { | |
72 | value: function (e) { | ||
73 | //TODO: Add logic to reparse the document for dynamically added styles | ||
74 | console.log(e); | ||
75 | } | ||
76 | }, | ||
71 | 77 | ||
72 | 78 | ||
73 | 79 | ||
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b060b751..5b9e4672 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -504,13 +504,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
504 | var sm, | 504 | var sm, |
505 | fm, | 505 | fm, |
506 | world, | 506 | world, |
507 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 507 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
508 | if(worldData) | 508 | if(worldData) |
509 | { | 509 | { |
510 | worldData = this.flip3DSense (worldData ); | ||
510 | world = new World(el, true); | 511 | world = new World(el, true); |
511 | el.elementModel.shapeModel.GLWorld = world; | 512 | el.elementModel.shapeModel.GLWorld = world; |
512 | el.elementModel.shapeModel.useWebGl = true; | 513 | el.elementModel.shapeModel.useWebGl = true; |
513 | world.import(worldData); | 514 | world.importJSON(worldData); |
514 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 515 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
515 | 516 | ||
516 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); | 517 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); |
@@ -540,13 +541,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
540 | return; | 541 | return; |
541 | } | 542 | } |
542 | var world, | 543 | var world, |
543 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 544 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
544 | if(worldData) | 545 | if(worldData) |
545 | { | 546 | { |
547 | worldData = this.flip3DSense (worldData ); | ||
546 | world = new World(el, false); | 548 | world = new World(el, false); |
547 | el.elementModel.shapeModel.GLWorld = world; | 549 | el.elementModel.shapeModel.GLWorld = world; |
548 | el.elementModel.shapeModel.useWebGl = false; | 550 | el.elementModel.shapeModel.useWebGl = false; |
549 | world.import(worldData); | 551 | world.importJSON(worldData); |
550 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 552 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
551 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); | 553 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); |
552 | el.elementModel.shapeModel.strokeMaterial = null; | 554 | el.elementModel.shapeModel.strokeMaterial = null; |
@@ -558,6 +560,24 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
558 | } | 560 | } |
559 | } | 561 | } |
560 | } | 562 | } |
563 | }, | ||
564 | |||
565 | flip3DSense: { | ||
566 | value: function( importStr ) | ||
567 | { | ||
568 | var jObj; | ||
569 | var index = importStr.indexOf( ';' ); | ||
570 | if ((importStr[0] === 'v') && (index < 24)) | ||
571 | { | ||
572 | // JSON format. separate the version info from the JSON info | ||
573 | //var vStr = importStr.substr( 0, index+1 ); | ||
574 | var jStr = importStr.substr( index+1 ); | ||
575 | jObj = JSON.parse( jStr ); | ||
576 | jObj.webGL = !jObj.webGL; | ||
577 | } | ||
578 | |||
579 | return jObj; | ||
580 | } | ||
561 | } | 581 | } |
562 | 582 | ||
563 | }); | 583 | }); |
diff --git a/js/document/html-document.js b/js/document/html-document.js index aa57d848..8f9d2870 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -564,67 +564,13 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
564 | } | 564 | } |
565 | // | 565 | // |
566 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; | 566 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; |
567 | //Inserting user's document into template | ||
568 | |||
569 | |||
570 | |||
571 | |||
572 | |||
573 | |||
574 | |||
575 | |||
576 | |||
577 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
578 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
579 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
580 | |||
581 | //TODO: Clean up and make public method to prepend properties with Ninja URL | ||
582 | this._templateDocument.head.innerHTML = (this._userDocument.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this)); | ||
583 | this._templateDocument.body.innerHTML = (this._userDocument.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this)); | ||
584 | // | ||
585 | //var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); | ||
586 | // | ||
587 | function ninjaUrlRedirect (prop) { | ||
588 | //Checking for property value to not contain a full direct URL | ||
589 | if (!prop.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) { | ||
590 | //Checking for attributes and type of source | ||
591 | if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) { //From HTML attribute | ||
592 | // | ||
593 | prop = prop.replace(/"([^"]*)"/gi, ninjaUrlPrepend.bind(this)); | ||
594 | } else if (prop.indexOf('url') !== -1) { //From CSS property | ||
595 | //TODO: Add functionality | ||
596 | var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); | ||
597 | prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl); | ||
598 | function cssUrlToNinjaUrl (s) { | ||
599 | if (s !== 'url') { | ||
600 | s = docRootUrl + s; | ||
601 | } | ||
602 | return s; | ||
603 | } | ||
604 | } | ||
605 | } | ||
606 | return prop; | ||
607 | } | ||
608 | // | ||
609 | function ninjaUrlPrepend (url) { | ||
610 | var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); | ||
611 | if (url.indexOf('data:image') !== -1) { | ||
612 | return url; | ||
613 | } else { | ||
614 | return '"'+docRootUrl+url.replace(/\"/gi, '')+'"'; | ||
615 | } | ||
616 | } | ||
617 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
618 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
619 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
620 | |||
621 | |||
622 | |||
623 | |||
624 | |||
625 | 567 | ||
626 | 568 | ||
627 | 569 | ||
570 | //TODO: Clean up, using for prototyping | ||
571 | this._templateDocument.head.innerHTML = (this._userDocument.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator)); | ||
572 | this._templateDocument.body.innerHTML = (this._userDocument.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator)); | ||
573 | |||
628 | 574 | ||
629 | 575 | ||
630 | var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; //TODO: Use querySelectorAll | 576 | var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; //TODO: Use querySelectorAll |
@@ -647,7 +593,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
647 | 593 | ||
648 | 594 | ||
649 | 595 | ||
650 | |||
651 | //Temporarily checking for disabled special case | 596 | //Temporarily checking for disabled special case |
652 | var stags = this.iframe.contentWindow.document.getElementsByTagName('style'), | 597 | var stags = this.iframe.contentWindow.document.getElementsByTagName('style'), |
653 | ltags = this.iframe.contentWindow.document.getElementsByTagName('link'); | 598 | ltags = this.iframe.contentWindow.document.getElementsByTagName('link'); |
@@ -672,7 +617,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
672 | 617 | ||
673 | 618 | ||
674 | 619 | ||
675 | |||
676 | //Adding a handler for the main user document reel to finish loading | 620 | //Adding a handler for the main user document reel to finish loading |
677 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); | 621 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); |
678 | 622 | ||
@@ -731,6 +675,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
731 | // | 675 | // |
732 | fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0]; | 676 | fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0]; |
733 | 677 | ||
678 | //TODO: Make public version of this.application.ninja.ioMediator.getNinjaPropUrlRedirect with dynamic ROOT | ||
734 |