aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-08 13:57:28 -0800
committerValerio Virgillito2012-03-08 13:57:28 -0800
commitdac3dcdc74e60a1948a6d8d994fa7ef38a446b7c (patch)
tree7e601fda69b79b3c3baea7d35aae7b736d494532 /js
parent22a66cb6e243a3f1c867b62e3942fd2e828019d9 (diff)
parent5940b22e01de4fc36e5c5de5f3ed074f08fadb07 (diff)
downloadninja-dac3dcdc74e60a1948a6d8d994fa7ef38a446b7c.tar.gz
Merge branch 'refs/heads/master' into montage-integration
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js9
-rwxr-xr-xjs/document/html-document.js75
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js10
-rw-r--r--js/mediators/io-mediator.js2
-rw-r--r--js/panels/Timeline/Collapser.js70
-rw-r--r--js/panels/Timeline/Layer.reel/Layer.html129
-rw-r--r--js/panels/Timeline/Layer.reel/Layer.js190
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.html14
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js560
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.html136
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js138
-rw-r--r--js/panels/Timeline/Tween.reel/Tween.js10
12 files changed, 755 insertions, 588 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 194496a6..a8056519 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -336,14 +336,23 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
336 nextDocumentIndex = closeDocumentIndex - 1; 336 nextDocumentIndex = closeDocumentIndex - 1;
337 } 337 }
338 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); 338 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
339 if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();}
339 this._removeDocumentView(doc.container); 340 this._removeDocumentView(doc.container);
340 }else if(this._documents.length === 0){ 341 }else if(this._documents.length === 0){
342 if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){
343 this.activeDocument.pauseAndStopVideos();
344 }
341 this.activeDocument = null; 345 this.activeDocument = null;
342 this._removeDocumentView(doc.container); 346 this._removeDocumentView(doc.container);
343 this.application.ninja.stage.stageView.hideRulers(); 347 this.application.ninja.stage.stageView.hideRulers();
344 document.getElementById("iframeContainer").style.display="block"; 348 document.getElementById("iframeContainer").style.display="block";
345 349
346 this.application.ninja.stage.hideCanvas(true); 350 this.application.ninja.stage.hideCanvas(true);
351 }else{//closing inactive document tab - just clear DOM
352 if(typeof doc.pauseAndStopVideos !== "undefined"){
353 doc.pauseAndStopVideos();
354 }
355 this._removeDocumentView(doc.container);
347 } 356 }
348 357
349 NJevent("closeDocument", doc.uri); 358 NJevent("closeDocument", doc.uri);
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 1c5cec91..23b55e92 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -451,9 +451,12 @@ exports.HTMLDocument = Montage.create(TextDocument, {
451 // 451 //
452 function ninjaUrlPrepend (url) { 452 function ninjaUrlPrepend (url) {
453 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); 453 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
454 return '"'+docRootUrl+url.replace(/\"/gi, '')+'"'; 454 if (url.indexOf('data:image') !== -1) {
455 return url;
456 } else {
457 return '"'+docRootUrl+url.replace(/\"/gi, '')+'"';
458 }
455 } 459 }
456
457 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 460 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
458 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 461 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
459 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 462 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -614,12 +617,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
614 } 617 }
615 } 618 }
616 } 619 }
617
618
619
620
621 /* 620 /*
622//TODO: Figure out cross-domain XHR issue, might need cloud to handle 621
622 //TODO: Figure out cross-domain XHR issue, might need cloud to handle
623 var xhr = new XMLHttpRequest(); 623 var xhr = new XMLHttpRequest();
624 xhr.open("GET", this._document.styleSheets[i].href, true); 624 xhr.open("GET", this._document.styleSheets[i].href, true);
625 xhr.send(); 625 xhr.send();
@@ -627,20 +627,24 @@ exports.HTMLDocument = Montage.create(TextDocument, {
627 if (xhr.readyState === 4) { 627 if (xhr.readyState === 4) {
628 console.log(xhr); 628 console.log(xhr);
629 } 629 }
630*/
631 //tag.innerHTML = xhr.responseText //xhr.response; 630 //tag.innerHTML = xhr.responseText //xhr.response;
632 tag.innerHTML = 'noRULEjustHACK{background: #000}' 631 */
633 //Currently no external styles will load if unable to load via XHR request 632 //Temp rule so it's registered in the array
634 633 tag.innerHTML = 'noRULEjustHACK{background: #000}';
635 //Disabling external style sheets 634 //Disabling external style sheets
636 query = this._templateDocument.html.querySelectorAll(['link']); 635 query = this._templateDocument.html.querySelectorAll(['link']);
637 for (var k in query) { 636 for (var k in query) {
638 if (query[k].href === this._document.styleSheets[i].href) { 637 if (query[k].href === this._document.styleSheets[i].href) {
638
639 //TODO: Removed the temp insertion of the stylesheet
640 //because it wasn't the proper way to do it
641 //need to be handled via XHR with proxy in Cloud Sim
642
639 //Disabling style sheet to reload via inserting in style tag 643 //Disabling style sheet to reload via inserting in style tag
640 var tempCSS = query[k].cloneNode(true); 644 //var tempCSS = query[k].cloneNode(true);
641 tempCSS.setAttribute('data-ninja-template', 'true'); 645 //tempCSS.setAttribute('data-ninja-template', 'true');
642 query[k].setAttribute('disabled', 'true'); 646 query[k].setAttribute('disabled', 'true');
643 this.iframe.contentWindow.document.head.appendChild(tempCSS); 647 //this.iframe.contentWindow.document.head.appendChild(tempCSS);
644 //Inserting tag 648 //Inserting tag
645 this._templateDocument.head.insertBefore(tag, query[k]); 649 this._templateDocument.head.insertBefore(tag, query[k]);
646 } 650 }
@@ -838,6 +842,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
838 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); 842 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
839 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); 843 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
840 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start 844 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start
845
846 //pause videos on switching or closing the document, so that the browser does not keep downloading the media data
847 this.pauseVideos();
841 } 848 }
842 }, 849 },
843 850
@@ -866,6 +873,44 @@ exports.HTMLDocument = Montage.create(TextDocument, {
866 873
867 874
868 } 875 }
869 } 876 },
870 //////////////////////////////////////////////////////////////////// 877 ////////////////////////////////////////////////////////////////////
878 /**
879 *pause videos on switching or closing the document, so that the browser does not keep downloading the media data
880 */
881 pauseVideos:{
882 value:function(){
883 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
884 for(i=0;i<videosArr.length;i++){
885 if(!videosArr[i].paused){
886 videosArr[i].pause();
887 }
888 }
889 }
890 },
891
892 /**
893 * remove the video src on closing the document, so that the browser does not keep downloading the media data, if the tag does not get garbage collected
894 *removeSrc : boolean to remove the src if the video... set only in the close document flow
895 */
896 stopVideos:{
897 value:function(){
898 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
899 for(i=0;i<videosArr.length;i++){
900 videosArr[i].src = "";
901 }
902 }
903 },
904 pauseAndStopVideos:{
905 value:function(){
906 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
907 for(i=0;i<videosArr.length;i++){
908 if(!videosArr[i].paused){
909 videosArr[i].pause();
910 }
911 videosArr[i].src = "";
912 }
913 }
914 }
915 ////////////////////////////////////////////////////////////////////
871}); \ No newline at end of file 916}); \ No newline at end of file
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 02d946ae..63e7799a 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -112,6 +112,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
112 this.eventManager.addEventListener("elementDeleted", this, false); 112 this.eventManager.addEventListener("elementDeleted", this, false);
113 this.eventManager.addEventListener("deleteSelection", this, false); 113 this.eventManager.addEventListener("deleteSelection", this, false);
114 this.eventManager.addEventListener("elementChange", this, false); 114 this.eventManager.addEventListener("elementChange", this, false);
115 this.eventManager.addEventListener("closeDocument", this, false);
115 } 116 }
116 }, 117 },
117 118
@@ -135,6 +136,15 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
135 } 136 }
136 }, 137 },
137 138
139 handleCloseDocument:{
140 value: function() {
141 if(this.application.ninja.documentController._documents.length === 0){
142 this._eltArray = [];
143 this._planesArray = [];