Skip to content

Commit

Permalink
fix(search) : Correction du click sur les structures arpès une recher…
Browse files Browse the repository at this point in the history
…che par mot clé
  • Loading branch information
SebastienReuiller authored Feb 19, 2024
1 parent 949cb4c commit e232b45
Showing 1 changed file with 39 additions and 32 deletions.
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);
}
}

0 comments on commit e232b45

Please sign in to comment.