Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/browse/swh-ids-utils.js
/** | /** | ||||
* Copyright (C) 2018 The Software Heritage developers | * Copyright (C) 2018 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
import ClipboardJS from 'clipboard'; | import ClipboardJS from 'clipboard'; | ||||
import 'thirdparty/jquery.tabSlideOut/jquery.tabSlideOut'; | import 'thirdparty/jquery.tabSlideOut/jquery.tabSlideOut'; | ||||
import 'thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.css'; | import 'thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.css'; | ||||
import {BREAKPOINT_SM} from 'utils/constants'; | |||||
export function swhIdObjectTypeToggled(event) { | export function swhIdObjectTypeToggled(event) { | ||||
event.preventDefault(); | event.preventDefault(); | ||||
$(event.target).tab('show'); | $(event.target).tab('show'); | ||||
} | } | ||||
export function swhIdOptionOriginToggled(event) { | export function swhIdOptionOriginToggled(event) { | ||||
event.stopPropagation(); | event.stopPropagation(); | ||||
let swhIdElt = $(event.target).closest('.swh-id-ui').find('.swh-id'); | let swhIdElt = $(event.target).closest('.swh-id-ui').find('.swh-id'); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | new ClipboardJS('.btn-swh-id-url-copy', { | ||||
} | } | ||||
}); | }); | ||||
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 = { | ||||
tabLocation: 'right' | tabLocation: 'right', | ||||
offset: function() { | |||||
const width = $(window).width(); | |||||
anlambert: Once D1583 is landed, you should use the newly introduced constants here. | |||||
if (width < BREAKPOINT_SM) { | |||||
return '250px'; | |||||
} else { | |||||
return '200px'; | |||||
} | |||||
} | |||||
}; | }; | ||||
// ensure tab scrolling on small screens | // ensure tab scrolling on small screens | ||||
if (window.innerHeight < 600 || window.innerWidth < 500) { | if (window.innerHeight < 600 || window.innerWidth < 500) { | ||||
tabSlideOptions['otherOffset'] = '20px'; | tabSlideOptions['otherOffset'] = '20px'; | ||||
} | } | ||||
// initiate the sliding identifiers tab | // initiate the sliding identifiers tab | ||||
$('#swh-identifiers').tabSlideOut(tabSlideOptions); | $('#swh-identifiers').tabSlideOut(tabSlideOptions); | ||||
Show All 11 Lines |
Once D1583 is landed, you should use the newly introduced constants here.