hide table header on empty list

This commit is contained in:
Daniela Arcese 2017-07-05 09:50:00 -04:00
parent 2735fa577f
commit 88ba5352d4
2 changed files with 35 additions and 22 deletions

View File

@ -13,11 +13,15 @@ $(document).ready(function() {
$('#upload-progress').hide(); $('#upload-progress').hide();
$('#share-link').hide(); $('#share-link').hide();
if (localStorage.length === 0) {
toggleHeader();
} else {
for (let i = 0; i < localStorage.length; i++) { for (let i = 0; i < localStorage.length; i++) {
const id = localStorage.key(i); const id = localStorage.key(i);
//check if file exists before adding to list //check if file exists before adding to list
checkExistence(id, true); checkExistence(id, true);
} }
}
// copy link to clipboard // copy link to clipboard
$copyBtn.click(() => { $copyBtn.click(() => {
@ -55,7 +59,7 @@ $(document).ready(function() {
} else { } else {
file = event.target.files[0]; file = event.target.files[0];
} }
const expiration = 2 * 60 * 1000; //will eventually come from a field const expiration = 24 * 60 * 60 * 1000; //will eventually come from a field
const fileSender = new FileSender(file); const fileSender = new FileSender(file);
fileSender.on('progress', percentComplete => { fileSender.on('progress', percentComplete => {
@ -196,6 +200,7 @@ $(document).ready(function() {
FileSender.delete(file.fileId, file.deleteToken).then(() => { FileSender.delete(file.fileId, file.deleteToken).then(() => {
$(e.target).parents('tr').remove(); $(e.target).parents('tr').remove();
localStorage.removeItem(file.fileId); localStorage.removeItem(file.fileId);
toggleHeader();
}); });
}); });
@ -224,5 +229,14 @@ $(document).ready(function() {
function toggleShow() { function toggleShow() {
$popupText.toggleClass('show'); $popupText.toggleClass('show');
} }
toggleHeader();
}
function toggleHeader() {
//hide table header if empty list
if (document.querySelector('tbody').childNodes.length === 1) {
$('#file-list').hide();
} else {
$('#file-list').show();
}
} }
}); });

View File

@ -36,8 +36,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="file-list"> <div id="file-list">
<table id="uploaded-files"> <table id="uploaded-files">
<thead> <thead>
@ -55,6 +53,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<div id="upload-progress"> <div id="upload-progress">
<div class="title" id="upload-filename"> <div class="title" id="upload-filename">