aboutsummaryrefslogtreecommitdiff
path: root/js/document/views/code.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-05-30 18:41:07 -0700
committerArmen Kesablyan2012-05-30 18:41:07 -0700
commitb7e33c16bab26f8ee0daa61f920cfdbcb7abc6e3 (patch)
tree4629ccd709fd9b818ba4c8311dd19aa7b68a461e /js/document/views/code.js
parenta581fb3c544ee2faeafbb75f7a3f5719f53cf323 (diff)
parentd49c909cff7f0c5e5d0b127ad84a2fefc6677dc6 (diff)
downloadninja-b7e33c16bab26f8ee0daa61f920cfdbcb7abc6e3.tar.gz
Merge branch 'refs/heads/master' into binding
Diffstat (limited to 'js/document/views/code.js')
-rwxr-xr-xjs/document/views/code.js56
1 files changed, 22 insertions, 34 deletions
diff --git a/js/document/views/code.js b/js/document/views/code.js
index 66d1c702..0a0ff5c1 100755
--- a/js/document/views/code.js
+++ b/js/document/views/code.js
@@ -10,15 +10,13 @@ var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component, 10 Component = require("montage/ui/component").Component,
11 BaseDocumentView = require("js/document/views/base").BaseDocumentView; 11 BaseDocumentView = require("js/document/views/base").BaseDocumentView;
12//////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////
13// 13//
14var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentView, { 14exports.CodeDocumentView = Montage.create(BaseDocumentView, {
15 //////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////
16 // 16 //
17 hasTemplate: { 17 hasTemplate: {
18 enumerable: false,
19 value: false 18 value: false
20 }, 19 },
21
22 //////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////
23 // 21 //
24 _editor: { 22 _editor: {
@@ -28,7 +26,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie
28 // 26 //
29 editor: { 27 editor: {
30 get: function() {return this._editor;}, 28 get: function() {return this._editor;},
31 set: function(value) {this._editor= value;} 29 set: function(value) {this._editor = value;}
32 }, 30 },
33 //////////////////////////////////////////////////////////////////// 31 ////////////////////////////////////////////////////////////////////
34 // 32 //
@@ -39,7 +37,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie
39 // 37 //
40 textArea: { 38 textArea: {
41 get: function() {return this._textArea;}, 39 get: function() {return this._textArea;},
42 set: function(value) {this._textArea= value;} 40 set: function(value) {this._textArea = value;}
43 }, 41 },
44 //////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////
45 // 43 //
@@ -50,14 +48,10 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie
50 // 48 //
51 textViewContainer: { 49 textViewContainer: {
52 get: function() {return this._textViewContainer;}, 50 get: function() {return this._textViewContainer;},
53 set: function(value) {this._textViewContainer= value;} 51 set: function(value) {this._textViewContainer = value;}
54 }, 52 },
55 //////////////////////////////////////////////////////////////////// 53 ////////////////////////////////////////////////////////////////////
56 // 54 //
57
58 /**
59 * Public method
60 */
61 initialize:{ 55 initialize:{
62 value: function(parentContainer){ 56 value: function(parentContainer){
63 //create contianer 57 //create contianer
@@ -65,42 +59,35 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie
65 //this.textViewContainer.id = "codemirror_" + uuid; 59 //this.textViewContainer.id = "codemirror_" + uuid;
66 this.textViewContainer.style.display = "block"; 60 this.textViewContainer.style.display = "block";
67 parentContainer.appendChild(this.textViewContainer); 61 parentContainer.appendChild(this.textViewContainer);
68
69 //create text area 62 //create text area
70 this.textArea = this.createTextAreaElement(); 63 this.textArea = this.createTextAreaElement();
71 } 64 }
72 }, 65 },
73 66 ////////////////////////////////////////////////////////////////////
74 /** 67 //Creates a textarea element which will contain the content of the opened text document
75 * Public method
76 * Creates a textarea element which will contain the content of the opened text document.
77 */
78 createTextAreaElement: { 68 createTextAreaElement: {
79 value: function() { 69 value: function() {
80 var textArea = document.createElement("textarea"); 70 var textArea = document.createElement("textarea");
81// textArea.id = "code"; 71 //textArea.id = "code";
82// textArea.name = "code"; 72 //textArea.name = "code";
83 this.textViewContainer.appendChild(textArea); 73 this.textViewContainer.appendChild(textArea);
84 74 //Returns textarea element
85 return textArea; 75 return textArea;
86 } 76 }
87 }, 77 },
88 //////////////////////////////////////////////////////////////////// 78 ////////////////////////////////////////////////////////////////////
89 // 79 //Creates a new instance of a code editor
90 /**
91 * Public method
92 * Creates a new instance of a code editor
93 */
94 initializeTextView: { 80 initializeTextView: {
95 value: function(file, textDocument) { 81 value: function(file, textDocument) {
82 //
96 var type; 83 var type;
97 84 //
98 if(this.activeDocument) { 85 if(this.activeDocument) {
99 //need to hide only if another document was open before 86 //need to hide only if another document was open before
100// this.application.ninja.documentController._hideCurrentDocument(); 87 //this.application.ninja.documentController._hideCurrentDocument();
101// this.hideOtherDocuments(doc.uuid); 88 //this.hideOtherDocuments(doc.uuid);
102 } 89 }
103 90 //
104 switch(file.extension) { 91 switch(file.extension) {
105 case "css" : 92 case "css" :
106 type = "css"; 93 type = "css";
@@ -130,18 +117,18 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie
130 type = "xml"; 117 type = "xml";
131 break; 118 break;
132 } 119 }
120 //
133 this.textViewContainer.style.display="block"; 121 this.textViewContainer.style.display="block";
134 122 //
135 this.editor = this.application.ninja.codeEditorController.createEditor(this, type, file.extension, textDocument); 123 this.editor = this.application.ninja.codeEditorController.createEditor(this, type, file.extension, textDocument);
136 this.editor.hline = this.editor.setLineClass(0, "activeline"); 124 this.editor.hline = this.editor.setLineClass(0, "activeline");
137
138
139 } 125 }
140 }, 126 },
141 //////////////////////////////////////////////////////////////////// 127 ////////////////////////////////////////////////////////////////////
142 // 128 //
143 show: { 129 show: {
144 value: function (callback) { 130 value: function (callback) {
131 //
145 this.textViewContainer.style.display = "block"; 132 this.textViewContainer.style.display = "block";
146 // 133 //
147 if (callback) callback(); 134 if (callback) callback();
@@ -151,6 +138,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie
151 // 138 //
152 hide: { 139 hide: {
153 value: function (callback) { 140 value: function (callback) {
141 //
154 this.textViewContainer.style.display = "none"; 142 this.textViewContainer.style.display = "none";
155 // 143 //
156 if (callback) callback(); 144 if (callback) callback();
@@ -164,8 +152,8 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie
164 this.textViewContainer.className = "codeViewContainer "+themeClass; 152 this.textViewContainer.className = "codeViewContainer "+themeClass;
165 } 153 }
166 } 154 }
167//////////////////////////////////////////////////////////////////////// 155 ////////////////////////////////////////////////////////////////////
168//////////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////
169}); 157});
170//////////////////////////////////////////////////////////////////////// 158////////////////////////////////////////////////////////////////////////
171//////////////////////////////////////////////////////////////////////// \ No newline at end of file 159//////////////////////////////////////////////////////////////////////// \ No newline at end of file