aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/code-editor-controller.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js
index 0223165f..4a08aa32 100644
--- a/js/controllers/code-editor-controller.js
+++ b/js/controllers/code-editor-controller.js
@@ -24,7 +24,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
24 }, 24 },
25 25
26 codeCompletionSupport : { 26 codeCompletionSupport : {
27 value: {"javascript": true} 27 value: {"js": true}
28 }, 28 },
29 29
30 _automaticCodeComplete: { 30 _automaticCodeComplete: {
@@ -68,7 +68,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
68 * Creates an editor instance 68 * Creates an editor instance
69 */ 69 */
70 createEditor : { 70 createEditor : {
71 value:function(doc, type){ 71 value:function(doc, type, documentType){
72 var self = this, editorOptions = null; 72 var self = this, editorOptions = null;
73 73
74 editorOptions = { 74 editorOptions = {
@@ -91,8 +91,8 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
91 }; 91 };
92 92
93 //configure auto code completion if it is supported for that document type 93 //configure auto code completion if it is supported for that document type
94 if(this.codeCompletionSupport[type] === true){ 94 if(this.codeCompletionSupport[documentType] === true){
95 editorOptions.onKeyEvent = function(cm, keyEvent){self._codeCompletionKeyEventHandler.call(self, cm, keyEvent, type)}; 95 editorOptions.onKeyEvent = function(cm, keyEvent){self._codeCompletionKeyEventHandler.call(self, cm, keyEvent, documentType)};
96 } 96 }
97 97
98 var editor = self.codeEditor.fromTextArea(doc.textArea, editorOptions); 98 var editor = self.codeEditor.fromTextArea(doc.textArea, editorOptions);
@@ -109,7 +109,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
109 */ 109 */
110 _codeCompletionKeyEventHandler:{ 110 _codeCompletionKeyEventHandler:{
111 enumerable:false, 111 enumerable:false,
112 value: function(cm, keyEvent, type) { 112 value: function(cm, keyEvent, documentType) {
113 //===manually triggered code completion 113 //===manually triggered code completion
114 if((this.automaticCodeComplete === false)){ 114 if((this.automaticCodeComplete === false)){
115 if(keyEvent.ctrlKey && keyEvent.keyCode === 32){//Ctrl+Space 115 if(keyEvent.ctrlKey && keyEvent.keyCode === 32){//Ctrl+Space
@@ -117,7 +117,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
117 } 117 }
118 } 118 }
119 //===automatic auto complete [performance is slower] 119 //===automatic auto complete [performance is slower]
120 else if(this._showAutoComplete(type, keyEvent)){ 120 else if(this._showAutoComplete(documentType, keyEvent)){
121 this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint); 121 this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint);
122 } 122 }
123 } 123 }
@@ -129,11 +129,15 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
129 */ 129 */
130 _showAutoComplete : { 130 _showAutoComplete : {
131 enumerable:false, 131 enumerable:false,
132 value:function(type, keyEvent){ 132 value:function(documentType, keyEvent){
133 var status=false; 133 var status=false;
134 134
135 switch(type){ 135 if((keyEvent.metaKey || keyEvent.ctrlKey) && (keyEvent.keyCode === 83)){//ctrl+s
136 case "javascript": 136 return false;
137 }
138
139 switch(documentType){
140 case "js":
137 if((keyEvent.type === "keyup")//need seperate keycode set per mode 141 if((keyEvent.type === "keyup")//need seperate keycode set per mode
138 && ((keyEvent.keyCode > 47 && keyEvent.keyCode < 57)//numbers 142 && ((keyEvent.keyCode > 47 && keyEvent.keyCode < 57)//numbers
139 || (keyEvent.keyCode > 64 && keyEvent.keyCode <91)//letters 143 || (keyEvent.keyCode > 64 && keyEvent.keyCode <91)//letters
@@ -235,7 +239,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
235 //set theme 239 //set theme
236 this.handleThemeSelection(); 240 this.handleThemeSelection();
237 //check autocomplete support 241 //check autocomplete support
238 this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.editor.getOption("mode")); 242 this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.documentType);
239 //set zoom 243 //set zoom
240 this.handleZoom(this._zoomFactor); 244 this.handleZoom(this._zoomFactor);
241 } 245 }