diff options
author | Ananya Sen | 2012-02-15 09:58:37 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-15 09:58:37 -0800 |
commit | a90e3be8850b64e8e370aa8ff8cadaa448dd0c82 (patch) | |
tree | e47dbf5dfd4a3e466cc97acbce21262b24cf89e7 /js/io/document/text-document.js | |
parent | 9048cd50bf5e0a418d1d95498bb593961f72db36 (diff) | |
download | ninja-a90e3be8850b64e8e370aa8ff8cadaa448dd0c82.tar.gz |
Revert "Cleaning up"
This reverts commit a7952c5a16e2cae3fd1a459b03b9f16bba1004da.
Conflicts:
js/controllers/document-controller.js
js/io/document/text-document.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/document/text-document.js')
-rwxr-xr-x | js/io/document/text-document.js | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js new file mode 100755 index 00000000..87fcc551 --- /dev/null +++ b/js/io/document/text-document.js | |||
@@ -0,0 +1,156 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | //////////////////////////////////////////////////////////////////////// | ||
8 | // | ||
9 | var Montage = require("montage/core/core").Montage, | ||
10 | BaseDocument = require("js/io/document/base-document").BaseDocument; | ||
11 | //////////////////////////////////////////////////////////////////////// | ||
12 | // | ||
13 | exports.TextDocument = Montage.create(BaseDocument, { | ||
14 | // PRIVATE MEMBERS | ||
15 | _codeEditor: { | ||
16 | value: { | ||
17 | "editor": { value: null, enumerable: false }, | ||
18 | |||
19 | } | ||
20 | }, | ||
21 | |||
22 | _editor: { value: null, enumerable: false }, | ||
23 | _hline: { value: null, enumerable: false }, | ||
24 | |||
25 | _textArea: {value: null, enumerable: false }, | ||
26 | |||
27 | _userDocument: {value: null, enumerable: false }, | ||
28 | |||
29 | _source: { value: null, enumerable: false}, | ||
30 | |||
31 | source: { | ||
32 | get: function() { return this._source;}, | ||
33 | set: function(value) { this._source = value;} | ||
34 | }, | ||
35 | |||
36 | // PUBLIC MEMBERS | ||
37 | |||
38 | _savedLeftScroll: {value:null}, | ||
39 | _savedTopScroll: {value:null}, | ||
40 | |||
41 | //****************************************// | ||
42 | //PUBLIC API | ||
43 | |||
44 | |||
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 | }, | ||
61 | editor: { | ||
62 | get: function() { return this._editor; }, | ||
63 | set: function(value) { this._editor = value} | ||
64 | }, | ||
65 | |||
66 | hline: { | ||
67 | get: function() { return this._hline; }, | ||
68 | set: function(value) {this._hline = value; } | ||
69 | }, | ||
70 | |||
71 | |||
72 | //////////////////////////////////////////////////////////////////// | ||
73 | // | ||
74 | initialize: { | ||
75 | value: function(file, uuid, textArea, container, callback) { | ||
76 | // | ||
77 | this._userDocument = file; | ||
78 | // | ||
79 | this.init(file.name, file.uri, file.extension, container, uuid, callback); | ||
80 | // | ||
81 | this.currentView = "code"; | ||
82 | this.textArea = textArea; | ||
83 | } | ||
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 | //////////////////////////////////////////////////////////////////// | ||
96 | |||
97 | |||
98 | |||
99 | |||
100 | |||
101 | |||
102 | |||
103 | |||
104 | |||
105 | |||
106 | |||
107 | /* | ||
108 | // PRIVATE METHODS | ||
109 | _loadContent: { | ||
110 | value: function() { | ||
111 | // Start and AJAX call to load the HTML Document as a String | ||
112 | var xhr = new XMLHttpRequest(); | ||
113 | var ref = this; | ||
114 | |||
115 | xhr.onreadystatechange = function() { | ||
116 | if (xhr.readyState == 4) { | ||
117 | ref.source = xhr.responseText; | ||
118 | ref.textArea.innerHTML = xhr.responseText; | ||
119 | //ref.callback(xhr.responseText); | ||
120 | ref.callback(ref); | ||
121 | } | ||
122 | }; | ||
123 | |||
124 | if(this.documentType === "js") { | ||
125 | xhr.open('GET', 'user-document-templates/montage-application-cloud/appdelegate.js'); | ||
126 | } else if(this.documentType === "css") { | ||
127 | xhr.open('GET', 'user-document-templates/montage-application-cloud/default_html.css'); | ||
128 | } else { | ||
129 | xhr.open('GET', 'user-document-templates/montage-application-cloud/index.html'); | ||
130 | } | ||
131 | |||
132 | xhr.send(''); | ||
133 | } | ||
134 | }, | ||
135 | */ | ||
136 | //////////////////////////////////////////////////////////////////// | ||
137 | |||
138 | |||
139 | /** | ||
140 | * public method | ||
141 | */ | ||
142 | /* | ||
143 | save:{ | ||
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 | } | ||
154 | } | ||
155 | */ | ||
156 | }); \ No newline at end of file | ||