aboutsummaryrefslogtreecommitdiff
path: root/js/mediators/keyboard-mediator.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-02-22 10:34:46 -0800
committerNivesh Rajbhandari2012-02-22 10:34:46 -0800
commit50bb05efbafc9a80f069dfde32988e5cd6826865 (patch)
tree64332f1c2f22b5c0a17f6df2f9a02d77f1c87274 /js/mediators/keyboard-mediator.js
parenta69c929602e64f10fb3903b89a2ca9e9ed2c8dfb (diff)
parent2f24dafec79583547fe663d5a387d8ef15aae3bf (diff)
downloadninja-50bb05efbafc9a80f069dfde32988e5cd6826865.tar.gz
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/mediators/keyboard-mediator.js')
-rwxr-xr-xjs/mediators/keyboard-mediator.js226
1 files changed, 122 insertions, 104 deletions
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js
index e8a11ad8..0282060f 100755
--- a/js/mediators/keyboard-mediator.js
+++ b/js/mediators/keyboard-mediator.js
@@ -85,22 +85,115 @@ exports.KeyboardMediator = Montage.create(Component, {
85 85
86 handleKeydown: { 86 handleKeydown: {
87 value: function(evt) { 87 value: function(evt) {
88 if(document.activeElement.nodeName !== "BODY") {
89 // Don't do anything if an input or other control is focused
90 return;
91 }
92 88
93 // Disable defaults for the Arrow Keys 89 //keyboard controls for html design view
94 if((evt.keyCode == Keyboard.LEFT) || (evt.keyCode == Keyboard.RIGHT) || (evt.keyCode == Keyboard.UP) || (evt.keyCode == Keyboard.DOWN)) { 90 if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){
95 evt.preventDefault(); 91
96 } 92 // Don't do anything if an input or other control is focused
93 if(document.activeElement.nodeName !== "BODY") {
94 return;
95 }
96
97 // Disable defaults for the Arrow Keys
98 if((evt.keyCode == Keyboard.LEFT) || (evt.keyCode == Keyboard.RIGHT) || (evt.keyCode == Keyboard.UP) || (evt.keyCode == Keyboard.DOWN)) {
99 evt.preventDefault();
100 }
101
102 // Check DELETE OR BACKSPACE
103 if((evt.keyCode == Keyboard.BACKSPACE) || (evt.keyCode == Keyboard.DELETE)) {
104 evt.stopImmediatePropagation();
105 evt.preventDefault();
106 NJevent("deleting");
107 return;
108 }
109
110
111 // Shortcut for Selection Tool is V
112 if(evt.keyCode === Keyboard.V) {
113 evt.preventDefault();
114 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]});
115 return;
116 }
117
118 // Shortcut for Tag Tool is D
119 if(evt.keyCode === Keyboard.D){
120 evt.preventDefault();
121 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]});
122 return;
123 }
124
125 // Shortcut for Rotate Tool is W
126 if(evt.keyCode === Keyboard.W){
127 evt.preventDefault();
128 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]});
129 return;
130 }
131
132 // Shortcut for Translate Tool is G
133 if(evt.keyCode === Keyboard.G){
134 evt.preventDefault();
135 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]});
136 return;
137 }
138
139 // Shortcut for Rectangle Tool is R
140 // unless the user is pressing the command key.
141 // If the user is pressing the command key, they want to refresh the browser.
142 if((evt.keyCode === Keyboard.R) && !evt.metaKey) {
143 evt.preventDefault();
144 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]});
145 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]});
146 return;
147 }
148
149 // Shortcut for Oval Tool is O
150 if(evt.keyCode === Keyboard.O) {
151 evt.preventDefault();
152 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]});
153 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[0]});
154 return;
155 }
156
157 // Shortcut for Line Tool is L
158 if(evt.keyCode === Keyboard.L ) {
159 evt.preventDefault();
160 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]});
161 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[2]});
162 return;
163 }
164
165 if(evt.keyCode === Keyboard.H ) {
166 evt.preventDefault();
167 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]});
168 return;
169 }
170
171 if(evt.keyCode === Keyboard.Z ) {
172 evt.preventDefault();
173 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[16]});
174 return;
175 }
176
177 // Check if cmd+a/ctrl+a for Select All
178 if((evt.keyCode == Keyboard.A) && (evt.ctrlKey || evt.metaKey)) {
179 NJevent("selectAll");
180 return;
181 }
182
183 if(evt.keyCode === Keyboard.ESCAPE){//ESC key
184 //console.log("ESC key pressed");
185 if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleEscape(evt);
186 //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar");
187 }
188
189
190 if((evt.keyCode == Keyboard.ENTER) && (evt.ctrlKey || evt.metaKey)) {
191 this.application.ninja.executeChromePreview();
192 return;
193 }
194
195 if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyPress(evt);
97 196
98 // Check DELETE OR BACKSPACE
99 if((evt.keyCode == Keyboard.BACKSPACE) || (evt.keyCode == Keyboard.DELETE)) {
100 evt.stopImmediatePropagation();
101 evt.preventDefault();
102 NJevent("deleting");
103 return;
104 } 197 }
105 198
106 // Check if cmd+z/ctrl+z for Undo (Windows/Mac) 199 // Check if cmd+z/ctrl+z for Undo (Windows/Mac)
@@ -110,6 +203,13 @@ exports.KeyboardMediator = Montage.create(Component, {
110 return; 203 return;
111 } 204 }
112 205
206 // Check if cmd+s/ctrl+s for Save (Windows/Mac)
207 if ((evt.keyCode == Keyboard.S) && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) {
208 NJevent("executeSave");
209 evt.preventDefault();
210 return;
211 }
212
113 // Check if cmd+shift+z for Redo (Mac) 213 // Check if cmd+shift+z for Redo (Mac)
114 if ((evt.keyCode == Keyboard.Z) && evt.metaKey && evt.shiftKey) { 214 if ((evt.keyCode == Keyboard.Z) && evt.metaKey && evt.shiftKey) {
115 NJevent("executeRedo"); 215 NJevent("executeRedo");
@@ -124,103 +224,21 @@ exports.KeyboardMediator = Montage.create(Component, {
124 return; 224 return;
125 } 225 }
126 226
127 // Shortcut for Selection Tool is V
128 if(evt.keyCode === Keyboard.V) {
129 evt.preventDefault();
130 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]});
131 return;
132 }
133
134 // Shortcut for Tag Tool is D
135 if(evt.keyCode === Keyboard.D){
136 evt.preventDefault();
137 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]});
138 return;
139 }
140
141 // Shortcut for Rotate Tool is W
142 if(evt.keyCode === Keyboard.W){
143 evt.preventDefault();
144 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]});
145 return;
146 }
147
148 // Shortcut for Translate Tool is G
149 if(evt.keyCode === Keyboard.G){
150 evt.preventDefault();
151 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]});
152 return;
153 }
154
155 // Shortcut for Rectangle Tool is R
156 // unless the user is pressing the command key.
157 // If the user is pressing the command key, they want to refresh the browser.
158 if((evt.keyCode === Keyboard.R) && !evt.metaKey) {
159 evt.preventDefault();
160 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]});
161 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]});
162 return;
163 }
164
165 // Shortcut for Oval Tool is O
166 if(evt.keyCode === Keyboard.O) {
167 evt.preventDefault();
168 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]});
169 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[0]});
170 return;
171 }
172
173 // Shortcut for Line Tool is L
174 if(evt.keyCode === Keyboard.L ) {
175 evt.preventDefault();
176 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]});
177 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[2]});
178 return;
179 }
180
181 if(evt.keyCode === Keyboard.H ) {
182 evt.preventDefault();
183 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]});
184 return;
185 }
186
187 if(evt.keyCode === Keyboard.Z ) {
188 evt.preventDefault();
189 this.applicatio