aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators')
-rwxr-xr-xjs/mediators/drag-drop-mediator.js11
-rwxr-xr-xjs/mediators/element-mediator.js40
-rwxr-xr-xjs/mediators/keyboard-mediator.js6
3 files changed, 40 insertions, 17 deletions
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js
index 07e4a50c..ede71383 100755
--- a/js/mediators/drag-drop-mediator.js
+++ b/js/mediators/drag-drop-mediator.js
@@ -62,7 +62,7 @@ exports.DragDropMediator = Montage.create(Component, {
62 62
63 handleDropEvent: { 63 handleDropEvent: {
64 value: function(evt){ 64 value: function(evt){
65 var xferString, component; 65 var xferString, component, file, files, idx, len;
66 66
67 this.baseX = evt.offsetX - this.application.ninja.stage.userContentLeft; 67 this.baseX = evt.offsetX - this.application.ninja.stage.userContentLeft;
68 this.baseY = evt.offsetY - this.application.ninja.stage.userContentTop; 68 this.baseY = evt.offsetY - this.application.ninja.stage.userContentTop;
@@ -85,11 +85,8 @@ exports.DragDropMediator = Montage.create(Component, {
85 return; 85 return;
86 } 86 }
87 87
88 var file; 88 files = evt.dataTransfer.files;
89 const files = evt.dataTransfer.files; 89 len = files.length;
90 var idx;
91 const len = files.length;
92
93 90
94 // Loop over all dragged files... 91 // Loop over all dragged files...
95 for (idx = 0; idx < len; idx++) { 92 for (idx = 0; idx < len; idx++) {
@@ -125,7 +122,7 @@ exports.DragDropMediator = Montage.create(Component, {
125 122
126 NJUtils.makeElementModel(domElem, "SVG", "block"); 123 NJUtils.makeElementModel(domElem, "SVG", "block");
127 } else { // treat as a regular image 124 } else { // treat as a regular image
128 domElem = NJUtils.makeNJElement("image", "Image", "block"); 125 domElem = NJUtils.makeNJElement("image", "image", "image");
129 domElem.src = evt2.currentTarget.result; 126 domElem.src = evt2.currentTarget.result;
130 } 127 }
131 128
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index a6f31703..9aefbca6 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -44,12 +44,16 @@ exports.ElementMediator = Montage.create(NJComponent, {
44 this.deleteDelegate.handleDelete(); 44 this.deleteDelegate.handleDelete();
45 } else { 45 } else {
46 // Add the Undo/Redo 46 // Add the Undo/Redo
47 var els = []; 47 var els = [],
48 len = this.application.ninja.selectedElements.length;
48 49
49 if(this.application.ninja.selectedElements.length > 0) { 50 if(len) {
50 for(var i=0, item; item = this.application.ninja.selectedElements[i]; i++) { 51 for(var i = 0; i<len; i++) {
51 ElementController.removeElement(item._element); 52 els.push(this.application.ninja.selectedElements[i]);
52 els.push(item._element); 53 }
54
55 for(i=0; i<len; i++) {
56 this._removeElement(els[i]._element);
53 } 57 }
54 58
55 NJevent( "deleteSelection", els ); 59 NJevent( "deleteSelection", els );
@@ -108,6 +112,13 @@ exports.ElementMediator = Montage.create(NJComponent, {
108 } 112 }
109 }, 113 },
110 114
115 replaceElement: {
116 value: function(el, el2) {
117 el2.elementModel = el.elementModel;
118 this.application.ninja.currentDocument.documentRoot.replaceChild(el2, el);
119 }
120 },
121
111 getNJProperty: { 122 getNJProperty: {
112 value: function(el, p) { 123 value: function(el, p) {
113 if(el.elementModel) { 124 if(el.elementModel) {
@@ -425,7 +436,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
425 el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); 436 el.elementModel.controller["set3DProperties"](el, props, i, update3DModel);
426 } 437 }
427 438
428 NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": props, "value": props}, redraw: null}); 439 NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": "matrix", "value": props}, redraw: null});
429 } 440 }
430 }, 441 },
431 442
@@ -436,7 +447,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
436 getColor: { 447 getColor: {
437 value: function(el, isFill) { 448 value: function(el, isFill) {
438 if(!el.elementModel) { 449 if(!el.elementModel) {
439 NJUtils.makeElementModel(el, "Div", "block"); 450 NJUtils.makeElementModel2(el);
440 } 451 }
441 return el.elementModel.controller["getColor"](el, isFill); 452 return el.elementModel.controller["getColor"](el, isFill);
442 } 453 }
@@ -462,7 +473,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
462 if(!currentValue) { 473 if(!currentValue) {
463 var that = this; 474 var that = this;
464 currentValue = els.map(function(item) { 475 currentValue = els.map(function(item) {
465 return that.getColor(item._element); 476 return that.getColor(item._element, isFill);
466 }); 477 });
467 } 478 }
468 479
@@ -594,6 +605,15 @@ exports.ElementMediator = Montage.create(NJComponent, {
594 } 605 }
595 }, 606 },
596 607
608 getColor2: {
609 value: function(el, prop, mutator) {
610 if(!el.elementModel) {
611 NJUtils.makeElementModel2(el);
612 }
613
614 return this.getColor(el, (prop === "background"));
615 }
616 },
597 617
598 //-------------------------------------------------------------------------------------------------------- 618 //--------------------------------------------------------------------------------------------------------
599 // Routines to get/set 3D properties 619 // Routines to get/set 3D properties
@@ -651,11 +671,11 @@ exports.ElementMediator = Montage.create(NJComponent, {
651 671
652 if(isChanging) 672 if(isChanging)
653 { 673 {
654 NJevent("elementChanging", {type : "setMatrix", source: null, data: {"el": el, "prop": "matrix", "value": mat}, redraw: null}); 674 NJevent("elementChanging", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null});
655 } 675 }
656 else 676 else
657 { 677 {
658 NJevent("elementChange", {type : "setMatrix", source: null, data: {"el": el, "prop": "matrix", "value": mat}, redraw: null}); 678 NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null});
659 } 679 }
660 } 680 }
661 }, 681 },
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js
index 144932c0..a1fdead3 100755
--- a/js/mediators/keyboard-mediator.js
+++ b/js/mediators/keyboard-mediator.js
@@ -178,6 +178,12 @@ exports.KeyboardMediator = Montage.create(Component, {
178 return; 178 return;
179 } 179 }
180 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
181 if(evt.keyCode === Keyboard.Z ) { 187 if(evt.keyCode === Keyboard.Z ) {
182 evt.preventDefault(); 188 evt.preventDefault();
183 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[16]}); 189 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[16]});