diff options
Diffstat (limited to 'js/io/document/document-controller.js')
-rwxr-xr-x | js/io/document/document-controller.js | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index 7fe94c12..9be40ccc 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js | |||
@@ -112,7 +112,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
112 | if(uri.indexOf('.') != -1){ | 112 | if(uri.indexOf('.') != -1){ |
113 | fileType = uri.substr(uri.lastIndexOf('.') + 1); | 113 | fileType = uri.substr(uri.lastIndexOf('.') + 1); |
114 | } | 114 | } |
115 | this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent, "externalUri": uri}); | 115 | this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": uri}); |
116 | } | 116 | } |
117 | 117 | ||
118 | } | 118 | } |
@@ -141,7 +141,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
141 | newDoc = Montage.create(TextDocument, { | 141 | newDoc = Montage.create(TextDocument, { |
142 | "source": { value: doc.source } | 142 | "source": { value: doc.source } |
143 | }); | 143 | }); |
144 | newDoc.initialize(doc, Uuid.generate(), this._createTextAreaElement()); | 144 | var docUuid = Uuid.generate(); |
145 | var textArea = this.application.ninja.stage.stageView.createTextAreaElement(docUuid); | ||
146 | newDoc.initialize(doc, docUuid, textArea, textArea.parentNode); | ||
145 | 147 | ||
146 | // Tmp this will be filled with the real content | 148 | // Tmp this will be filled with the real content |
147 | newDoc.textArea.innerHTML = doc.source; //this.tmpSourceForTesting; | 149 | newDoc.textArea.innerHTML = doc.source; //this.tmpSourceForTesting; |
@@ -254,19 +256,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
254 | 256 | ||
255 | } else { | 257 | } else { |
256 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | 258 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe |
257 | var codeview = this._createTextAreaElement(); | 259 | |
258 | this._textHolder.style.display = "block"; | 260 | var codeview = this.activeDocument.container; |
259 | codeview.firstChild.innerHTML = this.activeDocument.iframe.contentWindow.document.body.parentNode.innerHTML; | 261 | //this._textHolder.style.display = "block"; |
260 | 262 | //codeview.firstChild.innerHTML = this.activeDocument.iframe.contentWindow.document.body.parentNode.innerHTML; | |
261 | this._codeEditor.editor = CodeMirror.fromTextArea(codeview.firstChild, { | 263 | |
262 | lineNumbers: true, | 264 | // this._codeEditor.editor = CodeMirror.fromTextArea(codeview.firstChild, { |
263 | mode: "htmlmixed", | 265 | // lineNumbers: true, |
264 | onCursorActivity: function() { | 266 | // mode: "htmlmixed", |
265 | DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null); | 267 | // onCursorActivity: function() { |
266 | DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline"); | 268 | // DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null); |
267 | } | 269 | // DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline"); |
268 | }); | 270 | // } |
269 | this._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline"); | 271 | // }); |
272 | // this._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline"); | ||
270 | } | 273 | } |
271 | } | 274 | } |
272 | }, | 275 | }, |
@@ -409,26 +412,5 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
409 | value: function() { | 412 | value: function() { |
410 | return "userDocument_" + (this._iframeCounter++); | 413 | return "userDocument_" + (this._iframeCounter++); |
411 | } | 414 | } |
412 | }, | ||
413 | |||
414 | /** | ||
415 | * Creates a text area which will contain the content of the opened text document. | ||
416 | */ | ||
417 | _createTextAreaElement: { | ||
418 | value: function() { | ||
419 | var codeMirrorDiv = document.createElement("div"); | ||
420 | codeMirrorDiv.id = "codeMirror_" + (this._codeMirrorCounter++); | ||
421 | |||
422 | var textArea = document.createElement("textarea"); | ||
423 | textArea.id = "code"; | ||
424 | textArea.name = "code"; | ||
425 | |||
426 | //codeMirrorDiv.appendChild(textArea); | ||
427 | |||
428 | // if(!this._textHolder) this._textHolder = document.getElementById("codeViewContainer"); | ||
429 | // this._textHolder.appendChild(codeMirrorDiv); | ||
430 | |||
431 | return textArea; | ||
432 | } | ||
433 | } | 415 | } |
434 | }); \ No newline at end of file | 416 | }); \ No newline at end of file |