From c2ec390d42945d2df1aed3f2b7ff3d1aa722fce8 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 13 Apr 2012 16:51:50 -0700 Subject: - code editor view options bar - Checkbox for user to toggle between manually triggered autocomplete and automatic autocomplete - font zoom hottext Signed-off-by: Ananya Sen --- js/controllers/code-editor-controller.js | 45 +++++++++++++++++++++++++++----- js/controllers/document-controller.js | 1 + 2 files changed, 40 insertions(+), 6 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js index 0c13958c..534d4645 100644 --- a/js/controllers/code-editor-controller.js +++ b/js/controllers/code-editor-controller.js @@ -23,17 +23,37 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone set: function(value){this._codeEditor = value;} }, - codeCompletionSupport : {"javascript": true}, + codeCompletionSupport : { + value: {"javascript": true} + }, _automaticCodeComplete: { value:true }, automaticCodeComplete:{ - get: function(){return this._automaticCodeComplete;}, - set: function(value){this._automaticCodeComplete = value;} - }, + get: function(){return this._automaticCodeComplete;}, + set: function(value){ + //console.log("$$$ automaticCodeComplete setter : "+value); + this._automaticCodeComplete = value;} + }, + + originalEditorFont:{ + value:"13"//px + }, + _editorFont:{ + value:null + }, + + editorFont:{ + get: function(){return this._editorFont;}, + set: function(value){//gets a zoom % + this._editorFont = (value/100) * CodeEditorController.originalEditorFont; + //set the font size + document.getElementsByClassName("codeViewContainer")[0].style.fontSize = ""+this._editorFont+"px"; + } + }, deserializedFromTemplate: { value: function() { @@ -70,11 +90,14 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone }; //configure auto code completion if it is supported for that document type - if(true){ + if(this.codeCompletionSupport[type] === true){ editorOptions.onKeyEvent = function(cm, keyEvent){self._codeCompletionKeyEventHandler.call(self, cm, keyEvent, type)}; } var editor = self.codeEditor.fromTextArea(doc.textArea, editorOptions); + + //editor.setOption("theme", "night"); + return editor; } }, @@ -128,6 +151,16 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone return false; } } - } + }, + handleCodeCompletionSupport:{ + value:function(fileType){ + var autoCodeCompleteElem = document.getElementsByClassName("autoCodeComplete")[0]; + if(autoCodeCompleteElem && (this.codeCompletionSupport[fileType] === true)){ + autoCodeCompleteElem.style.visibility = "visible"; + }else if(autoCodeCompleteElem && !this.codeCompletionSupport[fileType]){ + autoCodeCompleteElem.style.visibility = "hidden"; + } + } + } }); \ No newline at end of file diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index a308f191..9792c7f6 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -442,6 +442,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, NJevent("onOpenDocument", doc); // appDelegateModule.MyAppDelegate.onSetActiveDocument(); + this.application.ninja.stage.stageView.showCodeViewBar(false); } }, -- cgit v1.2.3