aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-15 23:34:52 -0700
committerValerio Virgillito2012-05-15 23:34:52 -0700
commit2b21e91a3343229bb87179e08be1e532fcf9b8f9 (patch)
tree5ae1e660d0e307fda84c3be6a66c243904d75225 /js/document
parent012a6e8fa8bfb56e1a50f3b2fc6058f3651701a2 (diff)
parent9db5c446337e266fd604eac79ec39c840ffebbbe (diff)
downloadninja-2b21e91a3343229bb87179e08be1e532fcf9b8f9.tar.gz
Merge pull request #237 from mencio/dom-architecture
Dom architecture - Fixed closing and opening a document
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 e8eba89f..f9844b70 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -214,10 +214,11 @@ exports.BaseDocumentModel = Montage.create(Component, {
214 if (this.views.design && (!view || view === 'design')) { 214 if (this.views.design && (!view || view === 'design')) {
215 // 215 //
216 this.parentContainer.removeChild(this.views.design.iframe); 216 this.parentContainer.removeChild(this.views.design.iframe);
217 this.views.design.pauseAndStopVideos();
217 this.views.design = null; 218 this.views.design = null;
218 } 219 }
219 // 220 //
220 if (callback) callback(success); 221 return success;
221 } 222 }
222 } 223 }
223 //////////////////////////////////////////////////////////////////// 224 ////////////////////////////////////////////////////////////////////