aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/code-editor-controller.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-30 17:45:38 -0700
committerValerio Virgillito2012-05-30 17:45:38 -0700
commit0a769756547acb93346d8e1b4126931a78845255 (patch)
treec901c0522eb74eb56250d5df591ac14432e76aed /js/controllers/code-editor-controller.js
parentcbb888376282c7f6a5151478956b037e71d3b027 (diff)
downloadninja-0a769756547acb93346d8e1b4126931a78845255.tar.gz
opening code view documents
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/controllers/code-editor-controller.js')
-rw-r--r--js/controllers/code-editor-controller.js47
1 files changed, 35 insertions, 12 deletions
diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js
index e7163bd8..d0b1f179 100644
--- a/js/controllers/code-editor-controller.js
+++ b/js/controllers/code-editor-controller.js
@@ -9,11 +9,34 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
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 11
12var CodeEditorController = exports.CodeEditorController = Montage.create(Component, { 12exports.CodeEditorController = Montage.create(Component, {
13 hasTemplate: { 13 hasTemplate: {
14 value: false 14 value: false
15 }, 15 },
16 16
17 _currentDocument: {
18 value : null
19 },
20
21 currentDocument : {
22 get : function() {
23 return this._currentDocument;
24 },
25 set : function(value) {
26 if (value === this._currentDocument) {
27 return;
28 }
29
30 this._currentDocument = value;
31
32 if(!value) {
33
34 } else if(this._currentDocument.currentView === "code") {
35 this.applySettings();
36 }
37 }
38 },
39
17 _codeEditor : { 40 _codeEditor : {
18 value:null 41 value:null
19 }, 42 },
@@ -213,22 +236,22 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
213 236
214 autoFormatSelection:{ 237 autoFormatSelection:{
215 value: function(){ 238 value: function(){
216 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.model.views.code.editor); 239 var range = this.getSelectedRange(this.currentDocument.model.views.code.editor);
217 this.application.ninja.documentController.activeDocument.model.views.code.editor.autoFormatRange(range.from, range.to); 240 this.currentDocument.model.views.code.editor.autoFormatRange(range.from, range.to);
218 } 241 }
219 }, 242 },
220 243
221 commentSelection:{ 244 commentSelection:{
222 value: function(isComment){ 245 value: function(isComment){
223 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.model.views.code.editor); 246 var range = this.getSelectedRange(this.currentDocument.model.views.code.editor);
224 this.application.ninja.documentController.activeDocument.model.views.code.editor.commentRange(isComment, range.from, range.to); 247 this.currentDocument.model.views.code.editor.commentRange(isComment, range.from, range.to);
225 } 248 }
226 }, 249 },
227 250
228 handleThemeSelection:{ 251 handleThemeSelection:{
229 value: function(){ 252 value: function(){
230 this.application.ninja.documentController.activeDocument.model.views.code.editor.setOption("theme", this.editorTheme); 253 this.currentDocument.model.views.code.editor.setOption("theme", this.editorTheme);
231 this.application.ninja.documentController.activeDocument.model.views.code.applyTheme("cm-s-"+this.editorTheme); 254 this.currentDocument.model.views.code.applyTheme("cm-s-"+this.editorTheme);
232 } 255 }
233 }, 256 },
234 257
@@ -236,10 +259,10 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
236 value:function(value){ 259 value:function(value){
237 var originalFont=13,originalLineHeight=16; 260 var originalFont=13,originalLineHeight=16;
238 this._zoomFactor = value; 261 this._zoomFactor = value;
239 this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.style.fontSize = ""+((value/100)*originalFont)+"px"; 262 this.currentDocument.model.views.code.textViewContainer.style.fontSize = ""+((value/100)*originalFont)+"px";
240 this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.style.cursor = "text"; 263 this.currentDocument.model.views.code.textViewContainer.style.cursor = "text";
241 this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.querySelector(".CodeMirror").style.lineHeight = ""+((value/100)*originalLineHeight)+"px"; 264 this.currentDocument.model.views.code.textViewContainer.querySelector(".CodeMirror").style.lineHeight = ""+((value/100)*originalLineHeight)+"px";
242 this.application.ninja.documentController.activeDocument.model.views.code.editor.refresh();//refresh editor display for xoom 265 this.currentDocument.model.views.code.editor.refresh();//refresh editor display for xoom
243 } 266 }
244 }, 267 },
245 268
@@ -248,7 +271,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
248 //set theme 271 //set theme
249 this.handleThemeSelection(); 272 this.handleThemeSelection();
250 //check autocomplete support 273 //check autocomplete support
251 this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.model.file.extension); 274 this.handleCodeCompletionSupport(this.currentDocument.model.file.extension);
252 //set zoom 275 //set zoom
253 this.handleZoom(this._zoomFactor); 276 this.handleZoom(this._zoomFactor);
254 } 277 }