From: Aleksander Ɓukasz Date: Tue, 18 Feb 2014 15:10:58 +0000 (+0100) Subject: editor: fix - better handle node removal in various views X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/ea854b3eae2b03d3eab4f9b937798024648fc8ed?ds=inline editor: fix - better handle node removal in various views --- diff --git a/src/editor/modules/metadataEditor/metadataEditor.js b/src/editor/modules/metadataEditor/metadataEditor.js index 1088247..70df62e 100644 --- a/src/editor/modules/metadataEditor/metadataEditor.js +++ b/src/editor/modules/metadataEditor/metadataEditor.js @@ -191,7 +191,7 @@ return function(sandbox) { if(event.type === 'metadataRemoved' && event.meta.node.sameNode(currentNode)) { view.removeMetadataRow(event.meta.row); } - if(event.type === 'nodeDetached' && event.meta.node.sameNode(currentNode)) { + if(event.type === 'nodeDetached' && event.meta.node.containsNode(currentNode)) { view.setMetadata(null); } }); diff --git a/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js b/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js index 188aa6e..0540542 100644 --- a/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js +++ b/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js @@ -8,7 +8,8 @@ define([ return function(sandbox) { - var template = _.template(templateSrc); + var template = _.template(templateSrc), + listens = false; var view = { dom: $('
' + template({node:null, parents: null}) + '
'), @@ -58,6 +59,14 @@ return function(sandbox) { start: function() { sandbox.publish('ready'); }, getView: function() { return view.dom; }, setNodeElement: function(nodeElement) { + if(!listens && nodeElement) { + nodeElement.document.on('change', function() { + if(view.currentNodeElement && !view.currentNodeElement.isInDocument()) { + view.setNodeElement(null); + } + }); + listens = true; + } view.setNodeElement(nodeElement); }, highlightNode: function(id) { view.highlightNode(id); }, diff --git a/src/editor/modules/nodePane/nodePane.js b/src/editor/modules/nodePane/nodePane.js index f7e6694..85a6fdd 100644 --- a/src/editor/modules/nodePane/nodePane.js +++ b/src/editor/modules/nodePane/nodePane.js @@ -35,6 +35,9 @@ return function(sandbox) { var module = this; if(!listens) { wlxmlNodeElement.document.on('change', function(event) { + if(currentNode && !currentNode.isInDocument()) { + module.setNodeElement(null); + } if(event.type === 'nodeAttrChange' && event.meta.node.sameNode(currentNode)) { module.setNodeElement(currentNode); }