Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/browse/swhid-utils.js
Show All 14 Lines | export function swhIdObjectTypeToggled(event) { | ||||
event.preventDefault(); | event.preventDefault(); | ||||
$(event.target).tab('show'); | $(event.target).tab('show'); | ||||
} | } | ||||
export function swhIdContextOptionToggled(event) { | export function swhIdContextOptionToggled(event) { | ||||
event.stopPropagation(); | event.stopPropagation(); | ||||
let swhIdElt = $(event.target).closest('.swhid-ui').find('.swhid'); | let swhIdElt = $(event.target).closest('.swhid-ui').find('.swhid'); | ||||
let swhIdWithContext = $(event.target).data('swhid-with-context'); | let swhIdWithContext = $(event.target).data('swhid-with-context'); | ||||
let swhIdWithContextUrl = $(event.target).data('swhid-with-context-url'); | |||||
let currentSwhId = swhIdElt.text(); | let currentSwhId = swhIdElt.text(); | ||||
if ($(event.target).prop('checked')) { | if ($(event.target).prop('checked')) { | ||||
currentSwhId = swhIdWithContext; | currentSwhId = swhIdWithContext; | ||||
swhIdElt.attr('href', swhIdWithContextUrl); | |||||
} else { | } else { | ||||
const pos = currentSwhId.indexOf(';'); | const pos = currentSwhId.indexOf(';'); | ||||
if (pos !== -1) { | if (pos !== -1) { | ||||
currentSwhId = currentSwhId.slice(0, pos); | currentSwhId = currentSwhId.slice(0, pos); | ||||
} | } | ||||
swhIdElt.attr('href', '/' + currentSwhId + '/'); | |||||
} | } | ||||
swhIdElt.text(currentSwhId); | swhIdElt.text(currentSwhId); | ||||
swhIdElt.attr('href', '/' + currentSwhId + '/'); | |||||
addLinesInfo(); | addLinesInfo(); | ||||
} | } | ||||
function addLinesInfo() { | function addLinesInfo() { | ||||
let swhIdElt = $('#swhid-tab-content').find('.swhid'); | let swhIdElt = $('#swhid-tab-content').find('.swhid'); | ||||
let currentSwhId = swhIdElt.text(); | let currentSwhId = swhIdElt.text(); | ||||
let lines = []; | let lines = []; | ||||
Show All 27 Lines | new ClipboardJS('.btn-swhid-copy', { | ||||
text: trigger => { | text: trigger => { | ||||
let swhId = $(trigger).closest('.swhid-ui').find('.swhid').text(); | let swhId = $(trigger).closest('.swhid-ui').find('.swhid').text(); | ||||
return swhId; | return swhId; | ||||
} | } | ||||
}); | }); | ||||
new ClipboardJS('.btn-swhid-url-copy', { | new ClipboardJS('.btn-swhid-url-copy', { | ||||
text: trigger => { | text: trigger => { | ||||
let swhId = $(trigger).closest('.swhid-ui').find('.swhid').text(); | let swhIdUrl = $(trigger).closest('.swhid-ui').find('.swhid').attr('href'); | ||||
return window.location.origin + '/' + swhId + '/'; | return window.location.origin + swhIdUrl; | ||||
} | } | ||||
}); | }); | ||||
if (window.innerWidth * 0.7 > 1000) { | if (window.innerWidth * 0.7 > 1000) { | ||||
$('#swh-identifiers').css('width', '1000px'); | $('#swh-identifiers').css('width', '1000px'); | ||||
} | } | ||||
let tabSlideOptions = { | let tabSlideOptions = { | ||||
Show All 34 Lines |