aboutsummaryrefslogtreecommitdiff
path: root/js/document/models/base-document.js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-15 09:51:12 -0800
committerAnanya Sen2012-02-15 09:51:12 -0800
commit9048cd50bf5e0a418d1d95498bb593961f72db36 (patch)
tree90d029bebddfcd4a8aa4ad6bb9730200b4b3f823 /js/document/models/base-document.js
parent2e308be9bec5e06d81b2905b65005a232f0a190d (diff)
downloadninja-9048cd50bf5e0a418d1d95498bb593961f72db36.tar.gz
Revert "Reverting text/html document classes and setting up MVC folder structure"
This reverts commit 68ce64a5a2f4a71b54d33916aaf1d57161302425. Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document/models/base-document.js')
-rwxr-xr-xjs/document/models/base-document.js204
1 files changed, 204 insertions, 0 deletions
diff --git a/js/document/models/base-document.js b/js/document/models/base-document.js
new file mode 100755
index 00000000..45c340ce
--- /dev/null
+++ b/js/document/models/base-document.js
@@ -0,0 +1,204 @@
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//BaseDocument Object for all files types and base class for HTML documents.
8
9var Montage = require("montage/core/core").Montage;
10
11var BaseDocument = exports.BaseDocument = Montage.create(Montage, {
12
13
14 //TODO: Clean up, test
15
16
17
18
19
20 ////////////////////////////////////////////////////////////////////
21 ////////////////////////////////////////////////////////////////////
22 ////////////////////////////////////////////////////////////////////
23 ////////////////////////////////////////////////////////////////////
24 //Taken from text-document, which shouldn't be needed
25
26 // PRIVATE MEMBERS
27 _codeEditor: {
28 value: {
29 "editor": { value: null, enumerable: false },
30
31 }
32 },
33
34 _editor: { value: null, enumerable: false },
35 _hline: { value: null, enumerable: false },
36
37 _textArea: {value: null, enumerable: false },
38
39 _userDocument: {value: null, enumerable: false },
40
41 _source: { value: null, enumerable: false},
42
43 source: {
44 get: function() { return this._source;},
45 set: function(value) { this._source = value;}
46 },
47
48 // PUBLIC MEMBERS
49
50 _savedLeftScroll: {value:null},
51 _savedTopScroll: {value:null},
52
53 //****************************************//
54 //PUBLIC API
55
56
57 // GETTERS / SETTERS
58
59 savedLeftScroll:{
60 get: function() { return this._savedLeftScroll; },
61 set: function(value) { this._savedLeftScroll = value}
62 },
63
64 savedTopScroll:{
65 get: function() { return this._savedTopScroll; },
66 set: function(value) { this._savedTopScroll = value}
67 },
68
69 textArea: {
70 get: function() { return this._textArea; },
71 set: function(value) { this._textArea = value; }
72 },
73 editor: {
74 get: function() { return this._editor; },
75 set: function(value) { this._editor = value}
76 },
77
78 hline: {
79 get: function() { return this._hline; },
80 set: function(value) {this._hline = value; }
81 },
82
83
84 ////////////////////////////////////////////////////////////////////
85 //
86 initialize: {
87 value: function(file, uuid, textArea, container, callback) {
88 //
89 this._userDocument = file;
90 //
91 this.init(file.name, file.uri, file.extension, container, uuid, callback);
92 //
93 this.currentView = "code";
94 this.textArea = textArea;
95 }
96 },
97 ////////////////////////////////////////////////////////////////////
98 //
99 save: {
100 enumerable: false,
101 value: function () {
102 //TODO: Improve sequence
103 this.editor.save();
104 return {mode: this._userDocument.extension, document: this._userDocument, content: this.textArea.value};
105 }
106 },
107 ////////////////////////////////////////////////////////////////////
108 ////////////////////////////////////////////////////////////////////
109 ////////////////////////////////////////////////////////////////////
110 ////////////////////////////////////////////////////////////////////
111
112
113
114
115
116
117
118
119
120
121 /** Private Members **/
122 _name: { value: null, enumerable: false },
123 _uri: { value: null, enumerable: false },
124 _documentType: { value: null, enumerable: false },
125 _container: {value: null, enumerable: false },
126 _uuid: { value: null, enumerable: false },
127 _isActive: { value: true, enumerable: false },
128 _dirtyFlag: { value: false, enumerable: false },
129 _callback: { value: null, enumerable: false },
130 _currentView: { value: null, enumerable: false},
131
132 /** Getters/Setters **/
133 name: {
134 get: function() { return this._name; },
135 set: function(value) { this._name = value; }
136 },
137
138 uri: {
139 get: function() { return this._uri; },
140 set: function(value) { this._uri = value; }
141 },
142
143 documentType: {
144 get: function() { return this._documentType; },
145 set: function(value) { this._documentType = value; }
146 },
147
148 container: {
149 get: function() { return this._container; },
150 set: function(value) { this._container = value; }
151 },
152
153 uuid: {
154 get: function() { return this._uuid; },
155 set: function(value) { this._uuid = value; }
156 },
157
158 isActive: {
159 get: function() { return this._isActive; },
160 set: function(value) { this._isActive = value; }
161 },
162
163 dirtyFlag: {
164 get: function() { return this._dirtyFlag; },
165 set: function(value) { this._dirtyFlag = value; }
166 },
167
168 callback: {
169 get: function() { return this._callback; },
170 set: function(value) { this._callback = value; }
171 },
172
173 currentView: {
174 get: function() { return this._currentView; },
175 set: function(value) { this._currentView = value }
176 },
177
178 /** Base Methods **/
179 init: {
180 value: function(name, uri, type, container, uuid, callback) {
181 this.name = name;
182 this.uri = uri;
183 this.documentType = type;
184 this.container = container;
185 this.uuid = uuid;
186 this.callback = callback;
187 }
188 },
189
190 loadDocument: {
191 value: function() {
192 // Have the XHR here?
193 }
194 }/*
195,
196
197 save:{
198 value:function(){
199 //base function - to be overridden
200 }
201 }
202*/
203
204}); \ No newline at end of file