aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorAnanya Sen2012-05-18 16:56:16 -0700
committerAnanya Sen2012-05-18 16:56:16 -0700
commit7a22f7b368ef549a5b30c58a0f3900685b764bdb (patch)
tree44951af31368a5b287057e5cdddf0469cdc30298 /js/document/views
parent65cea92d839bcd25ea9094a0798190a4dc4bea35 (diff)
downloadninja-7a22f7b368ef549a5b30c58a0f3900685b764bdb.tar.gz
integrated open code view document in new dom architecture
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document/views')
-rwxr-xr-xjs/document/views/code.js193
1 files changed, 190 insertions, 3 deletions
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 }
155 },
156 ////////////////////////////////////////////////////////////////////
157 //
158
159 showRulers:{
160 value:function(){
161 this.application.ninja.rulerTop.style.display = "block";
162 this.application.ninja.rulerLeft.style.display = "block";
163 }
164 },
165 hideRulers:{
166 value:function(){
167 this.application.ninja.rulerTop.style.display = "none";
168 this.application.ninja.rulerLeft.style.display = "none";
169 }
170 },
171 showCodeViewBar:{
172 value:function(isCodeView){
173 if(isCodeView === true) {
174 this.application.ninja.editorViewOptions.element.style.display = "block";
175 this.application.ninja.documentBar.element.style.display = "none";
176 } else {
177 this.application.ninja.documentBar.element.style.display = "block";
178 this.application.ninja.editorViewOptions.element.style.display = "none";
179 }
180 }
181 },
182
183 collapseAllPanels:{
184 value:function(){
185 this.application.ninja.panelSplitter.collapse();
186 this.application.ninja.timelineSplitter.collapse();
187 this.application.ninja.toolsSplitter.collapse();
188 this.application.ninja.optionsSplitter.collapse();
189 }
190 },
191 restoreAllPanels:{
192 value:function(){
193 this.application.ninja.panelSplitter.restore();
194 this.application.ninja.timelineSplitter.restore();
195 this.application.ninja.toolsSplitter.restore();
196 this.application.ninja.optionsSplitter.restore();
197 }
198 },
199
200 applyTheme:{
201 value:function(themeClass){
202 //Todo: change for bucket structure of documents
203 this.textParentContainer.className = "codeViewContainer "+themeClass;
204 }
20 } 205 }
21 //////////////////////////////////////////////////////////////////// 206
22 //////////////////////////////////////////////////////////////////// 207
208////////////////////////////////////////////////////////////////////////
209////////////////////////////////////////////////////////////////////////
23}); 210});
24//////////////////////////////////////////////////////////////////////// 211////////////////////////////////////////////////////////////////////////
25//////////////////////////////////////////////////////////////////////// \ No newline at end of file 212//////////////////////////////////////////////////////////////////////// \ No newline at end of file