Bug 1066558 - Cant collapse a tree in web IDE, after expanding it; r=bgrins

This commit is contained in:
Manu Jain 2014-10-08 15:49:48 -07:00
parent d46128c9fc
commit 27f203cfc2
2 changed files with 18 additions and 6 deletions

View File

@ -69,14 +69,12 @@ var ResourceContainer = Class({
this.elt.appendChild(this.children);
this.line.addEventListener("click", (evt) => {
if (!this.selected) {
this.select();
this.expanded = true;
evt.stopPropagation();
}
this.select();
this.toggleExpansion();
evt.stopPropagation();
}, false);
this.expander.addEventListener("click", (evt) => {
this.expanded = !this.expanded;
this.toggleExpansion();
this.select();
evt.stopPropagation();
}, true);
@ -87,6 +85,14 @@ var ResourceContainer = Class({
this.update();
},
toggleExpansion: function() {
if (!this.resource.isRoot) {
this.expanded = !this.expanded;
} else {
this.expanded = true;
}
},
destroy: function() {
this.elt.remove();
this.expander.remove();

View File

@ -39,10 +39,16 @@ function selectFileFirstLoad(projecteditor, resource) {
if (resource.isRoot) {
ok (container.expanded, "The root directory is expanded by default.");
container.line.click();
ok (container.expanded, "Clicking on the line does not toggles expansion.");
return;
}
if (resource.isDir) {
ok (!container.expanded, "A directory is not expanded by default.");
container.line.click();
ok (container.expanded, "Clicking on the line toggles expansion.");
container.line.click();
ok (!container.expanded, "Clicking on the line toggles expansion.");
return;
}