diff options
Diffstat (limited to 'js/io/document')
-rwxr-xr-x | js/io/document/base-document.js | 13 | ||||
-rwxr-xr-x | js/io/document/document-controller.js | 36 | ||||
-rwxr-xr-x | js/io/document/text-document.js | 4 |
3 files changed, 34 insertions, 19 deletions
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js index 44f54f78..af96c851 100755 --- a/js/io/document/base-document.js +++ b/js/io/document/base-document.js | |||
@@ -12,6 +12,7 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { | |||
12 | /** Private Members **/ | 12 | /** Private Members **/ |
13 | _name: { value: null, enumerable: false }, | 13 | _name: { value: null, enumerable: false }, |
14 | _uri: { value: null, enumerable: false }, | 14 | _uri: { value: null, enumerable: false }, |
15 | _externalUri: {value: null, enumerable:false}, | ||
15 | _documentType: { value: null, enumerable: false }, | 16 | _documentType: { value: null, enumerable: false }, |
16 | _container: {value: null, enumerable: false }, | 17 | _container: {value: null, enumerable: false }, |
17 | _uuid: { value: null, enumerable: false }, | 18 | _uuid: { value: null, enumerable: false }, |
@@ -31,6 +32,11 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { | |||
31 | set: function(value) { this._uri = value; } | 32 | set: function(value) { this._uri = value; } |
32 | }, | 33 | }, |
33 | 34 | ||
35 | externalUri: { | ||
36 | get: function() { return this._externalUri; }, | ||
37 | set: function(value) { this._externalUri = value; } | ||
38 | }, | ||
39 | |||
34 | documentType: { | 40 | documentType: { |
35 | get: function() { return this._documentType; }, | 41 | get: function() { return this._documentType; }, |
36 | set: function(value) { this._documentType = value; } | 42 | set: function(value) { this._documentType = value; } |
@@ -68,13 +74,18 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { | |||
68 | 74 | ||
69 | /** Base Methods **/ | 75 | /** Base Methods **/ |
70 | init: { | 76 | init: { |
71 | value: function(name, uri, type, container, uuid, callback) { | 77 | value: function(name, uri, type, container, uuid, callback, externalUri) { |
72 | this.name = name; | 78 | this.name = name; |
73 | this.uri = uri; | 79 | this.uri = uri; |
74 | this.documentType = type; | 80 | this.documentType = type; |
75 | this.container = container; | 81 | this.container = container; |
76 | this.uuid = uuid; | 82 | this.uuid = uuid; |
77 | this.callback = callback; | 83 | this.callback = callback; |
84 | if(!!externalUri){ | ||
85 | this.externalUri = externalUri; | ||
86 | this.container.setAttribute("data-uri", externalUri); | ||
87 | } | ||
88 | |||
78 | } | 89 | } |
79 | }, | 90 | }, |
80 | 91 | ||
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 | }, |
diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 599d311c..a9081cb5 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js | |||
@@ -45,10 +45,10 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base | |||
45 | // PUBLIC METHODS | 45 | // PUBLIC METHODS |
46 | initialize: { | 46 | initialize: { |
47 | value: function(doc, uuid, textArea, callback) { | 47 | value: function(doc, uuid, textArea, callback) { |
48 | this.init(doc.name, doc.uri, doc.type, textArea, uuid); | 48 | this.init(doc.name, doc.uri, doc.type, textArea, uuid, null, doc.externalUri); |
49 | |||
50 | this.currentView = "code"; | 49 | this.currentView = "code"; |
51 | this.textArea = textArea; | 50 | this.textArea = textArea; |
51 | |||
52 | // this._loadContent(); | 52 | // this._loadContent(); |
53 | } | 53 | } |
54 | }, | 54 | }, |