From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- .../layout/bread-crumb.reel/bread-crumb.js | 44 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'js/components/layout/bread-crumb.reel') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index 49dbe3cb..74e89ac1 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -9,13 +9,45 @@ var Montage = require("montage/core/core").Montage, exports.Breadcrumb = Montage.create(Component, { - disabled: { + _currentDocument: { + enumerable: false, + value: null + }, + + currentDocument: { + enumerable: false, + get: function() { + return this._currentDocument; + }, + set: function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + + if(!this._currentDocument) { + this.disabled = true; + } + + this.disabled = this._currentDocument.currentView !== "design"; + + } + }, + + + _disabled: { value: true }, - handleOpenDocument: { - value: function(){ - this.disabled = false; + disabled: { + get: function() { + return this._disabled; + }, + set: function(value) { + if(value !== this._disabled) { + this._disabled = value; + } } }, @@ -50,7 +82,6 @@ exports.Breadcrumb = Montage.create(Component, { prepareForDraw: { value: function() { - this.eventManager.addEventListener("openDocument", this, false); this.eventManager.addEventListener("closeDocument", this, false); this.breadcrumbBt.addEventListener("action", this, false); } @@ -65,7 +96,7 @@ exports.Breadcrumb = Montage.create(Component, { parentNode = this.container; - while(parentNode !== this.application.ninja.currentDocument.model.documentRoot) { + while(parentNode !== this.currentDocument.model.documentRoot) { this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); parentNode = parentNode.parentNode; } @@ -87,6 +118,7 @@ exports.Breadcrumb = Montage.create(Component, { this.containerElements.pop(); } + // TODO: This is bound 2 ways, update the internal property this.application.ninja.currentSelectedContainer = this.containerElements[i].node; } } -- cgit v1.2.3 From 31b094ee21102f99a4021d505bc3a28527c9e23d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 01:33:20 -0700 Subject: Fixing the close document. Signed-off-by: Valerio Virgillito --- js/components/layout/bread-crumb.reel/bread-crumb.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'js/components/layout/bread-crumb.reel') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index 74e89ac1..ac131f2c 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -26,12 +26,12 @@ exports.Breadcrumb = Montage.create(Component, { this._currentDocument = value; - if(!this._currentDocument) { + if(!value) { this.disabled = true; + } else { + this.disabled = this._currentDocument.currentView !== "design"; } - this.disabled = this._currentDocument.currentView !== "design"; - } }, @@ -51,15 +51,6 @@ exports.Breadcrumb = Montage.create(Component, { } }, - handleCloseDocument: { - value: function(){ - if(!this.application.ninja.documentController.activeDocument && this.application.ninja.currentDocument.currentView !== "code") { - this.disabled = true; - this.application.ninja.currentSelectedContainer = (this.application.ninja.currentDocument ? this.application.ninja.currentDocument.model.documentRoot : null); - } - } - }, - _container:{ value:null }, @@ -82,7 +73,6 @@ exports.Breadcrumb = Montage.create(Component, { prepareForDraw: { value: function() { - this.eventManager.addEventListener("closeDocument", this, false); this.breadcrumbBt.addEventListener("action", this, false); } }, -- cgit v1.2.3