ajustement js longueru texte actus
This commit is contained in:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -358,17 +358,33 @@
 | 
			
		||||
  ///////////////////  caracteres  body actus/////////////////////////
 | 
			
		||||
 | 
			
		||||
  document.addEventListener('DOMContentLoaded', function() {
 | 
			
		||||
    // Maximum number of characters to display
 | 
			
		||||
    const maxChars = 140; // Adjust this value as needed
 | 
			
		||||
  
 | 
			
		||||
    document.querySelectorAll('#actus-caroussel .node-type-actualite .field_body p').forEach(function(paragraph) {
 | 
			
		||||
      let text = paragraph.textContent.trim();
 | 
			
		||||
      if (text.length > maxChars) {
 | 
			
		||||
        let truncatedText = text.slice(0, maxChars) + '...';
 | 
			
		||||
        paragraph.textContent = truncatedText;
 | 
			
		||||
      }
 | 
			
		||||
    // Nombre maximum de caractères à afficher
 | 
			
		||||
    const maxChars = 140; // Ajustez cette valeur selon vos besoins
 | 
			
		||||
 | 
			
		||||
    document.querySelectorAll('#actus-caroussel .node-type-actualite').forEach(function(node) {
 | 
			
		||||
        let paragraphs = node.querySelectorAll('.field_body p');
 | 
			
		||||
        let fullText = "";
 | 
			
		||||
        
 | 
			
		||||
        // 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  ////////////////////////// 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user