aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js9
-rwxr-xr-xjs/controllers/selection-controller.js13
-rwxr-xr-xjs/document/html-document.js41
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js10
4 files changed, 72 insertions, 1 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index e29148c9..de080167 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -363,14 +363,23 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
363 nextDocumentIndex = closeDocumentIndex - 1; 363 nextDocumentIndex = closeDocumentIndex - 1;
364 } 364 }
365 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); 365 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
366 doc.stopVideos();
366 this._removeDocumentView(doc.container); 367 this._removeDocumentView(doc.container);
367 }else if(this._documents.length === 0){ 368 }else if(this._documents.length === 0){
369 if(typeof this.activeDocument.pauseVideos !== "undefined"){
370 this.activeDocument.pauseVideos(true);
371 }
368 this.activeDocument = null; 372 this.activeDocument = null;
369 this._removeDocumentView(doc.container); 373 this._removeDocumentView(doc.container);
370 this.application.ninja.stage.stageView.hideRulers(); 374 this.application.ninja.stage.stageView.hideRulers();
371 document.getElementById("iframeContainer").style.display="block"; 375 document.getElementById("iframeContainer").style.display="block";
372 376
373 this.application.ninja.stage.hideCanvas(true); 377 this.application.ninja.stage.hideCanvas(true);
378 }else{//closing inactive document tab - just clear DOM
379 if(typeof doc.pauseVideos !== "undefined"){
380 doc.pauseVideos(true);
381 }
382 this._removeDocumentView(doc.container);
374 } 383 }
375 384
376 NJevent("closeDocument", doc.uri); 385 NJevent("closeDocument", doc.uri);
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 3f9d8514..49bf42b6 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -48,6 +48,7 @@ exports.SelectionController = Montage.create(Component, {
48 this.eventManager.addEventListener("selectAll", this, false); 48 this.eventManager.addEventListener("selectAll", this, false);
49 this.eventManager.addEventListener("deleteSelection", this, false); 49 this.eventManager.addEventListener("deleteSelection", this, false);
50 this.eventManager.addEventListener("switchDocument", this, false); 50 this.eventManager.addEventListener("switchDocument", this, false);
51 this.eventManager.addEventListener("closeDocument", this, false);
51// defaultEventManager.addEventListener( "undo", this, false); 52// defaultEventManager.addEventListener( "undo", this, false);
52// defaultEventManager.addEventListener( "redo", this, false); 53// defaultEventManager.addEventListener( "redo", this, false);
53 } 54 }
@@ -105,6 +106,18 @@ exports.SelectionController = Montage.create(Component, {
105 } 106 }
106 }, 107 },
107 108
109 handleCloseDocument:{
110 value: function() {
111 //clear selections if all documents are closed
112 if(this.application.ninja.documentController._documents.length === 0){
113 this._selectedItems.length =0;
114 this.application.ninja.selectedElements.length =0;
115 this._isDocument = true;
116 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} );
117 }
118 }
119 },
120
108 handleElementAdded: { 121 handleElementAdded: {
109 value: function(event) { 122 value: function(event) {
110 this.executeSelectElement(event.detail); 123 this.executeSelectElement(event.detail);
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 80930af2..d90231e3 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -824,6 +824,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
824 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); 824 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
825 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); 825 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
826 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start 826 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start
827
828 //pause videos on switching or closing the document, so that the browser does not keep downloading the media data
829 this.pauseVideos();
827 } 830 }
828 }, 831 },
829 832
@@ -852,6 +855,42 @@ exports.HTMLDocument = Montage.create(TextDocument, {
852 855
853 856
854 } 857 }
855 } 858 },
856 //////////////////////////////////////////////////////////////////// 859 ////////////////////////////////////////////////////////////////////
860 /**
861 *pause videos on switching or closing the document, so that the browser does not keep downloading the media data
862 *removeSrc : boolean to remove the src if the video... set only in the close document flow
863 */
864 pauseVideos:{
865 value:function(removeSrc){
866 console.log("$$$ pauseVideos");
867 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
868 for(i=0;i<videosArr.length;i++){
869 if(!videosArr[i].paused){
870 videosArr[i].pause();
871 }
872 console.log("$$$ Paused ", videosArr[i]);
873 if((typeof removeSrc !== "undefined") && (removeSrc === true)){
874 videosArr[i].src = "";
875 console.log("$$$ stopped ");
876 }
877 }
878 }
879 },
880
881 /**
882 * 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
883 *removeSrc : boolean to remove the src if the video... set only in the close document flow
884 */
885 stopVideos:{
886 value:function(){
887 console.log("$$$ stopVideos");
888 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
889 for(i=0;i<videosArr.length;i++){
890 videosArr[i].src = "";
891 console.log("$$$ stopped ", videosArr[i]);
892 }
893 }
894 }
895 ////////////////////////////////////////////////////////////////////
857}); \ No newline at end of file 896}); \ 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 = [];
144 }
145 }
146 },
147
138 handleElementAdded: { 148 handleElementAdded: {
139 value: function(event) { 149 value: function(event) {
140 this.addElement(event.detail); 150 this.addElement(event.detail);