From 806974142d44afdd23534bf2d18eff0a8e701e0c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 8 Jun 2012 16:59:59 -0700 Subject: rewrite: currentSelectedContainer -> domContainer Fixed the currentSelectedContainer by removing bindings and using property change on the current document added the red outline back. Signed-off-by: Valerio Virgillito --- .../layout/bread-crumb.reel/bread-crumb.js | 42 +++++++++------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'js/components') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index ac131f2c..260922b3 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -51,22 +51,6 @@ exports.Breadcrumb = Montage.create(Component, { } }, - _container:{ - value:null - }, - - container: { - set: function(value) { - if(this._container !== value) { - this._container = value; - this.createContainerElements(); - } - }, - get: function() { - return this._container; - } - }, - containerElements: { value: [] }, @@ -74,31 +58,37 @@ exports.Breadcrumb = Montage.create(Component, { prepareForDraw: { value: function() { this.breadcrumbBt.addEventListener("action", this, false); + this.addPropertyChangeListener("currentDocument.model.domContainer", this) } }, - createContainerElements: { + handleChange: { value: function() { - var parentNode; + if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) { + this.createContainerElements(this.currentDocument.model.getProperty("domContainer")); + } + } + }, + + createContainerElements: { + value: function(container) { // delete this.containerElements; this.containerElements = []; - parentNode = this.container; - - while(parentNode !== this.currentDocument.model.documentRoot) { - this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); - parentNode = parentNode.parentNode; + while(container !== this.currentDocument.model.documentRoot) { + this.containerElements.unshift({"node": container, "nodeUuid":container.uuid, "label": container.nodeName}); + container = container.parentNode; } // This is always the top container which is now hardcoded to body - this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); + this.containerElements.unshift({"node": container, "nodeUuid":container.uuid, "label": container.nodeName}); } }, handleAction: { value: function(evt) { - if(evt.target.value === this.container.uuid) { + if(evt.target.value === this.currentDocument.model.domContainer.uuid) { return; } @@ -109,7 +99,7 @@ exports.Breadcrumb = Montage.create(Component, { } // TODO: This is bound 2 ways, update the internal property - this.application.ninja.currentSelectedContainer = this.containerElements[i].node; + this.currentDocument.model.domContainer = this.containerElements[i].node; } } }); -- cgit v1.2.3