|
@@ -306,4 +306,39 @@ jQuery(document).ready(function($){
|
|
|
// }
|
|
|
// };
|
|
|
// })(jQuery, Drupal);
|
|
|
-// //////////////////// end div infos site ////////////////////////
|
|
|
+// //////////////////// end div infos site ////////////////////////
|
|
|
+
|
|
|
+
|
|
|
+// document.querySelectorAll('.description').forEach(el => {
|
|
|
+// el.setAttribute('data-text', el.textContent.trim());
|
|
|
+// });
|
|
|
+
|
|
|
+function initDescriptionTooltips(root = document) {
|
|
|
+ root.querySelectorAll('.description').forEach(el => {
|
|
|
+ if (!el.hasAttribute('data-text')) {
|
|
|
+ el.setAttribute('data-text', el.textContent.trim());
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// Initialisation sur la page actuelle
|
|
|
+initDescriptionTooltips();
|
|
|
+
|
|
|
+// Observer pour détecter les nouveaux éléments ajoutés au DOM
|
|
|
+const observer = new MutationObserver(mutations => {
|
|
|
+ mutations.forEach(mutation => {
|
|
|
+ mutation.addedNodes.forEach(node => {
|
|
|
+ if (node.nodeType === 1) { // élément HTML
|
|
|
+ if (node.matches('.description')) {
|
|
|
+ initDescriptionTooltips(node.parentNode);
|
|
|
+ } else {
|
|
|
+ // Si c'est un conteneur qui contient des .description
|
|
|
+ initDescriptionTooltips(node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+// Observer sur tout le body
|
|
|
+observer.observe(document.body, { childList: true, subtree: true });
|