aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 46fefd90..bc27ea7b 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -943,6 +943,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
943 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); 943 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
944 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); 944 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
945 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start 945 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start
946
947 //pause videos on switching or closing the document, so that the browser does not keep downloading the media data
948 this.pauseVideos();
946 } 949 }
947 }, 950 },
948 951
@@ -971,6 +974,44 @@ exports.HTMLDocument = Montage.create(TextDocument, {
971 974
972 975
973 } 976 }
974 } 977 },
975 //////////////////////////////////////////////////////////////////// 978 ////////////////////////////////////////////////////////////////////
979 /**
980 *pause videos on switching or closing the document
981 */
982 pauseVideos:{
983 value:function(){
984 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
985 for(i=0;i<videosArr.length;i++){
986 if(!videosArr[i].paused){
987 videosArr[i].pause();
988 }
989 }
990 }
991 },
992
993 /**
994 * 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
995 */
996 stopVideos:{
997 value:function(){
998 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
999 for(i=0;i<videosArr.length;i++){
1000 videosArr[i].src = "";
1001 }
1002 }
1003 },
1004
1005 pauseAndStopVideos:{
1006 value:function(){
1007 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
1008 for(i=0;i<videosArr.length;i++){
1009 if(!videosArr[i].paused){
1010 videosArr[i].pause();
1011 }
1012 videosArr[i].src = "";
1013 }
1014 }
1015 }
1016 ////////////////////////////////////////////////////////////////////
976}); \ No newline at end of file 1017}); \ No newline at end of file