aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
authorArmen Kesablyan2012-02-07 16:55:34 -0800
committerArmen Kesablyan2012-02-07 16:55:34 -0800
commit10f0ad4c15f090b2d0d50d11e4c7aaf291e9eb0e (patch)
tree12b31910a3c7c7fa2ee0b26d8aaa611710e139a5 /js/mediators
parent7f8730c3add146f1ba107e6fc22d1f5a8348ed8b (diff)
parent668510892537eaaeb2e11520831d87b44b2489b7 (diff)
downloadninja-10f0ad4c15f090b2d0d50d11e4c7aaf291e9eb0e.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into text-tool
Conflicts: _scss/compass_app_log.txt css/ninja.css
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/drag-drop-mediator.js9
-rw-r--r--js/mediators/element-mediator.js38
-rw-r--r--js/mediators/keyboard-mediator.js6
3 files changed, 37 insertions, 16 deletions
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js
index 07e4a50c..aacb228c 100644
--- 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++) {
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index 91b09475..c44e1cb5 100644
--- 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 );
@@ -92,6 +96,11 @@ exports.ElementMediator = Montage.create(NJComponent, {
92 _addElement: { 96 _addElement: {
93 value: function(el, rules, noEvent) { 97 value: function(el, rules, noEvent) {
94 ElementController.addElement(el, rules); 98 ElementController.addElement(el, rules);
99 var p3d = this.get3DProperties(el);
100 if(p3d)
101 {
102 el.elementModel.controller["set3DProperties"](el, [p3d], 0, true);
103 }
95 if(!noEvent) NJevent("elementAdded", el); 104 if(!noEvent) NJevent("elementAdded", el);
96 } 105 }
97 }, 106 },
@@ -420,7 +429,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
420 el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); 429 el.elementModel.controller["set3DProperties"](el, props, i, update3DModel);
421 } 430 }
422 431
423 NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": props, "value": props}, redraw: null}); 432 NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": "matrix", "value": props}, redraw: null});
424 } 433 }
425 }, 434 },
426 435
@@ -431,7 +440,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
431 getColor: { 440 getColor: {
432 value: function(el, isFill) { 441 value: function(el, isFill) {
433 if(!el.elementModel) { 442 if(!el.elementModel) {
434 NJUtils.makeElementModel(el, "Div", "block"); 443 NJUtils.makeElementModel2(el);
435 } 444 }
436 return el.elementModel.controller["getColor"](el, isFill); 445 return el.elementModel.controller["getColor"](el, isFill);
437 } 446 }
@@ -457,7 +466,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
457 if(!currentValue) { 466 if(!currentValue) {
458 var that = this; 467 var that = this;
459 currentValue = els.map(function(item) { 468 currentValue = els.map(function(item) {
460 return that.getColor(item._element); 469 return that.getColor(item._element, isFill);
461 }); 470 });
462 } 471 }
463 472
@@ -589,6 +598,15 @@ exports.ElementMediator = Montage.create(NJComponent, {
589 } 598 }
590 }, 599 },
591 600
601 getColor2: {
602 value: function(el, prop, mutator) {
603 if(!el.elementModel) {
604 NJUtils.makeElementModel2(el);
605 }
606
607 return this.getColor(el, (prop === "background"));
608 }
609 },
592 610
593 //-------------------------------------------------------------------------------------------------------- 611 //--------------------------------------------------------------------------------------------------------
594 // Routines to get/set 3D properties 612 // Routines to get/set 3D properties
@@ -646,11 +664,11 @@ exports.ElementMediator = Montage.create(NJComponent, {
646 664
647 if(isChanging) 665 if(isChanging)
648 { 666 {
649 NJevent("elementChanging", {type : "setMatrix", source: null, data: {"el": el, "prop": "matrix", "value": mat}, redraw: null}); 667 NJevent("elementChanging", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null});
650 } 668 }
651 else 669 else
652 { 670 {
653 NJevent("elementChange", {type : "setMatrix", source: null, data: {"el": el, "prop": "matrix", "value": mat}, redraw: null}); 671 NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null});
654 } 672 }
655 } 673 }
656 }, 674 },
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js
index 144932c0..a1fdead3 100644
--- 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]});