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 hover = false;
var createTableContainer = function ($body) {
File.$container = $('<div>', { 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([
$('<div>', {'class':'cp-fileupload-table-progressbar'}).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]');
if ($lines.length > 5) {
//$lines.slice(0, $lines.length - 5).remove();
@ -257,6 +268,15 @@ define([
// cancel
$('<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();
};

Loading…
Cancel
Save