diff options
author | Nivesh Rajbhandari | 2012-04-04 14:06:38 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-04-04 14:06:38 -0700 |
commit | db0fa4e454b76d8a2bd6ba47c6f10166761179e7 (patch) | |
tree | ad28f7324d2d08163247e9be8f0982d6739e5eaf /js/mediators | |
parent | 8482e23cd9b8c4700b5130f2588e5eb24d376536 (diff) | |
download | ninja-db0fa4e454b76d8a2bd6ba47c6f10166761179e7.tar.gz |
Adding replaceElement routine and event so Timeline can avoid removing and adding layers and PI and SelectionController can avoid deselecting and reselecting the element.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/element-mediator.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 09f2aeed..b0efc02b 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -84,6 +84,23 @@ exports.ElementMediator = Montage.create(Component, { | |||
84 | } | 84 | } |
85 | }, | 85 | }, |
86 | 86 | ||
87 | replaceElement: { | ||
88 | value: function(newChild, oldChild, notify) { | ||
89 | |||
90 | this.application.ninja.currentDocument.documentRoot.replaceChild(newChild, oldChild); | ||
91 | |||
92 | var undoLabel = "replace element"; | ||
93 | |||
94 | document.application.undoManager.add(undoLabel, this.replaceElement, this, oldChild, newChild); | ||
95 | |||
96 | this.application.ninja.documentController.activeDocument.needsSave = true; | ||
97 | |||
98 | if(notify || notify === undefined) { | ||
99 | NJevent("elementReplaced", {type : "replaceElement", data: {"newChild": newChild, "oldChild": oldChild}}); | ||
100 | } | ||
101 | } | ||
102 | }, | ||
103 | |||
87 | getProperty: { | 104 | getProperty: { |
88 | value: function(el, prop, valueMutator) { | 105 | value: function(el, prop, valueMutator) { |
89 | if(!el.elementModel) { | 106 | if(!el.elementModel) { |