diff options
author | Jose Antonio Marquez | 2012-04-10 11:24:35 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-10 11:24:35 -0700 |
commit | e663e336ee7e832b5059a82748061506b414cb04 (patch) | |
tree | a09d932319365067f437780e90aeab4ef19f74b4 /js/mediators/element-mediator.js | |
parent | c3022de5ba2e24737184dba7454233b165da0a20 (diff) | |
parent | bd43ce383b050d03b0f92cc923c517febc66ca28 (diff) | |
download | ninja-e663e336ee7e832b5059a82748061506b414cb04.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/mediators/element-mediator.js')
-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 | }, |