diff --git a/vault/static/vault/js/vault.js b/vault/static/vault/js/vault.js index 708fc4c1..bf68fcc0 100644 --- a/vault/static/vault/js/vault.js +++ b/vault/static/vault/js/vault.js @@ -10,6 +10,8 @@ $(document).ajaxSend(function (e, request, settings) { } }) +let downloadChecksumReportTextTooltip +let downloadChecksumReportCSVTooltip let preservableFormatsLists = null let currentFolder let dataPackage = null @@ -24,6 +26,8 @@ $(function () { // Canonicalize path somewhat, for convenience. currentFolder = currentFolder.replace(/\/+/g, '/').replace(/\/$/, '') + createTooltips() + if ($('#file-browser').length) { // startBrowsing(browsePageItems); startBrowsing() @@ -49,8 +53,6 @@ $(function () { $('#showChecksumReport .collection').text(folder) $('#showChecksumReport .modal-body #checksumReport').html('') - $('#showChecksumReport .modal-footer .download-report-text').addClass('d-none') - $('#showChecksumReport .modal-footer .download-report-csv').addClass('d-none') $('#showChecksumReport .modal-footer .download-report-text').attr('href', downloadUrl + '&format=text') $('#showChecksumReport .modal-footer .download-report-csv').attr('href', downloadUrl + '&format=csv') @@ -59,23 +61,35 @@ $(function () { let table = '' table += '' - $.each(data, function (index, obj) { - if (data.length > 0) { + if (data.length > 0) { + $.each(data, function (index, obj) { table += ` - - - - ` - $('#showChecksumReport .modal-footer .download-report-text').removeClass('d-none') - $('#showChecksumReport .modal-footer .download-report-csv').removeClass('d-none') + + + + ` + }) + if (downloadChecksumReportTextTooltip) { + downloadChecksumReportTextTooltip.disable() } - }) + if (downloadChecksumReportCSVTooltip) { + downloadChecksumReportCSVTooltip.disable() + } + } else { + $('#showChecksumReport .modal-footer .download-report-text').removeAttr('href') + $('#showChecksumReport .modal-footer .download-report-csv').removeAttr('href') + if (downloadChecksumReportTextTooltip) { + downloadChecksumReportTextTooltip.enable() + } + if (downloadChecksumReportCSVTooltip) { + downloadChecksumReportCSVTooltip.enable() + } + } table += '
FilenameSizeChecksum
${obj.name}${obj.size}${obj.checksum}
${obj.name}${obj.size}${obj.checksum}
' $('#showChecksumReport .modal-body #checksumReport').html(table) $('#showChecksumReport').modal('show') }) - }) $('body').on('click', 'a.action-check-for-unpreservable-files', function () { // Check for unpreservable file formats. @@ -306,6 +320,16 @@ $(function () { }) }) +function createTooltips () { + const downloadChecksumReportText = $('.download-report-text').parent() + downloadChecksumReportTextTooltip = new bootstrap.Tooltip(downloadChecksumReportText) + downloadChecksumReportTextTooltip.disable() + + const downloadChecksumReportCSV = $('.download-report-csv').parent() + downloadChecksumReportCSVTooltip = new bootstrap.Tooltip(downloadChecksumReportCSV) + downloadChecksumReportCSVTooltip.disable() +} + function changeBrowserUrl (path) { let url = window.location.pathname if (typeof path !== 'undefined') { diff --git a/vault/templates/vault/browse.html b/vault/templates/vault/browse.html index 0c23a61f..eb2fb593 100644 --- a/vault/templates/vault/browse.html +++ b/vault/templates/vault/browse.html @@ -189,8 +189,12 @@