aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
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
parenta69c929602e64f10fb3903b89a2ca9e9ed2c8dfb (diff)
parent2f24dafec79583547fe663d5a387d8ef15aae3bf (diff)
downloadninja-50bb05efbafc9a80f069dfde32988e5cd6826865.tar.gz
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/mediators')
-rwxr-xr-xjs/mediators/element-mediator.js15
-rwxr-xr-xjs/mediators/keyboard-mediator.js226
2 files changed, 128 insertions, 113 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index 95aec2a3..51923f08 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -28,13 +28,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
28 // TODO use the specific controller to be able to subclass the functionality 28 // TODO use the specific controller to be able to subclass the functionality
29 handleElementAdding: { 29 handleElementAdding: {
30 value: function(event) { 30 value: function(event) {
31 /*
32 var cmd = ElementControllerCommands.addElementCommand(event.detail.el, event.detail.data);
33 NJevent("sendToUndo", cmd);
34 cmd.execute();
35 */
36 this.addElement(event.detail.el, event.detail.data); 31 this.addElement(event.detail.el, event.detail.data);
37
38 } 32 }
39 }, 33 },
40 34
@@ -97,11 +91,13 @@ exports.ElementMediator = Montage.create(NJComponent, {
97 value: function(el, rules, noEvent) { 91 value: function(el, rules, noEvent) {
98 ElementController.addElement(el, rules); 92 ElementController.addElement(el, rules);
99 var p3d = this.get3DProperties(el); 93 var p3d = this.get3DProperties(el);
100 if(p3d) 94 if(p3d) {
101 {
102 el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); 95 el.elementModel.controller["set3DProperties"](el, [p3d], 0, true);
103 } 96 }
104 if(!noEvent) NJevent("elementAdded", el); 97 if(!noEvent) {
98 this.application.ninja.documentController.activeDocument.needsSave = true;
99 NJevent("elementAdded", el);
100 }
105 } 101 }
106 }, 102 },
107 103
@@ -127,6 +123,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
127 _removeElement: { 123 _removeElement: {
128 value: function(el, rules) { 124 value: function(el, rules) {
129 ElementController.removeElement(el, rules); 125 ElementController.removeElement(el, rules);
126 this.application.ninja.documentController.activeDocument.needsSave = true;
130 NJevent("elementDeleted", el); 127 NJevent("elementDeleted", el);
131 } 128 }
132 }, 129 },
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