aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js4
-rwxr-xr-xjs/document/models/base-document.js113
-rwxr-xr-xjs/document/models/text-document.js156
3 files changed, 114 insertions, 159 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 9b412576..25f60cc5 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -10,7 +10,7 @@ var 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/document/models/html-document").HTMLDocument, 12 HTMLDocument = require("js/document/models/html-document").HTMLDocument,
13 TextDocument = require("js/document/models/text-document").TextDocument, 13 BaseDocument = require("js/document/models/base-document").BaseDocument,
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(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; 206 var code = Montage.create(BaseDocument, {"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/base-document.js b/js/document/models/base-document.js
index 918b51ad..45c340ce 100755
--- a/js/document/models/base-document.js
+++ b/js/document/models/base-document.js
@@ -9,6 +9,115 @@ 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},
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
12 /** Private Members **/ 121 /** Private Members **/
13 _name: { value: null, enumerable: false }, 122 _name: { value: null, enumerable: false },
14 _uri: { value: null, enumerable: false }, 123 _uri: { value: null, enumerable: false },
@@ -82,12 +191,14 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, {
82 value: function() { 191 value: function() {
83 // Have the XHR here? 192 // Have the XHR here?
84 } 193 }
85 }, 194 }/*
195,
86 196
87 save:{ 197 save:{
88 value:function(){ 198 value:function(){
89 //base function - to be overridden 199 //base function - to be overridden
90 } 200 }
91 } 201 }
202*/
92 203
93}); \ No newline at end of file 204}); \ No newline at end of file
diff --git a/js/document/models/text-document.js b/js/document/models/text-document.js
deleted file mode 100755
index c0d4f256..00000000
--- a/js/document/models/text-document.js
+++ /dev/null
@@ -1,156 +0,0 @@
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