Skip to content

Commit

Permalink
Cleaner implementation of subElements()
Browse files Browse the repository at this point in the history
It should return the list of subelements.  Whether these subelements are
populated should be determined by calling code.
  • Loading branch information
slusarz committed Jul 22, 2014
1 parent 300fb76 commit fc12737
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions imp/js/dimpbase.js
Expand Up @@ -3330,7 +3330,7 @@ var DimpBase = {
}

if (r.expand) {
this.flist.subElements(r.base).each(function(sub) {
this.flist.subElements(r.base).findAll(function(e) { return e.down(); }).each(function(sub) {
this._toggleSubFolder(sub, 'exp', {
noeffect: true,
noexpand: true,
Expand Down Expand Up @@ -4159,25 +4159,19 @@ var IMP_Flist = Class.create({

subElements: function(base)
{
var elts = [], tmp;

if (base) {
tmp = this.getMbox(base);
if (tmp) {
tmp = tmp.subElement();
if (tmp) {
elts = tmp.select('DIV.horde-subnavi').collect(
this.getMbox.bind(this)
).compact();
base = this.getMbox(base);
if (base) {
base = base.subElement();
if (base) {
return base.select('DIV.horde-subnavi-sub').compact();
}
}
} else {
elts = Object.values(this.mboxes);

return [];
}

return elts.invoke('subElement').compact().findAll(function(e) {
return e.down();
});
return Object.values(this.mboxes).invoke('subElement').compact();
}

});
Expand Down

0 comments on commit fc12737

Please sign in to comment.