103 lines
3.5 KiB
JavaScript
103 lines
3.5 KiB
JavaScript
/**
|
|
* Script pour la page de liste des capacités de traduction
|
|
* Gère les interactions (toggle des enfants, etc.)
|
|
*/
|
|
(function($) {
|
|
'use strict';
|
|
|
|
$(document).ready(function() {
|
|
// Toggle des règles dépendantes (enfants)
|
|
$('.toggle-children').on('click', function(e) {
|
|
e.preventDefault();
|
|
|
|
const $button = $(this);
|
|
const $card = $button.closest('.capacite-card');
|
|
const $children = $card.find('.card-children');
|
|
|
|
// Toggle de l'affichage
|
|
if ($children.is(':visible')) {
|
|
$children.slideUp(300);
|
|
$button.removeClass('active');
|
|
} else {
|
|
$children.slideDown(300);
|
|
$button.addClass('active');
|
|
}
|
|
});
|
|
|
|
// Animation au survol des cartes
|
|
$('.capacite-card').hover(
|
|
function() {
|
|
$(this).css('transform', 'translateY(-2px)');
|
|
},
|
|
function() {
|
|
$(this).css('transform', 'translateY(0)');
|
|
}
|
|
);
|
|
|
|
// Highlight des cartes pleines
|
|
$('.capacite-card.full').each(function() {
|
|
const $card = $(this);
|
|
// Animation subtile pour attirer l'attention
|
|
setInterval(function() {
|
|
$card.css('border-left-color', '#d63638');
|
|
setTimeout(function() {
|
|
$card.css('border-left-color', '#f0b849');
|
|
}, 1000);
|
|
}, 2000);
|
|
});
|
|
|
|
// Confirmation avant suppression (si implémenté plus tard)
|
|
$(document).on('click', '.delete-capacite', function(e) {
|
|
if (!confirm('Êtes-vous sûr de vouloir supprimer cette capacité de traduction ?')) {
|
|
e.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
// Recherche rapide (optionnel - peut être ajouté plus tard)
|
|
if ($('#capacite-search').length) {
|
|
$('#capacite-search').on('keyup', function() {
|
|
const searchTerm = $(this).val().toLowerCase();
|
|
|
|
$('.capacite-card').each(function() {
|
|
const $card = $(this);
|
|
const title = $card.find('.card-title h2').text().toLowerCase();
|
|
const langue = $card.find('.info-value').first().text().toLowerCase();
|
|
|
|
if (title.includes(searchTerm) || langue.includes(searchTerm)) {
|
|
$card.show();
|
|
} else {
|
|
$card.hide();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// Tooltip pour les badges
|
|
$('.badge').each(function() {
|
|
const $badge = $(this);
|
|
if ($badge.attr('title')) {
|
|
$badge.css('cursor', 'help');
|
|
}
|
|
});
|
|
|
|
// Auto-refresh des statistiques (optionnel - peut être ajouté plus tard)
|
|
// Permet de rafraîchir les données d'utilisation sans recharger la page
|
|
function refreshUsageStats() {
|
|
// À implémenter si nécessaire avec un appel AJAX
|
|
// vers un endpoint REST qui retourne les stats actualisées
|
|
}
|
|
|
|
// Initialisation des tooltips WordPress (si disponible)
|
|
if (typeof jQuery.fn.tooltip !== 'undefined') {
|
|
$('.badge[title]').tooltip({
|
|
position: {
|
|
my: 'center bottom-5',
|
|
at: 'center top'
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
})(jQuery);
|