From 9d17dc8dab12aa661ab321567f024406f4972abb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 15:34:14 -0800 Subject: cleanup of the breadcrumb Signed-off-by: Valerio Virgillito --- .../layout/bread-crumb.reel/bread-crumb.js | 112 ++++++--------------- 1 file changed, 30 insertions(+), 82 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 ead7c764..1290aaac 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -1,6 +1,6 @@ -var Montage = require("montage/core/core").Montage -var Component = require("montage/ui/component").Component +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { @@ -8,15 +8,12 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { value:null }, - container: { set: function(value) { - if(this._container !== value) { - this._container = value; - this.createContainerElements(); - } - - + if(this._container !== value) { + this._container = value; + this.createContainerElements(); + } }, get: function() { return this._container; @@ -25,7 +22,6 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { containerElements: { value: [] - }, @@ -33,14 +29,12 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { value: function() { this.eventManager.addEventListener( "appLoaded", this, false); this.eventManager.addEventListener( "breadCrumbTrail", this, false); - }, - enumerable : false + } }, handleAppLoaded : { value: function() { - Object.defineBinding(this, "container", { boundObject: this.application.ninja, boundObjectPropertyPath: "currentSelectedContainer", @@ -50,107 +44,61 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { } }, - prepareForDraw: { - value: function() { - - } - }, - - draw: { - value: function() { - - } - }, - - didDraw:{ - value:function(){ - } - }, - createContainerElements: { value: function() { - var parentNode; - while(this.containerElements.pop()){ - // To empty the array to get the new parentNode of the new currentLevel - } - - if(this.container.id === "UserContent"){ - - this.containerElements.push({selected:false,element:this.container}); - + this.containerElements.length = 0 - } - else{ - - parentNode= this.container; - - while(parentNode.id!=="UserContent"){ - - this.containerElements.unshift ({selected:false,element:parentNode}); - parentNode=parentNode.parentNode; + if(this.container.id === "UserContent") { + this.containerElements.push({selected:false, element:this.container}); + } else { + parentNode = this.container; - } - - this.containerElements.unshift({selected:false,element:parentNode}); + while(parentNode.id!=="UserContent") { + this.containerElements.unshift({selected:false,element:parentNode}); + parentNode = parentNode.parentNode; + } + this.containerElements.unshift({selected:false,element:parentNode}); } NJevent('layerBinding',{selected:false ,element:this.container}) - - } }, - - handleBreadCrumbTrail: { + handleBreadCrumbTrail: { value: function(event) { + var newLength,revaluatedLength,tmpvalue; + var i=0; - var newLength,revaluatedLength,tmpvalue - var i=0; - if(event.detail.setFlag){ - this.application.ninja.currentSelectedContainer = event.detail.element; - return; + if(event.detail.setFlag ){ + this.application.ninja.currentSelectedContainer = event.detail.element; + return; } newLength = this.containerElements.length; while(i < newLength ){ - - if(this.containerElements[i].selected){ - - tmpvalue = i ; - break; - - } - + if(this.containerElements[i].selected){ + tmpvalue = i; + break; + } i++; } - - - for(i = newLength -1 ; i >= 1 ; i--){ - - if(tmpvalue!==i){ - + for(i = newLength -1 ; i >= 1 ; i--) { + if(tmpvalue !== i) { this.containerElements.pop(); - } - - else{ - + } else { break; } - } revaluatedLength = this.containerElements.length; this.application.ninja.currentSelectedContainer = this.containerElements[revaluatedLength-1].element; - } } - - }); -- cgit v1.2.3