aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-15 22:36:44 -0700
committerValerio Virgillito2012-05-15 22:36:44 -0700
commit919a0d0ed35c24b1047281723ddde2ac98fc9a3e (patch)
treea35ef0d07bf16a461543f4481a04f005ceacc160 /js/document
parent94855a2c1074f67f158b94ca0d61c51ee46c51b5 (diff)
downloadninja-919a0d0ed35c24b1047281723ddde2ac98fc9a3e.tar.gz
document close handler. initial working draft
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/document-html.js26
-rwxr-xr-xjs/document/html-document.js39
-rwxr-xr-xjs/document/models/base.js3
3 files changed, 6 insertions, 62 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 9bbea4c9..87c776d5 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -43,13 +43,6 @@ exports.HtmlDocument = Montage.create(Component, {
43 exclusionList: { 43 exclusionList: {
44 value: ["HTML", "BODY"] //TODO: Update to correct list 44 value: ["HTML", "BODY"] //TODO: Update to correct list
45 }, 45 },
46 ////////////////////////////////////////////////////////////////////
47 //
48 uuid: {
49 get: function() {
50 return this._uuid;
51 }
52 },
53 //////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////
54 // 47 //
55 inExclusion: { 48 inExclusion: {
@@ -133,21 +126,10 @@ exports.HtmlDocument = Montage.create(Component, {
133 //////////////////////////////////////////////////////////////////// 126 ////////////////////////////////////////////////////////////////////
134 // 127 //
135 closeDocument: { 128 closeDocument: {
136 value: function () { 129 value: function (context, callback) {
137 // 130 var closed = this.model.close(null);
138 this.model.close(null, this.handleCloseDocument.bind(this)); 131
139 } 132 callback.call(context, this);
140 },
141 ////////////////////////////////////////////////////////////////////
142 //
143 handleCloseDocument: {
144 value: function (success) {
145 //TODO: Add logic for handling success or failure
146 //
147 this.application.ninja.documentController._documents.splice(this.uuid, 1);
148 //
149 NJevent("closeDocument", this.model.file.uri);
150 //TODO: Delete object here
151 } 133 }
152 }, 134 },
153 //////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 9d083dd8..6a84abdf 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -972,44 +972,5 @@ exports.HTMLDocument = Montage.create(TextDocument, {
972 972
973 973
974 } 974 }
975 },
976 ////////////////////////////////////////////////////////////////////
977 /**
978 *pause videos on switching or closing the document, so that the browser does not keep downloading the media data
979 */
980 pauseVideos:{
981 value:function(){
982 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
983 for(i=0;i<videosArr.length;i++){
984 if(!videosArr[i].paused){
985 videosArr[i].pause();
986 }
987 }
988 }
989 },
990
991 /**
992 * 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
993 *removeSrc : boolean to remove the src if the video... set only in the close document flow
994 */
995 stopVideos:{
996 value:function(){
997 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
998 for(i=0;i<videosArr.length;i++){
999 videosArr[i].src = "";
1000 }
1001 }
1002 },
1003 pauseAndStopVideos:{
1004 value:function(){
1005 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
1006 for(i=0;i<videosArr.length;i++){
1007 if(!videosArr[i].paused){
1008 videosArr[i].pause();
1009 }
1010 videosArr[i].src = "";
1011 }
1012 }
1013 } 975 }
1014 ////////////////////////////////////////////////////////////////////
1015}); \ No newline at end of file 976}); \ No newline at end of file
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 5f2a5893..d34fb2dd 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -206,10 +206,11 @@ exports.BaseDocumentModel = Montage.create(Component, {
206 if (this.views.design && (!view || view === 'design')) { 206 if (this.views.design && (!view || view === 'design')) {
207 // 207 //
208 this.parentContainer.removeChild(this.views.design.iframe); 208 this.parentContainer.removeChild(this.views.design.iframe);
209 this.views.design.pauseAndStopVideos();
209 this.views.design = null; 210 this.views.design = null;
210 } 211 }
211 // 212 //
212 if (callback) callback(success); 213 return success;
213 } 214 }
214 } 215 }
215 //////////////////////////////////////////////////////////////////// 216 ////////////////////////////////////////////////////////////////////