Page MenuHomeSoftware Heritage

No OneTemporary

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 b3ebbc8c..94cfc1cb 100644
--- a/swh/web/assets/src/bundles/browse/swh-ids-utils.js
+++ b/swh/web/assets/src/bundles/browse/swh-ids-utils.js
@@ -1,93 +1,102 @@
/**
* 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 + '/';
}
});
- $('#swh-identifiers').tabSlideOut({
- tabLocation: 'right',
- otherOffset: '28vh'
- });
+ 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';
+ }
+
+ $('#swh-identifiers').tabSlideOut(tabSlideOptions);
$('.swh-id-option-origin').trigger('click');
$('.swh-id-option-lines').trigger('click');
$(window).on('hashchange', () => {
setIdLinesPart('.swh-id-option-lines');
});
});

File Metadata

Mime Type
text/x-diff
Expires
Mon, Aug 25, 6:15 PM (6 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3253489

Event Timeline