aboutsummaryrefslogtreecommitdiff
path: root/js/document/html-document.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-08 13:39:11 -0800
committerValerio Virgillito2012-03-08 13:39:11 -0800
commit5940b22e01de4fc36e5c5de5f3ed074f08fadb07 (patch)
tree72a5592ef65b3238b31f0e9954b2ad8d1778eeac /js/document/html-document.js
parent9b006acf1f6c2be5abc54f94a8bee7e684f106f9 (diff)
parent130cd6d4b99c9db344ec0ab44a54a59d11b31d2f (diff)
downloadninja-5940b22e01de4fc36e5c5de5f3ed074f08fadb07.tar.gz
Merge pull request #104 from ananyasen/integration-candidate
IKNINJA-1270: fixed browser crashing when you close a document while playing a video
Diffstat (limited to 'js/document/html-document.js')
-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..23b55e92 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, 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 ////////////////////////////////////////////////////////////////////
875}); \ No newline at end of file 916}); \ No newline at end of file