Fix upload table horizontal scrollbar + add autoscroll

pull/1/head
yflory 5 years ago
parent f9eea74b54
commit bf7f2e5bcd

@ -53,11 +53,17 @@ define([
var $table = File.$table = $('<table>', { id: 'cp-fileupload-table' }); var $table = File.$table = $('<table>', { id: 'cp-fileupload-table' });
var hover = false;
var createTableContainer = function ($body) { var createTableContainer = function ($body) {
File.$container = $('<div>', { id: 'cp-fileupload' }).append(tableHeader).append($table).appendTo($body); File.$container = $('<div>', { id: 'cp-fileupload' }).append(tableHeader).append($table).appendTo($body);
$('.cp-fileupload-header-close').click(function () { $('.cp-fileupload-header-close').click(function () {
File.$container.fadeOut(); File.$container.fadeOut();
}); });
File.$container.mouseenter(function () {
hover = true;
}).mouseleave(function () {
hover = false;
});
return File.$container; return File.$container;
}; };
@ -209,6 +215,11 @@ define([
window.setTimeout(function () { File.$container.show(); }); window.setTimeout(function () { File.$container.show(); });
var file = queue.queue.shift(); var file = queue.queue.shift();
if (file.dl) { return void file.dl(file); } 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); upload(file);
}; };
queue.push = function (obj) { queue.push = function (obj) {
@ -224,7 +235,7 @@ define([
$('<div>', {'class':'cp-fileupload-table-progressbar'}).appendTo($progressContainer); $('<div>', {'class':'cp-fileupload-table-progressbar'}).appendTo($progressContainer);
$('<span>', {'class':'cp-fileupload-table-progress-value'}).text(Messages.upload_pending).appendTo($progressContainer); $('<span>', {'class':'cp-fileupload-table-progress-value'}).text(Messages.upload_pending).appendTo($progressContainer);
var $tr = $('<tr>', {id: id}).appendTo($table); var $tr = obj.$line = $('<tr>', {id: id}).appendTo($table);
var $lines = $table.find('tr[id]'); var $lines = $table.find('tr[id]');
if ($lines.length > 5) { if ($lines.length > 5) {
//$lines.slice(0, $lines.length - 5).remove(); //$lines.slice(0, $lines.length - 5).remove();
@ -257,6 +268,15 @@ define([
// cancel // cancel
$('<td>', {'class': 'cp-fileupload-table-cancel'}).append($cancel).appendTo($tr); $('<td>', {'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(); queue.next();
}; };

Loading…
Cancel
Save