aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnanya Sen2012-04-24 16:45:47 -0700
committerAnanya Sen2012-04-24 16:45:47 -0700
commita7548b4c53de8f42cb5e0fb1c054eba6f7c45afb (patch)
treed41e74e4ad4c213af6f05cdc26ad747874d56a92
parenteab872829c14af251578f95c6f57509acbed660c (diff)
downloadninja-a7548b4c53de8f42cb5e0fb1c054eba6f7c45afb.tar.gz
IKNINJA-1529 : zooming such that cursor position can be calculated accurately
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
-rwxr-xr-xcss/ninja.css2
-rw-r--r--js/controllers/code-editor-controller.js23
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.css2
-rw-r--r--scss/imports/scss/_Stage.scss4
4 files changed, 21 insertions, 10 deletions
diff --git a/css/ninja.css b/css/ninja.css
index 6c198b8e..297ed7cd 100755
--- a/css/ninja.css
+++ b/css/ninja.css
@@ -212,7 +212,7 @@ body { position: absolute; margin: 0px; width: 100%; height: 100%; background-co
212 212
213#mainContent .CodeMirror { width: 100%; height: 100%; background: white; } 213#mainContent .CodeMirror { width: 100%; height: 100%; background: white; }
214 214
215#mainContent .CodeMirror-scroll { height: 100%; overflow: scroll; overflow-x: auto; overflow-y: hidden; } 215#mainContent .CodeMirror-scroll { height: 100%; overflow:auto; }
216 216
217.montage-editor-frame { position: absolute; z-index: 7; top: 0; left: 0; display: none; -webkit-user-select: initial; } 217.montage-editor-frame { position: absolute; z-index: 7; top: 0; left: 0; display: none; -webkit-user-select: initial; }
218 218
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
diff --git a/js/stage/stage-view.reel/stage-view.css b/js/stage/stage-view.reel/stage-view.css
index b86c197a..10f80476 100755
--- a/js/stage/stage-view.reel/stage-view.css
+++ b/js/stage/stage-view.reel/stage-view.css
@@ -18,7 +18,7 @@
18} 18}
19 19
20.codeViewContainer>div{ 20.codeViewContainer>div{
21 width:2050px;/*to prevent scrolling of editor container in the middle of the page for short files*/ 21 width:2500px;/*to prevent scrolling of editor container in the middle of the page for short files*/
22} 22}
23 23
24/* OLD CSS for reference 24/* OLD CSS for reference
diff --git a/scss/imports/scss/_Stage.scss b/scss/imports/scss/_Stage.scss
index 3a8c0997..6206f27f 100644
--- a/scss/imports/scss/_Stage.scss
+++ b/scss/imports/scss/_Stage.scss
@@ -188,9 +188,7 @@
188 188
189#mainContent .CodeMirror-scroll { 189#mainContent .CodeMirror-scroll {
190 height: 100%; 190 height: 100%;
191 overflow: scroll; 191 overflow: auto;
192 overflow-x: auto;
193 overflow-y: hidden;
194} 192}
195 193
196.montage-editor-frame { 194.montage-editor-frame {