diff options
Diffstat (limited to 'js/io')
-rwxr-xr-x | js/io/document/base-document.js | 8 | ||||
-rwxr-xr-x | js/io/document/document-controller.js | 54 | ||||
-rwxr-xr-x | js/io/document/html-document.js | 12 | ||||
-rwxr-xr-x | js/io/document/text-document.js | 10 | ||||
-rwxr-xr-x | js/io/system/coreioapi.js | 1 |
5 files changed, 39 insertions, 46 deletions
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js index af96c851..d3601de5 100755 --- a/js/io/document/base-document.js +++ b/js/io/document/base-document.js | |||
@@ -12,7 +12,6 @@ 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}, | ||
16 | _documentType: { value: null, enumerable: false }, | 15 | _documentType: { value: null, enumerable: false }, |
17 | _container: {value: null, enumerable: false }, | 16 | _container: {value: null, enumerable: false }, |
18 | _uuid: { value: null, enumerable: false }, | 17 | _uuid: { value: null, enumerable: false }, |
@@ -74,18 +73,13 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { | |||
74 | 73 | ||
75 | /** Base Methods **/ | 74 | /** Base Methods **/ |
76 | init: { | 75 | init: { |
77 | value: function(name, uri, type, container, uuid, callback, externalUri) { | 76 | value: function(name, uri, type, container, uuid, callback) { |
78 | this.name = name; | 77 | this.name = name; |
79 | this.uri = uri; | 78 | this.uri = uri; |
80 | this.documentType = type; | 79 | this.documentType = type; |
81 | this.container = container; | 80 | this.container = container; |
82 | this.uuid = uuid; | 81 | this.uuid = uuid; |
83 | this.callback = callback; | 82 | this.callback = callback; |
84 | if(!!externalUri){ | ||
85 | this.externalUri = externalUri; | ||
86 | this.container.setAttribute("data-uri", externalUri); | ||
87 | } | ||
88 | |||
89 | } | 83 | } |
90 | }, | 84 | }, |
91 | 85 | ||
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 |
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index c44dfe75..fc7dd05b 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js | |||
@@ -36,6 +36,13 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
36 | 36 | ||
37 | _zoomFactor: { value: 100, enumerable: false }, | 37 | _zoomFactor: { value: 100, enumerable: false }, |
38 | 38 | ||
39 | _codeEditor: { | ||
40 | value: { | ||
41 | "editor": { value: null, enumerable: false }, | ||
42 | "hline": { value: null, enumerable: false } | ||
43 | } | ||
44 | }, | ||
45 | |||
39 | // PUBLIC MEMBERS | 46 | // PUBLIC MEMBERS |
40 | cssLoadInterval: { value: null, enumerable: false }, | 47 | cssLoadInterval: { value: null, enumerable: false }, |
41 | 48 | ||
@@ -44,6 +51,11 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
44 | */ | 51 | */ |
45 | 52 | ||
46 | // GETTERS / SETTERS | 53 | // GETTERS / SETTERS |
54 | editor: { | ||
55 | get: function() { return this._codeEditor.editor; }, | ||
56 | set: function(value) { this._codeEditor.editor = value} | ||
57 | }, | ||
58 | |||
47 | selectionExclude: { | 59 | selectionExclude: { |
48 | get: function() { return this._selectionExclude; }, | 60 | get: function() { return this._selectionExclude; }, |
49 | set: function(value) { this._selectionExclude = value; } | 61 | set: function(value) { this._selectionExclude = value; } |
diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index a9081cb5..156aaacb 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js | |||
@@ -17,6 +17,8 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base | |||
17 | } | 17 | } |
18 | }, | 18 | }, |
19 | 19 | ||
20 | _textArea: {value: null, enumerable: false }, | ||
21 | |||
20 | _source: { value: null, enumerable: false}, | 22 | _source: { value: null, enumerable: false}, |
21 | 23 | ||
22 | source: { | 24 | source: { |
@@ -31,6 +33,10 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base | |||
31 | 33 | ||
32 | 34 | ||
33 | // GETTERS / SETTERS | 35 | // GETTERS / SETTERS |
36 | textArea: { | ||
37 | get: function() { return this._textArea; }, | ||
38 | set: function(value) { this._textArea = value; } | ||
39 | }, | ||
34 | editor: { | 40 | editor: { |
35 | get: function() { return this._codeEditor.editor; }, | 41 | get: function() { return this._codeEditor.editor; }, |
36 | set: function(value) { this._codeEditor.editor = value} | 42 | set: function(value) { this._codeEditor.editor = value} |
@@ -44,8 +50,8 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base | |||
44 | 50 | ||
45 | // PUBLIC METHODS | 51 | // PUBLIC METHODS |
46 | initialize: { | 52 | initialize: { |
47 | value: function(doc, uuid, textArea, callback) { | 53 | value: function(doc, uuid, textArea, container, callback) { |
48 | this.init(doc.name, doc.uri, doc.type, textArea, uuid, null, doc.externalUri); | 54 | this.init(doc.name, doc.uri, doc.type, container, uuid); |
49 | this.currentView = "code"; | 55 | this.currentView = "code"; |
50 | this.textArea = textArea; | 56 | this.textArea = textArea; |
51 | 57 | ||
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 3a007028..717606b5 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -926,7 +926,6 @@ exports.CoreIoApi = Montage.create(Component, { | |||
926 | // 204 - The file exists and response body has writable flag | 926 | // 204 - The file exists and response body has writable flag |
927 | // 404 - the file does not exist | 927 | // 404 - the file does not exist |
928 | // 500 - unknown server error occurred | 928 | // 500 - unknown server error occurred |
929 | //TODO:to be finalized | ||
930 | isFileWritable:{ | 929 | isFileWritable:{ |
931 | enumerable:true, | 930 | enumerable:true, |
932 | writable:false, | 931 | writable:false, |