aboutsummaryrefslogtreecommitdiff
path: root/js/document/models/text-document.js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-15 10:01:59 -0800
committerAnanya Sen2012-02-15 10:01:59 -0800
commitb8782f2e3dd106accbb0160a98e6b498f26752ea (patch)
treeca279bd78d65cf59249efd693c281c70a74c7b69 /js/document/models/text-document.js
parenta90e3be8850b64e8e370aa8ff8cadaa448dd0c82 (diff)
downloadninja-b8782f2e3dd106accbb0160a98e6b498f26752ea.tar.gz
Revert "Merging TextDocument into BaseDocument"
This reverts commit 93c8f327d662a7693d1d6ca050a0efd15ebc18ed. Conflicts: js/controllers/document-controller.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document/models/text-document.js')
-rwxr-xr-xjs/document/models/text-document.js156
1 files changed, 156 insertions, 0 deletions
diff --git a/js/document/models/text-document.js b/js/document/models/text-document.js
new file mode 100755
index 00000000..c0d4f256
--- /dev/null
+++ b/js/document/models/text-document.js
@@ -0,0 +1,156 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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//
9var Montage = require("montage/core/core").Montage,
10 BaseDocument = require("js/document/models/base-document").BaseDocument;
11////////////////////////////////////////////////////////////////////////
12//
13exports.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 /*
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 }
154 }
155*/
156}); \ No newline at end of file