aboutsummaryrefslogtreecommitdiff
path: root/js/document/document-text.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/document-text.js')
-rwxr-xr-xjs/document/document-text.js57
1 files changed, 52 insertions, 5 deletions
diff --git a/js/document/document-text.js b/js/document/document-text.js
index 2a469144..811cc8ce 100755
--- a/js/document/document-text.js
+++ b/js/document/document-text.js
@@ -6,19 +6,66 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7//////////////////////////////////////////////////////////////////////// 7////////////////////////////////////////////////////////////////////////
8// 8//
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 TextDocumentModel = require("js/document/models/text").TextDocumentModel,
12 CodeDocumentView = require("js/document/views/code").CodeDocumentView;
11//////////////////////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////////////////////
12// 14//
13exports.TextDocument = Montage.create(Component, { 15exports.TextDocument = Montage.create(Component, {
14 //////////////////////////////////////////////////////////////////// 16 ////////////////////////////////////////////////////////////////////
15 // 17 //
16 hasTemplate: { 18 hasTemplate: {
17 enumerable: false,
18 value: false 19 value: false
19 } 20 },
20 ////////////////////////////////////////////////////////////////////
21 //////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////
22 //
23 model: {
24 value: null
25 },
26 ////////////////////////////////////////////////////////////////////
27 //
28 init:{
29 value: function(file, context, callback, view){
30 //
31 var codeDocumentView = CodeDocumentView.create(), container = null; //TODO: Why is this initilzied to null?
32 //Creating instance of Text Document Model
33 this.model = Montage.create(TextDocumentModel,{
34 file: {value: file},
35 parentContainer: {value: document.getElementById("codeViewContainer")}, //TODO: Remove reference to this element, should be dynamic
36 views: {value: {'code': codeDocumentView, 'design': null}} //TODO: Add check if file might have design view, if so, then create it
37 });
38 //TODO: Add design view logic
39 //Initilizing view(s)
40 codeDocumentView.initialize(this.model.parentContainer);
41 //Checking for view specified
42 if (view === 'code') {
43 //TODO: Remove reference and use as part of model
44 this.currentView = 'code';
45 //Setting current view object to design
46 this.model.currentView = this.model.views.code;
47 //Rendering view
48 codeDocumentView.textArea.value = file.content;
49 codeDocumentView.initializeTextView(file, this);
50 } else {
51 //Other view(s) logic goes here
52 }
53 //Checking if callback is needed
54 if (callback) callback.call(context, this);
55 }
56 },
57 ////////////////////////////////////////////////////////////////////
58 //
59 closeDocument: {
60 value: function (context, callback) {
61 //Closing document and getting outcome
62 var closed = this.model.close(null);
63 //Making callback if specified
64 if (callback) callback.call(context, this);
65 }
66 }
67 ////////////////////////////////////////////////////////////////////
68 ////////////////////////////////////////////////////////////////////
22}); 69});
23//////////////////////////////////////////////////////////////////////// 70////////////////////////////////////////////////////////////////////////
24//////////////////////////////////////////////////////////////////////// \ No newline at end of file 71//////////////////////////////////////////////////////////////////////// \ No newline at end of file