aboutsummaryrefslogtreecommitdiff
path: root/js/io/document/document-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/document/document-controller.js')
-rwxr-xr-xjs/io/document/document-controller.js36
1 files changed, 20 insertions, 16 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index bba7e0e7..7fe94c12 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -99,9 +99,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
99 if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){ 99 if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){
100 uri = uriArrayObj.uri[0]; 100 uri = uriArrayObj.uri[0];
101 } 101 }
102 console.log("URI is: ", uri); 102 //console.log("URI is: ", uri);
103 103
104 // Get file from Jose Code with a callback to here
105 if(!!uri){ 104 if(!!uri){
106 response = this.application.ninja.coreIoApi.openFile({"uri":uri}); 105 response = this.application.ninja.coreIoApi.openFile({"uri":uri});
107 if((response.success === true) && ((response.status === 200) || (response.status === 304))){ 106 if((response.success === true) && ((response.status === 200) || (response.status === 304))){
@@ -113,7 +112,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
113 if(uri.indexOf('.') != -1){ 112 if(uri.indexOf('.') != -1){
114 fileType = uri.substr(uri.lastIndexOf('.') + 1); 113 fileType = uri.substr(uri.lastIndexOf('.') + 1);
115 } 114 }
116 this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent}); 115 this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent, "externalUri": uri});
117 } 116 }
118 117
119 } 118 }
@@ -124,7 +123,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
124 value: function(uri) { 123 value: function(uri) {
125 console.log("URI is: ", uri); 124 console.log("URI is: ", uri);
126 125
127 // Get project from Jose Code with a callback to here
128 } 126 }
129 }, 127 },
130 128
@@ -158,18 +156,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
158 } 156 }
159 }, 157 },
160 158
161 // Document has been loaded into the Iframe. Dispatch the event.
162 // Event Detail: Contains the current ActiveDocument
163 _onOpenDocument: {
164 value: function(doc){
165
166 DocumentController.activeDocument = doc;
167
168 NJevent("onOpenDocument", doc);
169
170 }
171 },
172
173 textDocumentOpened: { 159 textDocumentOpened: {
174 value: function(doc) { 160 value: function(doc) {
175 161
@@ -209,13 +195,31 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
209 195
210 closeDocument: { 196 closeDocument: {
211 value: function(id) { 197 value: function(id) {
198
199 //if file dirty then save
200
212 var doc = this._findDocumentByUUID(id); 201 var doc = this._findDocumentByUUID(id);
213 this._removeDocumentView(doc.container); 202 this._removeDocumentView(doc.container);
214 203
215 this._documents.splice(this._findIndexByUUID(id), 1); 204 this._documents.splice(this._findIndexByUUID(id), 1);
216 205
217 if(this.activeDocument.uuid === id && this._documents.length > 0) { 206 if(this.activeDocument.uuid === id && this._documents.length > 0) {
207
208 var closeDocumentIndex = this._findIndexByUUID(id);
209 var nextDocumentIndex = -1 ;
210 if((this._documents.length > 0) && (closeDocumentIndex === 0)){
211 nextDocumentIndex = 1;
212 }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){
213 nextDocumentIndex = closeDocumentIndex - 1;
214 }
215
216 //remove the codemirror div if this is for a code view
217 /////test
218
219 ////end- test
220
218 this.switchDocument(this._documents[0].uuid); 221 this.switchDocument(this._documents[0].uuid);
222
219 } 223 }
220 } 224 }
221 }, 225 },