From aa35d31fa94f844586581c770913858bd15af505 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 30 Apr 2012 11:23:33 -0700 Subject: IKNINJA-1537 - don't show code hinting for ctrl+S IKNINJA-1568 - code hinting not supported for son files Signed-off-by: Ananya Sen --- js/controllers/code-editor-controller.js | 24 ++++++++++++++---------- js/stage/stage-view.reel/stage-view.js | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'js') 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 }, codeCompletionSupport : { - value: {"javascript": true} + value: {"js": true} }, _automaticCodeComplete: { @@ -68,7 +68,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone * Creates an editor instance */ createEditor : { - value:function(doc, type){ + value:function(doc, type, documentType){ var self = this, editorOptions = null; editorOptions = { @@ -91,8 +91,8 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone }; //configure auto code completion if it is supported for that document type - if(this.codeCompletionSupport[type] === true){ - editorOptions.onKeyEvent = function(cm, keyEvent){self._codeCompletionKeyEventHandler.call(self, cm, keyEvent, type)}; + if(this.codeCompletionSupport[documentType] === true){ + editorOptions.onKeyEvent = function(cm, keyEvent){self._codeCompletionKeyEventHandler.call(self, cm, keyEvent, documentType)}; } var editor = self.codeEditor.fromTextArea(doc.textArea, editorOptions); @@ -109,7 +109,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone */ _codeCompletionKeyEventHandler:{ enumerable:false, - value: function(cm, keyEvent, type) { + value: function(cm, keyEvent, documentType) { //===manually triggered code completion if((this.automaticCodeComplete === false)){ if(keyEvent.ctrlKey && keyEvent.keyCode === 32){//Ctrl+Space @@ -117,7 +117,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone } } //===automatic auto complete [performance is slower] - else if(this._showAutoComplete(type, keyEvent)){ + else if(this._showAutoComplete(documentType, keyEvent)){ this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint); } } @@ -129,11 +129,15 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone */ _showAutoComplete : { enumerable:false, - value:function(type, keyEvent){ + value:function(documentType, keyEvent){ var status=false; - switch(type){ - case "javascript": + if((keyEvent.metaKey || keyEvent.ctrlKey) && (keyEvent.keyCode === 83)){//ctrl+s + return false; + } + + switch(documentType){ + case "js": if((keyEvent.type === "keyup")//need seperate keycode set per mode && ((keyEvent.keyCode > 47 && keyEvent.keyCode < 57)//numbers || (keyEvent.keyCode > 64 && keyEvent.keyCode <91)//letters @@ -235,7 +239,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone //set theme this.handleThemeSelection(); //check autocomplete support - this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.editor.getOption("mode")); + this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.documentType); //set zoom this.handleZoom(this._zoomFactor); } diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index dcc84a35..518c3bdd 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -112,7 +112,7 @@ exports.StageView = Montage.create(Component, { } document.getElementById("codeMirror_"+doc.uuid).style.display="block"; - doc.editor = this.application.ninja.codeEditorController.createEditor(doc, type); + doc.editor = this.application.ninja.codeEditorController.createEditor(doc, type, doc.documentType); doc.editor.hline = doc.editor.setLineClass(0, "activeline"); this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe -- cgit v1.2.3