diff options
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/drag-drop-mediator.js | 6 | ||||
-rwxr-xr-x | js/mediators/element-mediator.js | 28 | ||||
-rwxr-xr-x | js/mediators/keyboard-mediator.js | 43 |
3 files changed, 48 insertions, 29 deletions
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index b0aba5b6..59086ef6 100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js | |||
@@ -114,11 +114,13 @@ exports.DragDropMediator = Montage.create(Component, { | |||
114 | var self = this; | 114 | var self = this; |
115 | // | 115 | // |
116 | if (e.currentTarget.fileType.indexOf('svg') !== -1) { | 116 | if (e.currentTarget.fileType.indexOf('svg') !== -1) { |
117 | element = NJUtils.makeNJElement('embed', 'SVG', 'block');//TODO: Verify this is proper | 117 | element = NJUtils.make('embed', null, this.application.ninja.currentDocument);//TODO: Verify this is proper |
118 | NJUtils.createModelWithSelection(element, "SVG"); | ||
118 | element.type = 'image/svg+xml'; | 119 | element.type = 'image/svg+xml'; |
119 | element.src = url+'/'+fileName; | 120 | element.src = url+'/'+fileName; |
120 | } else { | 121 | } else { |
121 | element = NJUtils.makeNJElement('image', 'image', 'image'); | 122 | element = NJUtils.make('image', null, this.application.ninja.currentDocument); |
123 | NJUtils.createModel(element); | ||
122 | element.src = url+'/'+fileName; | 124 | element.src = url+'/'+fileName; |
123 | } | 125 | } |
124 | //Adding element once it is loaded | 126 | //Adding element once it is loaded |
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 919aaec1..06514076 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -514,11 +514,33 @@ exports.ElementMediator = Montage.create(Component, { | |||
514 | var str = this.getProperty(el, "-webkit-transform"); | 514 | var str = this.getProperty(el, "-webkit-transform"); |
515 | return str && str.length; | 515 | return str && str.length; |
516 | } | 516 | } |
517 | } | 517 | }, |
518 | |||
519 | 518 | ||
519 | reArrangeDOM:{ | ||
520 | value: function(layersDraggedArray, layerDroppedAfter) { | ||
521 | var documentRoot,length; | ||
520 | 522 | ||
523 | documentRoot = this.application.ninja.currentDocument.documentRoot; | ||
524 | length = layersDraggedArray.length; | ||
521 | 525 | ||
522 | //-------------------------------------------------------------------------------------------------------- | 526 | for(var i=0; documentRoot.children[i]; i++) { |
527 | if(documentRoot.children[i] === layerDroppedAfter.layerData.elementsList[0]) { | ||
528 | if(length >0){ | ||
529 | documentRoot.children[i].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0], documentRoot.children[i]); | ||
530 | } | ||
523 | 531 | ||
532 | /* Will require for Multiple Drag n Drop */ | ||
533 | //length = length-1; | ||
534 | //index = i; | ||
535 | //if(length>0) { | ||
536 | //while(layersDraggedArray[length]) { | ||
537 | //documentRoot.children[index].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[k].nextSibling); | ||
538 | //length--; | ||
539 | //index++; | ||
540 | //} | ||
541 | //} | ||
542 | } | ||
543 | } | ||
544 | } | ||
545 | } | ||
524 | }); \ No newline at end of file | 546 | }); \ No newline at end of file |
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index f8934669..029c0916 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js | |||
@@ -110,35 +110,35 @@ exports.KeyboardMediator = Montage.create(Component, { | |||
110 | // Shortcut for Selection Tool is V | 110 | // Shortcut for Selection Tool is V |
111 | if(evt.keyCode === Keyboard.V) { | 111 | if(evt.keyCode === Keyboard.V) { |
112 | evt.preventDefault(); | 112 | evt.preventDefault(); |
113 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]}); | 113 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.selectionToolIndex] }); |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | 116 | ||
117 | // Shortcut for Tag Tool is D | 117 | // Shortcut for Tag Tool is D |
118 | if(evt.keyCode === Keyboard.D){ | 118 | if(evt.keyCode === Keyboard.D){ |
119 | evt.preventDefault(); | 119 | evt.preventDefault(); |
120 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]}); | 120 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.tagToolIndex] }); |
121 | return; | 121 | return; |
122 | } | 122 | } |
123 | 123 | ||
124 | // Shortcut for Rotate Tool is W | 124 | // Shortcut for Rotate Tool is W |
125 | if(evt.keyCode === Keyboard.W){ | 125 | if(evt.keyCode === Keyboard.W){ |
126 | evt.preventDefault(); | 126 | evt.preventDefault(); |
127 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]}); | 127 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.rotate3DToolIndex] }); |
128 | return; | 128 | return; |
129 | } | 129 | } |
130 | 130 | ||
131 | // Shortcut for Translate Tool is G | 131 | // Shortcut for Translate Tool is G |
132 | if(evt.keyCode === Keyboard.G){ | 132 | if(evt.keyCode === Keyboard.G){ |
133 | evt.preventDefault(); | 133 | evt.preventDefault(); |
134 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]}); | 134 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.translate3DToolIndex] }); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | 137 | ||
138 | // shortcut for Pen tool is P | 138 | // shortcut for Pen tool is P |
139 | if (evt.keyCode === Keyboard.P){ | 139 | if (evt.keyCode === Keyboard.P){ |
140 | evt.preventDefault(); | 140 | evt.preventDefault(); |
141 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[5]}); | 141 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.penToolIndex] }); |
142 | return; | 142 | return; |
143 | } | 143 | } |
144 | 144 | ||
@@ -147,24 +147,24 @@ exports.KeyboardMediator = Montage.create(Component, { | |||
147 | // If the user is pressing the command key, they want to refresh the browser. | 147 | // If the user is pressing the command key, they want to refresh the browser. |
148 | if((evt.keyCode === Keyboard.R) && !evt.metaKey) { | 148 | if((evt.keyCode === Keyboard.R) && !evt.metaKey) { |
149 | evt.preventDefault(); | 149 | evt.preventDefault(); |
150 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); | 150 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] }); |
151 | this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]}); | 151 | this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[1] }); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | 154 | ||
155 | // Shortcut for Oval Tool is O | 155 | // Shortcut for Oval Tool is O |
156 | if(evt.keyCode === Keyboard.O) { | 156 | if(evt.keyCode === Keyboard.O) { |
157 | evt.preventDefault(); | 157 | evt.preventDefault(); |
158 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); | 158 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] }); |
159 | this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[0]}); | 159 | this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[0] }); |
160 | return; | 160 | return; |
161 | } | 161 | } |
162 | 162 | ||
163 | // Shortcut for Line Tool is L | 163 | // Shortcut for Line Tool is L |
164 | if(evt.keyCode === Keyboard.L ) { | 164 | if(evt.keyCode === Keyboard.L ) { |
165 | evt.preventDefault(); | 165 | evt.preventDefault(); |
166 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); | 166 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] }); |
167 | this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[2]}); | 167 | this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[2] }); |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
@@ -172,38 +172,33 @@ exports.KeyboardMediator = Montage.create(Component, { | |||
172 | if(evt.keyCode === Keyboard.K ) { | 172 | if(evt.keyCode === Keyboard.K ) { |
173 | evt.preventDefault(); | 173 | evt.preventDefault(); |
174 | if(this.application.ninja.toolsData.selectedTool.id === "FillTool") { | 174 | if(this.application.ninja.toolsData.selectedTool.id === "FillTool") { |
175 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[11]}); | 175 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.inkBottleToolIndex] }); |
176 | } else if(this.application.ninja.toolsData.selectedTool.id === "InkBottleTool") { | ||
177 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.fillToolIndex] }); | ||
176 | } else { | 178 | } else { |
177 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[10]}); | 179 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.fillToolIndex] }); |
178 | } | 180 | } |
179 | return; | 181 | return; |
180 | } | ||
181 | |||
182 | // Shortcut for Eyedropper Tool is I | ||
183 | if(evt.keyCode === Keyboard.I && !(evt.ctrlKey || evt.metaKey)) { | ||
184 | evt.preventDefault(); | ||
185 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[12]}); | ||
186 | return; | ||
187 | } | 182 | } |
188 | 183 | ||
189 | // Rotate Stage Tool is M | 184 | // Rotate Stage Tool is M |
190 | if(evt.keyCode === Keyboard.M ) { | 185 | if(evt.keyCode === Keyboard.M ) { |
191 | evt.preventDefault(); | 186 | evt.preventDefault(); |
192 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[13]}); | 187 | this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.rotateStage3DToolIndex] }); |
193 | return; | 188 | return; |
194 | } | 189 | } |
195 | 190 | ||
196 | // Hand tool | 191 | // Hand tool |
197 | if(evt.keyCode === Keyboard.H ) { | 192 | if(evt.keyCode === Keyboard.H ) { |
198 | evt.preventDefault(); | 193 | evt.preventDefault(); |
199 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[14]}); | 194 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.panToolIndex]}); |
200 | return; | 195 | return; |
201 | } | 196 | } |
202 | 197 | ||
203 | // Zoom tool | 198 | // Zoom tool |
204 | if((evt.keyCode === Keyboard.Z) && !(evt.ctrlKey || evt.metaKey) && !evt.shiftKey) {//ctrl or shift key not press with Z | 199 | if((evt.keyCode === Keyboard.Z) && !(evt.ctrlKey || evt.metaKey) && !evt.shiftKey) {//ctrl or shift key not press with Z |
205 | evt.preventDefault(); | 200 | evt.preventDefault(); |
206 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]}); | 201 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.zoomToolIndex]}); |
207 | return; | 202 | return; |
208 | } | 203 | } |