diff options
author | Jon Reid | 2012-04-10 14:52:23 -0700 |
---|---|---|
committer | Jon Reid | 2012-04-10 14:52:23 -0700 |
commit | c19987997758cf47ac9b93a2a767a0e2a9072745 (patch) | |
tree | eb68491c5d04a5cf5ab75bedf2d6bbed3c7a3603 /js/mediators | |
parent | 03a3b32b9b0fd2dc8e4b54bfd5282fd1f8fb6ed6 (diff) | |
parent | 422b14fc60be84c116115f2e71e3499e232f3f05 (diff) | |
download | ninja-c19987997758cf47ac9b93a2a767a0e2a9072745.tar.gz |
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/element-mediator.js | 36 |
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 | }, |