From db0fa4e454b76d8a2bd6ba47c6f10166761179e7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 4 Apr 2012 14:06:38 -0700 Subject: 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 --- js/mediators/element-mediator.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'js/mediators') 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, { } }, + replaceElement: { + value: function(newChild, oldChild, notify) { + + this.application.ninja.currentDocument.documentRoot.replaceChild(newChild, oldChild); + + var undoLabel = "replace element"; + + document.application.undoManager.add(undoLabel, this.replaceElement, this, oldChild, newChild); + + this.application.ninja.documentController.activeDocument.needsSave = true; + + if(notify || notify === undefined) { + NJevent("elementReplaced", {type : "replaceElement", data: {"newChild": newChild, "oldChild": oldChild}}); + } + } + }, + getProperty: { value: function(el, prop, valueMutator) { if(!el.elementModel) { -- cgit v1.2.3