From: Michael M Slusarz Date: Fri, 14 Jan 2011 23:18:37 +0000 (-0700) Subject: Fix down/Page down behavior in dimp viewport X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f391c12b6ee913e2456d5c7cc60443caf53c4c34;p=horde.git Fix down/Page down behavior in dimp viewport --- diff --git a/imp/js/dimpbase.js b/imp/js/dimpbase.js index e9edfd0f3..f2b5a815a 100644 --- a/imp/js/dimpbase.js +++ b/imp/js/dimpbase.js @@ -99,11 +99,13 @@ var DimpBase = { }, // 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; @@ -141,7 +143,7 @@ var DimpBase = { 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 { @@ -1869,7 +1871,7 @@ var DimpBase = { 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; @@ -1911,7 +1913,7 @@ var DimpBase = { break; } } - this.moveSelected(move); + this.moveSelected(move, false, kc == Event.KEY_PAGEDOWN); e.stop(); } break; diff --git a/imp/js/viewport.js b/imp/js/viewport.js index 7f09f3be2..29fb3f09e 100644 --- a/imp/js/viewport.js +++ b/imp/js/viewport.js @@ -350,30 +350,37 @@ var ViewPort = Class.create({ }, // 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; },