diff --git a/swh/web/assets/src/bundles/browse/swh-ids-utils.js b/swh/web/assets/src/bundles/browse/swh-ids-utils.js index 94cfc1cb5..7e8b05330 100644 --- a/swh/web/assets/src/bundles/browse/swh-ids-utils.js +++ b/swh/web/assets/src/bundles/browse/swh-ids-utils.js @@ -1,102 +1,107 @@ /** * Copyright (C) 2018 The Software Heritage developers * See the AUTHORS file at the top-level directory of this distribution * License: GNU Affero General Public License version 3, or any later version * See top-level LICENSE file for more information */ import ClipboardJS from 'clipboard'; import 'utils/jquery.tabSlideOut'; import 'utils/jquery.tabSlideOut.css'; export function swhIdObjectTypeToggled(event) { event.preventDefault(); $(event.target).tab('show'); } export function swhIdOptionOriginToggled(event) { event.stopPropagation(); let swhIdElt = $(event.target).closest('.swh-id-ui').find('.swh-id'); let originPart = ';origin=' + $(event.target).data('swh-origin'); let currentSwhId = swhIdElt.text(); if ($(event.target).prop('checked')) { currentSwhId += originPart; } else { currentSwhId = currentSwhId.replace(originPart, ''); } swhIdElt.text(currentSwhId); swhIdElt.attr('href', '/' + currentSwhId + '/'); } function setIdLinesPart(elt) { let swhIdElt = $(elt).closest('.swh-id-ui').find('.swh-id'); let currentSwhId = swhIdElt.text(); let lines = []; let linesPart = ';lines='; let linesRegexp = new RegExp(/L(\d+)/g); let line = linesRegexp.exec(window.location.hash); while (line) { lines.push(parseInt(line[1])); line = linesRegexp.exec(window.location.hash); } if (lines.length > 0) { linesPart += lines[0]; } if (lines.length > 1) { linesPart += '-' + lines[1]; } if ($(elt).prop('checked')) { currentSwhId = currentSwhId.replace(/;lines=\d+-*\d*/g, ''); currentSwhId += linesPart; } else { currentSwhId = currentSwhId.replace(linesPart, ''); } swhIdElt.text(currentSwhId); swhIdElt.attr('href', '/' + currentSwhId + '/'); } export function swhIdOptionLinesToggled(event) { event.stopPropagation(); if (!window.location.hash) { return; } setIdLinesPart(event.target); } $(document).ready(() => { new ClipboardJS('.btn-swh-id-copy', { text: trigger => { let swhId = $(trigger).closest('.swh-id-ui').find('.swh-id').text(); return swhId; } }); new ClipboardJS('.btn-swh-id-url-copy', { text: trigger => { let swhId = $(trigger).closest('.swh-id-ui').find('.swh-id').text(); return window.location.origin + '/' + swhId + '/'; } }); if (window.innerWidth * 0.7 > 1000) { $('#swh-identifiers').css('width', '1000px'); } let tabSlideOptions = { tabLocation: 'right' }; // ensure tab scrolling on small screens if (window.innerHeight < 600 || window.innerWidth < 500) { tabSlideOptions['otherOffset'] = '20px'; } + // initiate the sliding identifiers tab $('#swh-identifiers').tabSlideOut(tabSlideOptions); - $('.swh-id-option-origin').trigger('click'); - $('.swh-id-option-lines').trigger('click'); + // set the tab visible once the close animation is terminated + setTimeout(() => { + $('#swh-identifiers').css('visibility', 'visible'); + $('.swh-id-option-origin').trigger('click'); + $('.swh-id-option-lines').trigger('click'); + }); $(window).on('hashchange', () => { setIdLinesPart('.swh-id-option-lines'); }); }); diff --git a/swh/web/templates/includes/show-swh-ids.html b/swh/web/templates/includes/show-swh-ids.html index 269285765..05ef45079 100644 --- a/swh/web/templates/includes/show-swh-ids.html +++ b/swh/web/templates/includes/show-swh-ids.html @@ -1,95 +1,95 @@ {% comment %} Copyright (C) 2017-2018 The Software Heritage developers See the AUTHORS file at the top-level directory of this distribution License: GNU Affero General Public License version 3, or any later version See top-level LICENSE file for more information {% endcomment %} {% load swh_templatetags %} {% if swh_ids %} -
To reference or cite the objects present in the Software Heritage archive, permalinks based on persistent identifiers
must be used instead of copying and pasting the url from the address bar of the browser (as there is no guarantee the current URI
scheme will remain the same over time).
Select below a type of object currently browsed in order to display its associated persistent identifier and permalink.