Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(search) : Correction du click sur les structures après une recherche par mot clé #1092

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 39 additions & 32 deletions lemarche/static/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,11 @@ window.addEventListener('DOMContentLoaded', function () {

initModalMessages();

$('.super-badge-badge').each(function (element) {
$(this).tooltip(
{
html: true,
placement: "bottom",
title: $('#tooltip-super-badge').html()
});
// reload click events and tooltip after htmx content loading as in semantic search
document.addEventListener('htmx:afterSwap', function(event) {
initSuperBadges();
});

document.querySelectorAll('.siae-card[data-url]').forEach(function (card) {
card.addEventListener('click', function (event) {
if (event.target.className == 'ri-star-line ri-xl') {
// manage case of favorites
event.preventDefault()
}
else if (this.dataset.url) window.open(this.dataset.url, '_blank');

});
});

$('.s-tabs-01__nav .nav-item').on('click', function (event) {
event.preventDefault()
let tabContent = this.parentElement.parentElement.querySelector(".tab-content");
let hasSuperBadgeTab = this.children[0].classList.contains("super-badge-tab");

if (hasSuperBadgeTab) {
tabContent.classList.add("super-badge-tab");
} else {
tabContent.classList.remove("super-badge-tab");
}
$(this).tab('show')
})
initSuperBadges();
});

let toggleRequiredClasses = (toggle, element) => {
Expand Down Expand Up @@ -86,8 +59,42 @@ const initModalMessages = () => {
}
}

const initSuperBadges = () => {
$('.super-badge-badge').each(function (element) {
$(this).tooltip(
{
html: true,
placement: "bottom",
title: $('#tooltip-super-badge').html()
});
});

document.querySelectorAll('.siae-card[data-url]').forEach(function (card) {
card.addEventListener('click', function (event) {
if (event.target.className == 'ri-star-line ri-xl') {
// manage case of favorites
event.preventDefault();
}
else if (this.dataset.url) window.open(this.dataset.url, '_blank');

});
});
$('.s-tabs-01__nav .nav-item').on('click', function (event) {
event.preventDefault()
let tabContent = this.parentElement.parentElement.querySelector(".tab-content");
let hasSuperBadgeTab = this.children[0].classList.contains("super-badge-tab");

if (hasSuperBadgeTab) {
tabContent.classList.add("super-badge-tab");
} else {
tabContent.classList.remove("super-badge-tab");
}
$(this).tab('show');
})
}

function OpenBootstrapModal(elmt) {
setTimeout(function () {
$(elmt).modal('show');
}, 1000);
}
}
Loading