aboutsummaryrefslogtreecommitdiff
path: root/js/mediators/element-mediator.js
diff options
context:
space:
mode:
authorEric Guzman2012-04-09 15:44:09 -0700
committerEric Guzman2012-04-09 15:44:09 -0700
commita27915e900eb768dd9db1f0dd441961ea80bfaa6 (patch)
tree593f429f0b3294103a059ae9f6ed03858288deb7 /js/mediators/element-mediator.js
parentafcaa157f7bc067cf00de91b43b2a71e9b64b7b3 (diff)
parentbd43ce383b050d03b0f92cc923c517febc66ca28 (diff)
downloadninja-a27915e900eb768dd9db1f0dd441961ea80bfaa6.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/mediators/element-mediator.js')
-rwxr-xr-xjs/mediators/element-mediator.js36
1 files changed, 26 insertions, 10 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index 09f2aeed..a05ca631 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -28,16 +28,15 @@ exports.ElementMediator = Montage.create(Component, {
28 value: function(elements, rules, notify) { 28 value: function(elements, rules, notify) {
29 if(Array.isArray(elements)) { 29 if(Array.isArray(elements)) {
30 elements.forEach(function(element) { 30 elements.forEach(function(element) {
31 element = element;
32 ElementController.addElement(element, rules); 31 ElementController.addElement(element, rules);
32 if(element.elementModel && element.elementModel.props3D) {
33 element.elementModel.props3D.init(element, false);
34 }
33 }); 35 });
34 } else { 36 } else {
35 ElementController.addElement(elements, rules); 37 ElementController.addElement(elements, rules);
36 38 if(elements.elementModel && elements.elementModel.props3D) {
37 // TODO - Check with webgl branch - Props seem to be already there. 39 elements.elementModel.props3D.init(elements, false);
38 var prop3d = this.get3DProperties(elements);
39 if(prop3d) {
40 elements.elementModel.controller["set3DProperties"](elements, [prop3d], 0, true);
41 } 40 }
42 } 41 }
43 42
@@ -84,6 +83,23 @@ exports.ElementMediator = Montage.create(Component, {
84 } 83 }
85 }, 84 },
86 85
86 replaceElement: {
87 value: function(newChild, oldChild, notify) {
88
89 this.application.ninja.currentDocument.documentRoot.replaceChild(newChild, oldChild);
90
91 var undoLabel = "replace element";
92
93 document.application.undoManager.add(undoLabel, this.replaceElement, this, oldChild, newChild);
94
95 this.application.ninja.documentController.activeDocument.needsSave = true;
96
97 if(notify || notify === undefined) {
98 NJevent("elementReplaced", {type : "replaceElement", data: {"newChild": newChild, "oldChild": oldChild}});
99 }
100 }
101 },
102
87 getProperty: { 103 getProperty: {
88 value: function(el, prop, valueMutator) { 104 value: function(el, prop, valueMutator) {
89 if(!el.elementModel) { 105 if(!el.elementModel) {
@@ -248,7 +264,7 @@ exports.ElementMediator = Montage.create(Component, {
248 var el; 264 var el;
249 265
250 for(var i=0, item; item = els[i]; i++) { 266 for(var i=0, item; item = els[i]; i++) {
251 item.elementModel.controller["setProperty"](item, p, value[i]); 267 item.elementModel.controller["setProperty"](item, p, value[i], eventType, source);
252 } 268 }
253 269
254 NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null}); 270 NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null});
@@ -588,14 +604,14 @@ exports.ElementMediator = Montage.create(Component, {
588 }, 604 },
589 605
590 setMatrix: { 606 setMatrix: {
591 value: function(el, mat, isChanging) { 607 value: function(el, mat, isChanging, source) {
592 var dist = el.elementModel.controller["getPerspectiveDist"](el); 608 var dist = el.elementModel.controller["getPerspectiveDist"](el);
593 el.elementModel.controller["set3DProperties"](el, [{mat:mat, dist:dist}], 0, !isChanging); 609 el.elementModel.controller["set3DProperties"](el, [{mat:mat, dist:dist}], 0, !isChanging);
594 610
595 if(isChanging) { 611 if(isChanging) {
596 NJevent("elementChanging", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); 612 NJevent("elementChanging", {type : "setMatrix", source: source, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null});
597 } else { 613 } else {
598 NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); 614 NJevent("elementChange", {type : "setMatrix", source: source, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null});
599 } 615 }
600 } 616 }
601 }, 617 },