Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9347874
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
View Options
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 d4b48fcc..4e87bda8 100644
--- a/swh/web/assets/src/bundles/browse/swh-ids-utils.js
+++ b/swh/web/assets/src/bundles/browse/swh-ids-utils.js
@@ -1,107 +1,117 @@
/**
* 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 'thirdparty/jquery.tabSlideOut/jquery.tabSlideOut';
import 'thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.css';
+import {BREAKPOINT_SM} from 'utils/constants';
+
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')) {
if (currentSwhId.indexOf(originPart) === -1) {
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'
+ tabLocation: 'right',
+ offset: function() {
+ const width = $(window).width();
+ if (width < BREAKPOINT_SM) {
+ return '250px';
+ } else {
+ return '200px';
+ }
+ }
};
// 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);
// set the tab visible once the close animation is terminated
$('#swh-identifiers').css('display', 'block');
$('.swh-id-option-origin').trigger('click');
$('.swh-id-option-lines').trigger('click');
$(window).on('hashchange', () => {
setIdLinesPart('.swh-id-option-lines');
});
});
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jul 4 2025, 5:59 PM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3252226
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment