Finish modals

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-09 15:57:39 +01:00
parent 19f99ff9d3
commit 378ee4632f
3 changed files with 25 additions and 10 deletions

View File

@ -181,6 +181,7 @@ navigation:
class: fa-solid fa-phone class: fa-solid fa-phone
url: "tel:+491781798023" url: "tel:+491781798023"
identifier: "+491781798023" identifier: "+491781798023"
target: _top
- name: Encrypted Email (PGP) - name: Encrypted Email (PGP)
description: Access my PGP key description: Access my PGP key
icon: icon:

View File

@ -2,8 +2,13 @@ function openDynamicPopup(subitem) {
// Schließe alle offenen Modals // Schließe alle offenen Modals
closeAllModals(); closeAllModals();
// Setze den Titel // Setze den Titel mit Icon, falls vorhanden
document.getElementById('dynamicModalLabel').innerText = subitem.name; const modalTitle = document.getElementById('dynamicModalLabel');
if (subitem.icon && subitem.icon.class) {
modalTitle.innerHTML = `<i class="${subitem.icon.class}"></i> ${subitem.name}`;
} else {
modalTitle.innerText = subitem.name;
}
// Setze den Identifier, falls vorhanden // Setze den Identifier, falls vorhanden
const identifierBox = document.getElementById('dynamicIdentifierBox'); const identifierBox = document.getElementById('dynamicIdentifierBox');
@ -16,6 +21,16 @@ function openDynamicPopup(subitem) {
modalContent.value = ''; modalContent.value = '';
} }
// Zeige die Beschreibung, falls keine URL vorhanden ist
const descriptionText = document.getElementById('dynamicDescriptionText');
if (!subitem.url && subitem.description) {
descriptionText.classList.remove('d-none');
descriptionText.innerText = subitem.description;
} else {
descriptionText.classList.add('d-none');
descriptionText.innerText = '';
}
// Konfiguriere die Warnbox // Konfiguriere die Warnbox
const warningBox = document.getElementById('dynamicModalWarning'); const warningBox = document.getElementById('dynamicModalWarning');
if (subitem.warning) { if (subitem.warning) {
@ -47,9 +62,11 @@ function openDynamicPopup(subitem) {
} }
// Konfiguriere die Alternativen // Konfiguriere die Alternativen
const alternativesSection = document.getElementById('dynamicAlternativesSection');
const alternativesList = document.getElementById('dynamicAlternativesList'); const alternativesList = document.getElementById('dynamicAlternativesList');
alternativesList.innerHTML = ''; // Clear existing alternatives alternativesList.innerHTML = ''; // Clear existing alternatives
if (subitem.alternatives && subitem.alternatives.length > 0) { if (subitem.alternatives && subitem.alternatives.length > 0) {
alternativesSection.classList.remove('d-none');
subitem.alternatives.forEach(alt => { subitem.alternatives.forEach(alt => {
const listItem = document.createElement('li'); const listItem = document.createElement('li');
listItem.classList.add('list-group-item', 'd-flex', 'justify-content-between', 'align-items-center'); listItem.classList.add('list-group-item', 'd-flex', 'justify-content-between', 'align-items-center');
@ -62,10 +79,7 @@ function openDynamicPopup(subitem) {
alternativesList.appendChild(listItem); alternativesList.appendChild(listItem);
}); });
} else { } else {
const noAltItem = document.createElement('li'); alternativesSection.classList.add('d-none');
noAltItem.classList.add('list-group-item');
noAltItem.innerText = 'No alternatives available.';
alternativesList.appendChild(noAltItem);
} }
// Kopierfunktion für den Identifier // Kopierfunktion für den Identifier

View File

@ -14,6 +14,8 @@
<div id="dynamicModalInfo" class="alert alert-info d-none" role="alert"> <div id="dynamicModalInfo" class="alert alert-info d-none" role="alert">
<i class="fa-solid fa-circle-info"></i> <span id="dynamicModalInfoText"></span> <i class="fa-solid fa-circle-info"></i> <span id="dynamicModalInfoText"></span>
</div> </div>
<!-- Description text, falls vorhanden -->
<div id="dynamicDescriptionText" class="mt-2 d-none"></div>
<!-- Eingabebox für Identifier --> <!-- Eingabebox für Identifier -->
<div id="dynamicIdentifierBox" class="input-group mt-2 d-none"> <div id="dynamicIdentifierBox" class="input-group mt-2 d-none">
<input type="text" id="dynamicModalContent" class="form-control" readonly> <input type="text" id="dynamicModalContent" class="form-control" readonly>
@ -24,11 +26,9 @@
<a href="#" target="_blank" class="btn btn-primary w-100" id="dynamicModalLinkHref"></a> <a href="#" target="_blank" class="btn btn-primary w-100" id="dynamicModalLinkHref"></a>
</div> </div>
<!-- Alternativen, falls vorhanden --> <!-- Alternativen, falls vorhanden -->
<div id="dynamicAlternatives" class="mt-4"> <div id="dynamicAlternativesSection" class="mt-4 d-none">
<h6>Alternatives:</h6> <h6>Alternatives:</h6>
<ul class="list-group" id="dynamicAlternativesList"> <ul class="list-group" id="dynamicAlternativesList"></ul>
<li class="list-group-item">No alternatives available.</li>
</ul>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">