diff options
author | Ananya Sen | 2012-04-24 16:45:47 -0700 |
---|---|---|
committer | Ananya Sen | 2012-04-24 16:45:47 -0700 |
commit | a7548b4c53de8f42cb5e0fb1c054eba6f7c45afb (patch) | |
tree | d41e74e4ad4c213af6f05cdc26ad747874d56a92 /js/controllers | |
parent | eab872829c14af251578f95c6f57509acbed660c (diff) | |
download | ninja-a7548b4c53de8f42cb5e0fb1c054eba6f7c45afb.tar.gz |
IKNINJA-1529 : zooming such that cursor position can be calculated accurately
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/controllers')
-rw-r--r-- | js/controllers/code-editor-controller.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js index 8d7e3117..bce6f410 100644 --- a/js/controllers/code-editor-controller.js +++ b/js/controllers/code-editor-controller.js | |||
@@ -46,14 +46,13 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
46 | }, | 46 | }, |
47 | 47 | ||
48 | _zoomFactor:{ | 48 | _zoomFactor:{ |
49 | value:null | 49 | value:100 |
50 | }, | 50 | }, |
51 | 51 | ||
52 | zoomFactor:{ | 52 | zoomFactor:{ |
53 | get: function(){return this._zoomFactor;}, | 53 | get: function(){return this._zoomFactor;}, |
54 | set: function(value){ | 54 | set: function(value){ |
55 | this._zoomFactor = value; | 55 | this.handleZoom(value); |
56 | this.application.ninja.documentController.activeDocument.container.style.zoom = ""+value+"%"; | ||
57 | } | 56 | } |
58 | }, | 57 | }, |
59 | 58 | ||
@@ -113,7 +112,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
113 | value: function(cm, keyEvent, type) { | 112 | value: function(cm, keyEvent, type) { |
114 | //===manually triggered code completion | 113 | //===manually triggered code completion |
115 | if((this.automaticCodeComplete === false)){ | 114 | if((this.automaticCodeComplete === false)){ |
116 | if((keyEvent.ctrlKey || keyEvent.metaKey) && keyEvent.keyCode === 32){//Ctrl-Space | 115 | if((keyEvent.ctrlKey || keyEvent.metaKey) && keyEvent.keyCode === 32){//Ctrl+Space |
117 | this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint); | 116 | this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint); |
118 | } | 117 | } |
119 | } | 118 | } |
@@ -147,6 +146,9 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
147 | || (keyEvent.shiftKey && keyEvent.keyCode === 57)//open bracket ( | 146 | || (keyEvent.shiftKey && keyEvent.keyCode === 57)//open bracket ( |
148 | || (keyEvent.shiftKey && keyEvent.keyCode === 48)//close bracket ) | 147 | || (keyEvent.shiftKey && keyEvent.keyCode === 48)//close bracket ) |
149 | || ((keyEvent.ctrlKey || keyEvent.metaKey) && keyEvent.keyCode === 83)//ctrl+S | 148 | || ((keyEvent.ctrlKey || keyEvent.metaKey) && keyEvent.keyCode === 83)//ctrl+S |
149 | || ((keyEvent.ctrlKey || keyEvent.metaKey) && keyEvent.keyCode === 90)//ctrl+z | ||
150 | || ((keyEvent.ctrlKey || keyEvent.metaKey) && keyEvent.shiftKey && keyEvent.keyCode === 90)//ctrl+shift+z | ||
151 | || ((keyEvent.ctrlKey || keyEvent.metaKey) && keyEvent.keyCode === 89)//ctrl+y | ||
150 | ) | 152 | ) |
151 | ){return true;} | 153 | ){return true;} |
152 | default : | 154 | default : |
@@ -213,6 +215,17 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
213 | } | 215 | } |
214 | }, | 216 | }, |
215 | 217 | ||
218 | handleZoom:{ | ||
219 | value:function(value){ | ||
220 | var originalFont=13,originalLineHeight=16; | ||
221 | this._zoomFactor = value; | ||
222 | this.application.ninja.documentController.activeDocument.container.style.fontSize = ""+((value/100)*originalFont)+"px"; | ||
223 | this.application.ninja.documentController.activeDocument.container.style.cursor = "text"; | ||
224 | this.application.ninja.documentController.activeDocument.container.querySelector(".CodeMirror").style.lineHeight = ""+((value/100)*originalLineHeight)+"px"; | ||
225 | this.application.ninja.documentController.activeDocument.editor.refresh();//refresh editor display for xoom | ||
226 | } | ||
227 | }, | ||
228 | |||
216 | applySettings:{ | 229 | applySettings:{ |
217 | value:function(){ | 230 | value:function(){ |
218 | //set theme | 231 | //set theme |
@@ -220,7 +233,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
220 | //check autocomplete support | 233 | //check autocomplete support |
221 | this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.editor.getOption("mode")); | 234 | this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.editor.getOption("mode")); |
222 | //set zoom | 235 | //set zoom |
223 | this.application.ninja.documentController.activeDocument.container.style.zoom = ""+this.zoomFactor+"%"; | 236 | this.handleZoom(this._zoomFactor); |
224 | } | 237 | } |
225 | } | 238 | } |
226 | }); \ No newline at end of file | 239 | }); \ No newline at end of file |