aboutsummaryrefslogtreecommitdiff
path: root/js/io/document/text-document.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/document/text-document.js')
-rwxr-xr-x[-rw-r--r--]js/io/document/text-document.js115
1 files changed, 90 insertions, 25 deletions
diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js
index 3506891a..e149c479 100644..100755
--- a/js/io/document/text-document.js
+++ b/js/io/document/text-document.js
@@ -4,29 +4,30 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage; 7////////////////////////////////////////////////////////////////////////
8var baseDocumentModule = require("js/io/document/base-document"); 8//
9 9var Montage = require("montage/core/core").Montage,
10 10 BaseDocument = require("js/io/document/base-document").BaseDocument;
11var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.BaseDocument, { 11////////////////////////////////////////////////////////////////////////
12//
13var TextDocument = exports.TextDocument = Montage.create(BaseDocument, {
12 // PRIVATE MEMBERS 14 // PRIVATE MEMBERS
13 _codeEditor: { 15 _codeEditor: {
14 value: { 16 value: {
15 "editor": { value: null, enumerable: false }, 17 "editor": { value: null, enumerable: false },
16 "hline": { value: null, enumerable: false } 18
17 } 19 }
18 }, 20 },
19 21
20 _textArea: { value: null, enumerable: false }, 22 _editor: { value: null, enumerable: false },
23 _hline: { value: null, enumerable: false },
21 24
22 // Temporary Save the source 25 _textArea: {value: null, enumerable: false },
26
27 _userDocument: {value: null, enumerable: false },
28
23 _source: { value: null, enumerable: false}, 29 _source: { value: null, enumerable: false},
24 30
25 textArea: {
26 get: function() { return this._textArea;},
27 set: function(value) { this._textArea = value; }
28 },
29
30 source: { 31 source: {
31 get: function() { return this._source;}, 32 get: function() { return this._source;},
32 set: function(value) { this._source = value;} 33 set: function(value) { this._source = value;}
@@ -34,33 +35,77 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base
34 35
35 // PUBLIC MEMBERS 36 // PUBLIC MEMBERS
36 37
38 _savedLeftScroll: {value:null},
39 _savedTopScroll: {value:null},
40
37 //****************************************// 41 //****************************************//
38 //PUBLIC API 42 //PUBLIC API
39 43
40 44
41 // GETTERS / SETTERS 45 // GETTERS / SETTERS
46
47 savedLeftScroll:{
48 get: function() { return this._savedLeftScroll; },
49 set: function(value) { this._savedLeftScroll = value}
50 },
51
52 savedTopScroll:{
53 get: function() { return this._savedTopScroll; },
54 set: function(value) { this._savedTopScroll = value}
55 },
56
57 textArea: {
58 get: function() { return this._textArea; },
59 set: function(value) { this._textArea = value; }
60 },
42 editor: { 61 editor: {
43 get: function() { return this._codeEditor.editor; }, 62 get: function() { return this._editor; },
44 set: function(value) { this._codeEditor.editor = value} 63 set: function(value) { this._editor = value}
45 }, 64 },
46 65
47 hline: { 66 hline: {
48 get: function() { return this._codeEditor.hline; }, 67 get: function() { return this._hline; },
49 set: function(value) {this._codeEditor.hline = value; } 68 set: function(value) {this._hline = value; }
50 }, 69 },
51 70
52 71
53 // PUBLIC METHODS 72 ////////////////////////////////////////////////////////////////////
73 //
54 initialize: { 74 initialize: {
55 value: function(doc, uuid, textArea, callback) { 75 value: function(file, uuid, textArea, container, callback) {
56 this.init(doc.name, doc.uri, doc.type, textArea, uuid, callback); 76 //
57 this.textArea = textArea.firstChild; 77 this._userDocument = file;
58 this.currentView = "code"; 78 //
59 this._loadContent(); 79 this.init(file.name, file.uri, file.extension, container, uuid, callback);
80 //
81 this.currentView = "code";
82 this.textArea = textArea;
60 } 83 }
61 }, 84 },
85 ////////////////////////////////////////////////////////////////////
86 //
87 save: {
88 enumerable: false,
89 value: function () {
90 //TODO: Improve sequence
91 this.editor.save();
92 return {mode: this._userDocument.extension, document: this._userDocument, content: this.textArea.value};
93 }
94 }
95 ////////////////////////////////////////////////////////////////////
62 96
63 // PRIVATE METHODS 97
98
99
100
101
102
103
104
105
106
107 /*
108// PRIVATE METHODS
64 _loadContent: { 109 _loadContent: {
65 value: function() { 110 value: function() {
66 // Start and AJAX call to load the HTML Document as a String 111 // Start and AJAX call to load the HTML Document as a String
@@ -86,6 +131,26 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base
86 131
87 xhr.send(''); 132 xhr.send('');
88 } 133 }
134 },
135*/
136 ////////////////////////////////////////////////////////////////////
137
138
139 /**
140 * public method
141 */
142 /*
143save:{
144 value:function(){
145 try{
146 this.editor.save();
147 //persist textArea.value to filesystem
148 this.dirtyFlag=false;
149 }catch(e){
150 console.log("Error while saving "+this.uri);
151 console.log(e.stack);
152 }
153 }
89 } 154 }
90 155*/
91}); \ No newline at end of file 156}); \ No newline at end of file