diff options
author | Jose Antonio Marquez | 2012-02-21 18:04:27 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-21 18:04:27 -0800 |
commit | 25e6a03cf8af4bd0496a8b21c82332d76ddd9fff (patch) | |
tree | 9b4ef3a716139d5259261cae97e8603a1d33a91f /js/mediators | |
parent | 20dc41e571ddec6b781653fac43e2ca34026937d (diff) | |
parent | 2f24dafec79583547fe663d5a387d8ef15aae3bf (diff) | |
download | ninja-25e6a03cf8af4bd0496a8b21c82332d76ddd9fff.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into Color
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/element-mediator.js | 15 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 21 | ||||
-rwxr-xr-x | js/mediators/keyboard-mediator.js | 220 |
3 files changed, 138 insertions, 118 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/io-mediator.js b/js/mediators/io-mediator.js index e9958ec3..56869839 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -143,6 +143,16 @@ exports.IoMediator = Montage.create(Component, { | |||
143 | // | 143 | // |
144 | switch (file.mode) { | 144 | switch (file.mode) { |
145 | case 'html': | 145 | case 'html': |
146 | //Copy webGL library if needed | ||
147 | if (file.webgl.length > 0) { | ||
148 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { | ||
149 | //if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Assets' || this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { | ||
150 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { | ||
151 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(file.document.root, (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase()); | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | // | ||
146 | contents = this.parseNinjaTemplateToHtml(file); | 156 | contents = this.parseNinjaTemplateToHtml(file); |
147 | break; | 157 | break; |
148 | default: | 158 | default: |
@@ -192,17 +202,6 @@ exports.IoMediator = Montage.create(Component, { | |||
192 | // | 202 | // |
193 | template.document.content.document.body.innerHTML = template.body; | 203 | template.document.content.document.body.innerHTML = template.body; |
194 | template.document.content.document.head.innerHTML = template.head; | 204 | template.document.content.document.head.innerHTML = template.head; |
195 | // | ||
196 | if (template.webgl.length > 0) { | ||
197 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { | ||
198 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Assets' || this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { | ||
199 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase()); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | //this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(path, libname); | ||
204 | //console.log(this.application.ninja.coreIoApi.ninjaLibrary.libs); | ||
205 | } | ||
206 | //TODO: Remove temp fix for styles | 205 | //TODO: Remove temp fix for styles |
207 | if (template.style) { | 206 | if (template.style) { |
208 | template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); | 207 | template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); |
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index a1fdead3..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 | |||