aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/views')
-rwxr-xr-xjs/document/views/base.js2
-rwxr-xr-xjs/document/views/code.js152
-rwxr-xr-xjs/document/views/design.js47
3 files changed, 183 insertions, 18 deletions
diff --git a/js/document/views/base.js b/js/document/views/base.js
index d1c65b5e..db72cc60 100755
--- a/js/document/views/base.js
+++ b/js/document/views/base.js
@@ -39,6 +39,7 @@ exports.BaseDocumentView = Montage.create(Component, {
39 value: function (callback) { 39 value: function (callback) {
40 if (this.iframe) { 40 if (this.iframe) {
41 this.iframe.style.display = 'block'; 41 this.iframe.style.display = 'block';
42 this.iframe.style.opacity = 1;
42 } else { 43 } else {
43 console.log('Error: View has no iframe to show!'); 44 console.log('Error: View has no iframe to show!');
44 } 45 }
@@ -52,6 +53,7 @@ exports.BaseDocumentView = Montage.create(Component, {
52 value: function (callback) { 53 value: function (callback) {
53 if (this.iframe) { 54 if (this.iframe) {
54 this.iframe.style.display = 'none'; 55 this.iframe.style.display = 'none';
56 this.iframe.style.opacity = 0;
55 } else { 57 } else {
56 console.log('Error: View has no iframe to hide!'); 58 console.log('Error: View has no iframe to hide!');
57 } 59 }
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
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 2ccb82d1..b3887fdf 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -64,6 +64,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
64 }, 64 },
65 //////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////
66 // 66 //
67 propertiesPanel: {
68 value: null
69 },
70 ////////////////////////////////////////////////////////////////////
71 //
67 initialize: { 72 initialize: {
68 value: function (parent) { 73 value: function (parent) {
69 //Creating iFrame for view 74 //Creating iFrame for view
@@ -184,8 +189,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
184 this._bodyFragment = null; 189 this._bodyFragment = null;
185 //Calling standard method to finish opening document 190 //Calling standard method to finish opening document
186 this.bodyContentLoaded(null); 191 this.bodyContentLoaded(null);
187 192 //TODO: Move this to be set via the controller
188 // TODO: Clean up this code
189 this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); 193 this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2);
190 this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); 194 this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2);
191 } 195 }
@@ -243,17 +247,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
243 } 247 }
244 } 248 }
245 } 249 }
246 //Checking and initializing webGL 250 //Checking for script tags then parsing check for montage and webgl
247 if (scripttags.length > 0) { 251 if (scripttags.length > 0) {
252 //Checking and initializing webGL
248 this.initWebGl(scripttags); 253 this.initWebGl(scripttags);
249 } //Else there is not data to parse 254 //Checking and initializing Montage
250 255 this.initMontage(scripttags);
251 256 } else {