aboutsummaryrefslogtreecommitdiff
path: root/js/io/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/document')
-rwxr-xr-xjs/io/document/base-document.js204
-rwxr-xr-xjs/io/document/html-document.js492
-rwxr-xr-xjs/io/document/text-document.js156
3 files changed, 852 insertions, 0 deletions
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js
new file mode 100755
index 00000000..45c340ce
--- /dev/null
+++ b/js/io/document/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
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js
new file mode 100755
index 00000000..ac556c2d
--- /dev/null
+++ b/js/io/document/html-document.js
@@ -0,0 +1,492 @@
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/io/document/base-document").BaseDocument,
11 NJUtils = require("js/lib/NJUtils").NJUtils;
12////////////////////////////////////////////////////////////////////////
13//
14exports.HTMLDocument = Montage.create(BaseDocument, {
15 // PRIVATE MEMBERS
16 _selectionExclude: { value: null, enumerable: false },
17 _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false},
18 _iframe: { value: null, enumerable: false },
19 _server: { value: null, enumerable: false },
20 _templateDocument: { value: null, enumerable: false },
21 _selectionModel: { value: [], enumerable: false },
22 _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false},
23
24 _document: { value: null, enumerable: false },
25 _documentRoot: { value: null, enumerable: false },
26 _stageBG: { value: null, enumerable: false },
27 _window: { value: null, enumerable: false },
28 _styles: { value: null, enumerable: false },
29 _stylesheets: { value: null, enumerable: false },
30 _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false },
31 _userDocument: { value: null, enumerable: false },
32 _htmlSource: {value: "<html></html>", enumerable: false},
33 _glData: {value: null, enumerable: false },