diff --git a/static/js/utils.js b/static/js/utils.js new file mode 100644 index 00000000..33113a69 --- /dev/null +++ b/static/js/utils.js @@ -0,0 +1,15 @@ +/** + * handles card click navigation with modifier key support + * @param {Event} event - the click event + * @param {string} url - the URL to navigate to + */ +function handleCardClick(event, url) { + if (event.target.tagName === 'A' || event.target.closest('a')) { + return; + } + if (event.ctrlKey || event.metaKey || event.shiftKey) { + window.open(url, '_blank'); + return; + } + window.location = url; +} diff --git a/templates/base.html b/templates/base.html index 4bca066b..3a4fefa8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -36,6 +36,7 @@ + {% block extra_head %} diff --git a/templates/libraries/_library_categorized_list_item.html b/templates/libraries/_library_categorized_list_item.html index 9b77ec23..11e73783 100644 --- a/templates/libraries/_library_categorized_list_item.html +++ b/templates/libraries/_library_categorized_list_item.html @@ -1,5 +1,5 @@