aboutsummaryrefslogtreecommitdiff
path: root/js/document/views/code.js
diff options
context:
space:
mode:
authorEric Guzman2012-05-22 15:57:23 -0700
committerEric Guzman2012-05-22 15:57:23 -0700
commitad3b4595d7377e5bf75bcb8ad81007859b0a8a02 (patch)
treeecb7fe289824a625b1dc422a97c2236826081ec3 /js/document/views/code.js
parent0eb95ff2dbba1fe7213eed2e0140b4d07bda3dd5 (diff)
parent2b207ef8b2594927f8cd6cd63a8483d205cb86c4 (diff)
downloadninja-ad3b4595d7377e5bf75bcb8ad81007859b0a8a02.tar.gz
Merge branch 'dom-architecture' of github.com:Motorola-Mobility/ninja-internal into CSSPanelUpdates
Conflicts: js/controllers/styles-controller.js
Diffstat (limited to 'js/document/views/code.js')
-rwxr-xr-xjs/document/views/code.js152
1 files changed, 149 insertions, 3 deletions
diff --git a/js/document/views/code.js b/js/document/views/code.js
index cd3e02d4..66d1c702 100755
--- a/js/document/views/code.js
+++ b/js/document/views/code.js
@@ -11,15 +11,161 @@ 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 _textViewContainer: {
47 value: null
48 },
49 ////////////////////////////////////////////////////////////////////
50 //
51 textViewContainer: {
52 get: function() {return this._textViewContainer;},
53 set: function(value) {this._textViewContainer= value;}
54 },
55 ////////////////////////////////////////////////////////////////////
56 //
57
58 /**
59 * Public method
60 */
61 initialize:{
62 value: function(parentContainer){
63 //create contianer
64 this.textViewContainer = document.createElement("div");
65 //this.textViewContainer.id = "codemirror_" + uuid;
66 this.textViewContainer.style.display = "block";
67 parentContainer.appendChild(this.textViewContainer);
68
69 //create text area
70 this.textArea = this.createTextAreaElement();
71 }
72 },
73
74 /**
75 * Public method
76 * Creates a textarea element which will contain the content of the opened text document.
77 */
78 createTextAreaElement: {
79 value: function() {
80 var textArea = document.createElement("textarea");
81// textArea.id = "code";
82// textArea.name = "code";
83 this.textViewContainer.appendChild(textArea);
84
85 return textArea;
86 }
87 },
88 ////////////////////////////////////////////////////////////////////
89 //
90 /**
91 * Public method
92 * Creates a new instance of a code editor
93 */
94 initializeTextView: {
95 value: function(file, textDocument) {
96 var type;
97
98 if(this.activeDocument) {
99 //need to hide only if another document was open before
100// this.application.ninja.documentController._hideCurrentDocument();
101// this.hideOtherDocuments(doc.uuid);
102 }
103
104 switch(file.extension) {
105 case "css" :
106 type = "css";
107 break;
108 case "js" :
109 type = "javascript";
110 break;
111 case "html" :
112 type = "htmlmixed";
113 break;
114 case "json" :
115 type = "javascript";
116 break;
117 case "php" :
118 type = "php";
119 break;
120 case "pl" :
121 type = "perl";
122 break;
123 case "py" :
124 type = "python";
125 break;
126 case "rb" :
127 type = "ruby";
128 break;
129 case "xml" :
130 type = "xml";
131 break;
132 }
133 this.textViewContainer.style.display="block";
134
135 this.editor = this.application.ninja.codeEditorController.createEditor(this, type, file.extension, textDocument);
136 this.editor.hline = this.editor.setLineClass(0, "activeline");
137
138
139 }
140 },
141 ////////////////////////////////////////////////////////////////////
142 //
143 show: {
144 value: function (callback) {
145 this.textViewContainer.style.display = "block";
146 //
147 if (callback) callback();
148 }
149 },
150 ////////////////////////////////////////////////////////////////////
151 //
152 hide: {
153 value: function (callback) {
154 this.textViewContainer.style.display = "none";
155 //
156 if (callback) callback();
157 }
158 },
159 ////////////////////////////////////////////////////////////////////
160 //
161 applyTheme:{
162 value:function(themeClass){
163 //Todo: change for bucket structure of documents
164 this.textViewContainer.className = "codeViewContainer "+themeClass;
165 }
20 } 166 }
21 //////////////////////////////////////////////////////////////////// 167////////////////////////////////////////////////////////////////////////
22 //////////////////////////////////////////////////////////////////// 168////////////////////////////////////////////////////////////////////////
23}); 169});
24//////////////////////////////////////////////////////////////////////// 170////////////////////////////////////////////////////////////////////////
25//////////////////////////////////////////////////////////////////////// \ No newline at end of file 171//////////////////////////////////////////////////////////////////////// \ No newline at end of file