aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnanya Sen2012-02-15 10:01:59 -0800
committerAnanya Sen2012-02-15 10:01:59 -0800
commitb8782f2e3dd106accbb0160a98e6b498f26752ea (patch)
treeca279bd78d65cf59249efd693c281c70a74c7b69
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>
-rwxr-xr-xjs/controllers/document-controller.js6
-rwxr-xr-xjs/document/models/text-document.js156
-rwxr-xr-xjs/io/document/base-document.js113
3 files changed, 160 insertions, 115 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 9ece27f9..9b412576 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -9,8 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component, 10 Component = require("montage/ui/component").Component,
11 Uuid = require("montage/core/uuid").Uuid, 11 Uuid = require("montage/core/uuid").Uuid,
12 HTMLDocument = require("js/io/document/html-document").HTMLDocument, 12 HTMLDocument = require("js/document/models/html-document").HTMLDocument,
13 TextDocument = require("js/io/document/text-document").TextDocument, 13 TextDocument = require("js/document/models/text-document").TextDocument,
14 DocumentController; 14 DocumentController;
15//////////////////////////////////////////////////////////////////////// 15////////////////////////////////////////////////////////////////////////
16// 16//
@@ -203,7 +203,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
203 break; 203 break;
204 default: 204 default:
205 //Open in code view 205 //Open in code view
206 var code = Montage.create(BaseDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; 206 var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea;
207 textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); 207 textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid);
208 code.initialize(doc, docuuid, textArea, textArea.parentNode); 208 code.initialize(doc, docuuid, textArea, textArea.parentNode);
209 //code.init(doc.name, doc.uri, doc.extension, null, docuuid); 209 //code.init(doc.name, doc.uri, doc.extension, null, docuuid);
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
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js
index 45c340ce..918b51ad 100755
--- a/js/io/document/base-document.js
+++ b/js/io/document/base-document.js
@@ -9,115 +9,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage; 9var Montage = require("montage/core/core").Montage;
10 10
11var BaseDocument = exports.BaseDocument = Montage.create(Montage, { 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},