},
// num = (integer) See absolute.
- // absolute = Is num an absolute row number - from 1 -> page_size (true) -
- // or a relative change from the current selected value (false)
+ // absolute = (boolean) Is num an absolute row number - from 1 ->
+ // page_size (true) - or a relative change from the current
+ // selected value (false)
// If no current selected value, the first message in the
// current viewport is selected.
- moveSelected: function(num, absolute)
+ // bottom = (boolean) Make selected appear at bottom?
+ moveSelected: function(num, absolute, bottom)
{
var curr, curr_row, row, row_data, sel;
if (row.size()) {
row_data = row.get('dataob').first();
if (!curr_row || row_data.imapuid != curr_row.imapuid) {
- this.viewport.scrollTo(row_data.VP_rownum);
+ this.viewport.scrollTo(row_data.VP_rownum, { bottom: bottom });
this.viewport.select(row, { delay: 0.3 });
}
} else {
this.msgSelect(row.VP_domid, { shift: true });
}
} else {
- this.moveSelected(kc == Event.KEY_UP ? -1 : 1);
+ this.moveSelected(kc == Event.KEY_UP ? -1 : 1, false, kc == Event.KEY_DOWN);
}
e.stop();
break;
break;
}
}
- this.moveSelected(move);
+ this.moveSelected(move, false, kc == Event.KEY_PAGEDOWN);
e.stop();
}
break;
},
// rownum = (integer) Row number
- // opts = (Object) [noupdate, top] TODO
+ // opts = (Object) [bottom, noupdate, top] TODO
scrollTo: function(rownum, opts)
{
- var s = this.scroller;
+ var s = this.scroller,
+ to = null;
opts = opts || {};
s.noupdate = opts.noupdate;
switch (this.isVisible(rownum)) {
case -1:
- s.moveScroll(rownum - 1);
+ to = rownum - 1;
break;
case 0:
if (opts.top) {
- s.moveScroll(rownum - 1);
+ to = rownum - 1;
}
break;
case 1:
- s.moveScroll(Math.min(rownum - 1, this.getMetaData('total_rows') - this.getPageSize()));
+ to = opts.bottom
+ ? Math.max(0, rownum - this.getPageSize())
+ : Math.min(rownum - 1, this.getMetaData('total_rows') - this.getPageSize());
break;
}
+ if (to !== null) {
+ s.moveScroll(to);
+ }
+
s.noupdate = false;
},