ajustement js longueru texte actus
This commit is contained in:
parent
a954720f71
commit
ca93906dbd
File diff suppressed because one or more lines are too long
@ -358,17 +358,33 @@
|
|||||||
/////////////////// caracteres body actus/////////////////////////
|
/////////////////// caracteres body actus/////////////////////////
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Maximum number of characters to display
|
// Nombre maximum de caractères à afficher
|
||||||
const maxChars = 140; // Adjust this value as needed
|
const maxChars = 140; // Ajustez cette valeur selon vos besoins
|
||||||
|
|
||||||
document.querySelectorAll('#actus-caroussel .node-type-actualite .field_body p').forEach(function(paragraph) {
|
document.querySelectorAll('#actus-caroussel .node-type-actualite').forEach(function(node) {
|
||||||
let text = paragraph.textContent.trim();
|
let paragraphs = node.querySelectorAll('.field_body p');
|
||||||
if (text.length > maxChars) {
|
let fullText = "";
|
||||||
let truncatedText = text.slice(0, maxChars) + '...';
|
|
||||||
paragraph.textContent = truncatedText;
|
// Concaténer tous les paragraphes
|
||||||
}
|
paragraphs.forEach(p => fullText += p.textContent.trim() + " ");
|
||||||
|
fullText = fullText.trim();
|
||||||
|
|
||||||
|
// Vérifier si le texte dépasse la limite
|
||||||
|
if (fullText.length > maxChars) {
|
||||||
|
let truncatedText = fullText.slice(0, maxChars) + '...';
|
||||||
|
|
||||||
|
// Vider tout le contenu et insérer seulement le texte tronqué
|
||||||
|
let firstParagraph = paragraphs[0];
|
||||||
|
firstParagraph.textContent = truncatedText;
|
||||||
|
|
||||||
|
// Masquer les autres paragraphes
|
||||||
|
for (let i = 1; i < paragraphs.length; i++) {
|
||||||
|
paragraphs[i].style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////// start slideshow home //////////////////////////
|
//////////// start slideshow home //////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user