aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/document-text.js43
-rwxr-xr-xjs/document/models/text.js4
-rwxr-xr-xjs/document/views/code.js193
3 files changed, 231 insertions, 9 deletions
diff --git a/js/document/document-text.js b/js/document/document-text.js
index 2a469144..533b32c9 100755
--- a/js/document/document-text.js
+++ b/js/document/document-text.js
@@ -7,7 +7,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
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, {
@@ -16,9 +18,44 @@ exports.TextDocument = Montage.create(Component, {
16 hasTemplate: { 18 hasTemplate: {
17 enumerable: false, 19 enumerable: false,
18 value: false 20 value: false
19 } 21 },
20 ////////////////////////////////////////////////////////////////////
21 //////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////
23 //
24 model: {
25 value: null
26 },
27 ////////////////////////////////////////////////////////////////////
28 //
29
30 init:{
31 enumerable: false,
32 value : function(file, context, callback, view){
33 var codeDocumentView = CodeDocumentView.create(), container = null;
34 codeDocumentView.initialize();
35
36 //Creating instance of Text Document Model
37 this.model = Montage.create(TextDocumentModel,{
38 file: {value: file},
39 parentContainer: {value: document.getElementById("codeViewContainer")},
40 views: {value: {'code': codeDocumentView, 'design': null}}
41 });
42
43 codeDocumentView.textArea.value = file.content;
44 codeDocumentView.initializeTextView(file, this);
45
46 if (view === 'code') {
47 //TODO: Remove reference and use as part of model
48 this.currentView = 'code';
49 //Setting current view object to design
50 this.model.currentView = this.model.views.code;
51 }
52
53
54 callback.call(context, this);
55 }
56 }
57////////////////////////////////////////////////////////////////////
58////////////////////////////////////////////////////////////////////
22}); 59});
23//////////////////////////////////////////////////////////////////////// 60////////////////////////////////////////////////////////////////////////
24//////////////////////////////////////////////////////////////////////// \ No newline at end of file 61//////////////////////////////////////////////////////////////////////// \ No newline at end of file
diff --git a/js/document/models/text.js b/js/document/models/text.js
index ebf9993e..5a5e86ef 100755
--- a/js/document/models/text.js
+++ b/js/document/models/text.js
@@ -7,7 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7//////////////////////////////////////////////////////////////////////// 7////////////////////////////////////////////////////////////////////////
8// 8//
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 BaseDocumentModel = require("js/document/models/text").BaseDocumentModel; 10 BaseDocumentModel = require("js/document/models/base").BaseDocumentModel;
11//////////////////////////////////////////////////////////////////////// 11////////////////////////////////////////////////////////////////////////
12// 12//
13exports.TextDocumentModel = Montage.create(BaseDocumentModel, { 13exports.TextDocumentModel = Montage.create(BaseDocumentModel, {
@@ -17,8 +17,6 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, {
17 enumerable: false, 17 enumerable: false,
18 value: false 18 value: false
19 } 19 }
20 ////////////////////////////////////////////////////////////////////
21 ////////////////////////////////////////////////////////////////////
22}); 20});
23//////////////////////////////////////////////////////////////////////// 21////////////////////////////////////////////////////////////////////////
24//////////////////////////////////////////////////////////////////////// \ No newline at end of file 22//////////////////////////////////////////////////////////////////////// \ No newline at end of file
diff --git a/js/document/views/code.js b/js/document/views/code.js
index cd3e02d4..de12881c 100755
--- a/js/document/views/code.js
+++ b/js/document/views/code.js
@@ -11,15 +11,202 @@ var Montage = require("montage/core/core").Montage,
11 BaseDocumentView = require("js/document/views/base").BaseDocumentView; 11 BaseDocumentView = require("js/document/views/base").BaseDocumentView;
12//////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////
13// 13//
14exports.CodeDocumentView = Montage.create(BaseDocumentView, { 14var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentView, {
15 //////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////
16 // 16 //
17 hasTemplate: { 17 hasTemplate: {
18 enumerable: false, 18 enumerable: false,
19 value: false 19 value: false
20 },
21
22 ////////////////////////////////////////////////////////////////////
23 //
24 _editor: {
25 value: null
26 },
27 ////////////////////////////////////////////////////////////////////
28 //
29 editor: {
30 get: function() {return this._editor;},
31 set: function(value) {this._editor= value;}
32 },
33 ////////////////////////////////////////////////////////////////////
34 //
35 _textArea: {
36 value: null
37 },
38 ////////////////////////////////////////////////////////////////////
39 //
40 textArea: {
41 get: function() {return this._textArea;},
42 set: function(value) {this._textArea= value;}
43 },
44
45 ////////////////////////////////////////////////////////////////////
46 //remove _extParentContainer after moving to bucket structure for documents
47 _textParentContainer: {
48 value: null
49 },
50 ////////////////////////////////////////////////////////////////////
51 //
52 textParentContainer: {
53 get: function() {return this._textParentContainer;},
54 set: function(value) {this._textParentContainer= value;}
55 },
56 ////////////////////////////////////////////////////////////////////
57 //
58 _textViewContainer: {
59 value: null
60 },
61 ////////////////////////////////////////////////////////////////////
62 //
63 textViewContainer: {
64 get: function() {return this._textViewContainer;},
65 set: function(value) {this._textViewContainer= value;}
66 },
67 ////////////////////////////////////////////////////////////////////
68 //
69
70 /**
71 * Public method
72 */
73 initialize:{
74 value: function(){
75 //populate _textParentContainer
76 this.textParentContainer = document.getElementById("codeViewContainer");
77
78 //create contianer
79 this.textViewContainer = document.createElement("div");
80 //this.textViewContainer.id = "codemirror_" + uuid;
81 this.textViewContainer.style.display = "block";
82 this.textParentContainer.appendChild(this.textViewContainer);
83
84 //create text area
85 this.textArea = this.createTextAreaElement();
86 }
87 },
88
89 /**
90 * Public method
91 * Creates a textarea element which will contain the content of the opened text document.
92 */
93 createTextAreaElement: {
94 value: function() {
95 var textArea = document.createElement("textarea");
96// textArea.id = "code";
97// textArea.name = "code";
98 this.textViewContainer.appendChild(textArea);
99
100 return textArea;
101 }
102 },
103 ////////////////////////////////////////////////////////////////////
104 //
105 /**
106 * Public method
107 * Creates a new instance of a code editor
108 */
109 initializeTextView: {
110 value: function(file, textDocument) {
111 var type;
112
113 if(this.activeDocument) {
114 //need to hide only if another document was open before
115// this.application.ninja.documentController._hideCurrentDocument();
116// this.hideOtherDocuments(doc.uuid);
117 }
118
119 switch(file.extension) {
120 case "css" :
121 type = "css";
122 break;
123 case "js" :
124 type = "javascript";
125 break;
126 case "html" :
127 type = "htmlmixed";
128 break;
129 case "json" :
130 type = "javascript";
131 break;
132 case "php" :
133 type = "php";
134 break;
135 case "pl" :
136 type = "perl";
137 break;
138 case "py" :
139 type = "python";
140 break;
141 case "rb" :
142 type = "ruby";
143 break;
144 case "xml" :
145 type = "xml";
146 break;
147 }
148 this.textViewContainer.style.display="block";
149
150 this.editor = this.application.ninja.codeEditorController.createEditor(this, type, file.extension, textDocument);
151 this.editor.hline = this.editor.setLineClass(0, "activeline");
152
153
154