Add Library Listing page card ctrl-click support (#1796) (#1983)

This commit is contained in:
daveoconnor
2025-10-22 11:42:25 -07:00
committed by GitHub
parent 30e2f76d03
commit 1ec3cba5e3
5 changed files with 19 additions and 3 deletions

15
static/js/utils.js Normal file
View File

@@ -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;
}

View File

@@ -36,6 +36,7 @@
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script> <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<script src="{% static 'js/theme_handling.js' %}"></script> <script src="{% static 'js/theme_handling.js' %}"></script>
<script src="{% static 'js/scroll-to-link.js' %}" defer></script> <script src="{% static 'js/scroll-to-link.js' %}" defer></script>
<script src="{% static 'js/utils.js' %}"></script>
<script src="{% static 'js/boost-gecko/main.C3hPHS6-.js' %}" defer></script> <script src="{% static 'js/boost-gecko/main.C3hPHS6-.js' %}" defer></script>
{% block extra_head %} {% block extra_head %}
<link href="{% static 'css/styles.css' %}" rel="stylesheet"> <link href="{% static 'css/styles.css' %}" rel="stylesheet">

View File

@@ -1,5 +1,5 @@
<tr class="border-0 md:border border-gray-200/10 border-dotted md:border-t-0 md:border-r-0 md:border-l-0 md:border-b-1 hover:bg-gray-100 dark:hover:bg-gray-700 transition-all duration-200 ease-in-out cursor-pointer" <tr class="border-0 md:border border-gray-200/10 border-dotted md:border-t-0 md:border-r-0 md:border-l-0 md:border-b-1 hover:bg-gray-100 dark:hover:bg-gray-700 transition-all duration-200 ease-in-out cursor-pointer"
onclick="window.location='{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}'"> onclick="handleCardClick(event, '{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}')">
<td class="py-2 align-top md:w-1/5"> <td class="py-2 align-top md:w-1/5">
<a class="mr-1 font-bold capitalize text-sky-600 dark:text-sky-300 hover:text-orange dark:hover:text-orange" <a class="mr-1 font-bold capitalize text-sky-600 dark:text-sky-300 hover:text-orange dark:hover:text-orange"
href="{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}" href="{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}"

View File

@@ -2,7 +2,7 @@
{% load date_filters %} {% load date_filters %}
<div class="relative content-between p-3 bg-white md:rounded-lg md:shadow-lg md:p-5 dark:bg-charcoal hover:bg-gray-100 dark:hover:bg-gray-700 transition-all duration-200 ease-in-out cursor-pointer" <div class="relative content-between p-3 bg-white md:rounded-lg md:shadow-lg md:p-5 dark:bg-charcoal hover:bg-gray-100 dark:hover:bg-gray-700 transition-all duration-200 ease-in-out cursor-pointer"
onclick="window.location='{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}'"> onclick="handleCardClick(event, '{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}')">
<div class=""> <div class="">
<h3 class="pb-2 text-xl md:text-2xl capitalize border-b border-gray-700"> <h3 class="pb-2 text-xl md:text-2xl capitalize border-b border-gray-700">
<div class="flex justify-between"> <div class="flex justify-between">

View File

@@ -1,5 +1,5 @@
<tr class="border-0 md:border border-gray-200/10 border-dotted md:border-t-0 md:border-r-0 md:border-l-0 md:border-b-1 hover:bg-gray-100 dark:hover:bg-gray-700 transition-all duration-300 ease-in-out cursor-pointer" <tr class="border-0 md:border border-gray-200/10 border-dotted md:border-t-0 md:border-r-0 md:border-l-0 md:border-b-1 hover:bg-gray-100 dark:hover:bg-gray-700 transition-all duration-300 ease-in-out cursor-pointer"
onclick="window.location='{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}'"> onclick="handleCardClick(event, '{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}')">
<td class="align-top md:w-1/5 pt-3"> <td class="align-top md:w-1/5 pt-3">
<a class="mr-1 pl-1 font-bold capitalize text-sky-600 dark:text-sky-300 hover:text-orange dark:hover:text-orange" <a class="mr-1 pl-1 font-bold capitalize text-sky-600 dark:text-sky-300 hover:text-orange dark:hover:text-orange"
href="{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}">{{ library_version.library.name }}</a> href="{% url 'library-detail' library_slug=library_version.library.slug version_slug=version_str %}">{{ library_version.library.name }}</a>