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 --- .../bread-crumb-button.reel/bread-crumb-button.js | 35 +++---- .../layout/bread-crumb.reel/bread-crumb.js | 112 ++++++--------------- 2 files changed, 44 insertions(+), 103 deletions(-) (limited to 'js/components') diff --git a/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js b/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js index 65e5b7c8..3f5b87e1 100755 --- a/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js +++ b/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js @@ -7,45 +7,38 @@ var Montage = require("montage/core/core").Montage; var Component = require("montage/ui/component").Component; - exports.BreadcrumbButton = Montage.create(Component, { - button: { value: null }, + button: { + value: null + }, - data: { value: null }, + data: { + value: null + }, prepareForDraw: { - enumerable: false, value: function() { this.element.addEventListener("mousedown", this, false); } }, draw: { - enumerable: false, value: function() { - - if(this.data.element.id==="UserContent"){ - - this.button.innerHTML = "Body"; - } - - else{ - this.button.innerHTML=this.data.element.nodeName; - } - + if(this.data.element.id === "UserContent") { + this.button.innerHTML = "Body"; + } else { + this.button.innerHTML = this.data.element.nodeName; + } } }, handleMousedown: { value: function(event) { - if(event.which===1){ - - this.data.selected=true; - NJevent('breadCrumbTrail',this.data); - this.data.selected=false; - } + //this.data.selected=true; + NJevent('breadCrumbTrail',this.data); + //this.data.selected=false; } } 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 From b1daf0b285a4a96bfd0086709c20e3682d75551a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 14:32:17 -0800 Subject: fixing the dirty flag and removing sass changes Signed-off-by: Valerio Virgillito --- .../layout/document-entry.reel/document-entry.html | 1 - .../layout/document-entry.reel/document-entry.js | 24 ++++++++++------------ .../layout/documents-tab.reel/documents-tab.html | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) (limited to 'js/components') diff --git a/js/components/layout/document-entry.reel/document-entry.html b/js/components/layout/document-entry.reel/document-entry.html index ba17449a..1cf01737 100755 --- a/js/components/layout/document-entry.reel/document-entry.html +++ b/js/components/layout/document-entry.reel/document-entry.html @@ -26,7 +26,6 @@
  • -
  • diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js index a1bed79b..9e4110e2 100755 --- a/js/components/layout/document-entry.reel/document-entry.js +++ b/js/components/layout/document-entry.reel/document-entry.js @@ -77,19 +77,17 @@ exports.DocumentEntry = Montage.create(Component, { } }, - _dirtyFlag:{ - enumerable:false, - value:false + _saveFlag: { + value: false }, - dirtyFlag:{ + + saveFlag: { get: function() { - return this._dirtyFlag; + return this._saveFlag; }, set: function(value) { - var previousValue = this._dirtyFlag; - this._dirtyFlag = value; - - if (previousValue !== this._dirtyFlag) { + if(this._saveFlag !== value) { + this._saveFlag = value; this.needsDraw = true; } } @@ -110,10 +108,10 @@ exports.DocumentEntry = Montage.create(Component, { this._active ? this.element.classList.add("activeTab") : this.element.classList.remove("activeTab"); - if(this.dirtyFlag === true){ - if(!this.label.classList.contains("dirty")){this.label.classList.add("dirty");} - }else{ - if(this.label.classList.contains("dirty")){this.label.classList.remove("dirty");} + if(this.saveFlag) { + this.label.classList.add("dirty"); + } else { + this.label.classList.remove("dirty"); } } }, diff --git a/js/components/layout/documents-tab.reel/documents-tab.html b/js/components/layout/documents-tab.reel/documents-tab.html index 82ba8782..737dfbcb 100755 --- a/js/components/layout/documents-tab.reel/documents-tab.html +++ b/js/components/layout/documents-tab.reel/documents-tab.html @@ -38,9 +38,9 @@ "boundObjectPropertyPath": "objectAtCurrentIteration.name", "oneway": true }, - "dirtyFlag": { + "saveFlag": { "boundObject": {"@": "repetition1"}, - "boundObjectPropertyPath": "objectAtCurrentIteration.dirtyFlag", + "boundObjectPropertyPath": "objectAtCurrentIteration.needsSave", "oneway": true }, "active": { -- cgit v1.2.3