From bf7f2e5bcd2f3f0aef0fd1960c6c8ad51e3c004f Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 10 Feb 2020 17:25:50 +0100 Subject: [PATCH] Fix upload table horizontal scrollbar + add autoscroll --- www/common/sframe-common-file.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index 09f501df7..3d12f81ac 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -53,11 +53,17 @@ define([ var $table = File.$table = $('', { id: 'cp-fileupload-table' }); + var hover = false; var createTableContainer = function ($body) { File.$container = $('
', { id: 'cp-fileupload' }).append(tableHeader).append($table).appendTo($body); $('.cp-fileupload-header-close').click(function () { File.$container.fadeOut(); }); + File.$container.mouseenter(function () { + hover = true; + }).mouseleave(function () { + hover = false; + }); return File.$container; }; @@ -209,6 +215,11 @@ define([ window.setTimeout(function () { File.$container.show(); }); var file = queue.queue.shift(); if (file.dl) { return void file.dl(file); } + if (file.$line && file.$line[0] && !hover) { + var line = file.$line[0]; + line.scrollIntoView(false); + } + delete file.$line; upload(file); }; queue.push = function (obj) { @@ -224,7 +235,7 @@ define([ $('
', {'class':'cp-fileupload-table-progressbar'}).appendTo($progressContainer); $('', {'class':'cp-fileupload-table-progress-value'}).text(Messages.upload_pending).appendTo($progressContainer); - var $tr = $('
', {id: id}).appendTo($table); + var $tr = obj.$line = $('', {id: id}).appendTo($table); var $lines = $table.find('tr[id]'); if ($lines.length > 5) { //$lines.slice(0, $lines.length - 5).remove(); @@ -257,6 +268,15 @@ define([ // cancel $('
', {'class': 'cp-fileupload-table-cancel'}).append($cancel).appendTo($tr); + var tw = $table.width(); + var cw = File.$container.prop('clientWidth'); + var diff = tw - cw; + if (diff && diff > 0) { + $table.css('margin-right', diff+'px'); + } else { + $table.css('margin-right', ''); + } + queue.next(); };