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 b9b68972..67026407 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -842,6 +842,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
842 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); 842 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
843 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); 843 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
844 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();
845 } 848 }
846 }, 849 },
847 850
@@ -870,6 +873,44 @@ exports.HTMLDocument = Montage.create(TextDocument, {
870 873
871 874
872 } 875 }
873 } 876 },
874 //////////////////////////////////////////////////////////////////// 877 ////////////////////////////////////////////////////////////////////
878 /**
879 *pause videos on switching or closing the document
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 */
895 stopVideos:{
896 value:function(){
897 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
898 for(i=0;i<videosArr.length;i++){
899 videosArr[i].src = "";
900 }
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 ////////////////////////////////////////////////////////////////////
875}); \ No newline at end of file 916}); \ No newline at end of file