Skip to content

Commit

Permalink
[mms] Improved handling for multiple expand/collapse actions in the d…
Browse files Browse the repository at this point in the history
…ynamic folder list (Bug #13170).
  • Loading branch information
slusarz committed May 13, 2014
1 parent ca0cf8c commit 00e92fc
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 35 deletions.
2 changes: 2 additions & 0 deletions imp/docs/CHANGES
Expand Up @@ -2,6 +2,8 @@
v6.2.0-git
----------

[mms] Improved handling for multiple expand/collapse actions in the dynamic
folder list (Bug #13170).
[mms] Provide visual UI info to user that file is uploading when drag/drop
attachments in dynamic view.

Expand Down
80 changes: 46 additions & 34 deletions imp/js/dimpbase.js
Expand Up @@ -3417,7 +3417,8 @@ var DimpBase = {

_toggleSubFolder: function(base, mode, noeffect, noexpand)
{
var collapse = [], expand = [], need = [], subs = [];
var collapse = [], expand = [], subs = [],
need = $H();

if (mode == 'expall' || mode == 'colall') {
if (base.hasClassName('horde-subnavi-sub')) {
Expand All @@ -3437,67 +3438,76 @@ var DimpBase = {
subs = [ base.next('.horde-subnavi-sub') ];
}

subs = subs.compact();
if (!subs) {
return;
}

if (mode == 'tog' || mode == 'expall') {
subs.compact().each(function(s) {
subs.each(function(s) {
if (!s.visible() && !s.childElements().size()) {
need.push(s.previous().retrieve('mbox'));
need.set(s.previous().retrieve('mbox'), 1);
}
});

if (need.size()) {
if (mode == 'tog') {
base.down('A').update(
new Element('SPAN')
.addClassName('imp-sidebar-mbox-loading')
.update('[' + DimpCore.text.loading + ']')
);
}
if (need.size() && mode == 'expall') {
this._listMboxes({
all: ~~(mode == 'expall'),
all: 1,
base: base,
expall: ~~(mode == 'expall'),
mboxes: need
expall: 1,
mboxes: need.keys()
});
return;
} else if (mode == 'tog') {
// Need to pass element here, since we might be working
// with 'special' mailboxes.
this.setMboxLabel(base);
}
}

subs.each(function(s) {
if (mode == 'tog' ||
((mode == 'exp' || mode == 'expall') && !s.visible()) ||
((mode == 'col' || mode == 'colall') && s.visible())) {
s.previous().down().toggleClassName('exp').toggleClassName('col');
var mbox = s.previous().retrieve('mbox');

if (mode == 'col' ||
((mode == 'tog') && s.visible())) {
collapse.push(s.previous().retrieve('mbox'));
collapse.push(mbox);
} else if (!noexpand &&
(mode == 'exp' ||
((mode == 'tog') && !s.visible()))) {
expand.push(s.previous().retrieve('mbox'));
expand.push(mbox);
}

if (noeffect) {
s.toggle();
} else {
Effect.toggle(s, 'blind', {
duration: 0.2,
queue: {
position: 'end',
scope: 'subfolder'
Effect.toggle(s, 'blind', {
beforeStart: function(e) {
if (need.get(mbox)) {
this.getMboxElt(mbox).down('A').update(
new Element('SPAN')
.addClassName('imp-sidebar-mbox-loading')
.update('[' + DimpCore.text.loading + ']')
);

this._listMboxes({
base: base,
mboxes: [ mbox ]
}, true);

e.element = this.getSubMboxElt(mbox);

// Need to pass element here, since we might be
// working with 'special' mailboxes.
this.setMboxLabel(this.getMboxElt(mbox));
}
});
}
}.bindAsEventListener(this),
afterFinish: function() {
this.getMboxElt(mbox).down().toggleClassName('exp').toggleClassName('col');
}.bind(this),
duration: noeffect ? 0 : 0.2,
queue: {
limit: 1,
scope: 'subfolder' + mbox
}
});
}
});
}, this);

if (DimpCore.conf.mbox_expand) {
if (collapse.size()) {
Expand All @@ -3510,7 +3520,7 @@ var DimpBase = {
}
},

_listMboxes: function(params)
_listMboxes: function(params, sync)
{
params = params || {};
params.unsub = ~~(!!this.showunsub);
Expand All @@ -3522,7 +3532,9 @@ var DimpBase = {
}
params.mboxes = Object.toJSON(params.mboxes);

DimpCore.doAction('listMailboxes', params);
DimpCore.doAction('listMailboxes', params, {
ajaxopts: { asynchronous: !sync }
});
},

// For format of the ob object, see
Expand Down
1 change: 0 additions & 1 deletion imp/lib/Ajax/Application/Handler/Dynamic.php
Expand Up @@ -396,7 +396,6 @@ public function listMailboxes()
}
}
} else {
$this->_base->queue->setMailboxOpt('expand', 1);
$filter->add($filter::EXPANDED);

foreach (IMP_Mailbox::formFrom(json_decode($this->vars->mboxes)) as $val) {
Expand Down
2 changes: 2 additions & 0 deletions imp/package.xml
Expand Up @@ -33,6 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mms] Improved handling for multiple expand/collapse actions in the dynamic folder list (Bug #13170).
* [mms] Provide visual UI info to user that file is uploading when drag/drop attachments in dynamic view.
</notes>
<contents>
Expand Down Expand Up @@ -3593,6 +3594,7 @@
<date>2014-05-05</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mms] Improved handling for multiple expand/collapse actions in the dynamic folder list (Bug #13170).
* [mms] Provide visual UI info to user that file is uploading when drag/drop attachments in dynamic view.
</notes>
</release>
Expand Down

0 comments on commit 00e92fc

Please sign in to comment.