From 0f97dc638755e27f260c9c724f34ec77a5369b35 Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Tue, 26 Oct 2021 17:38:01 +0200 Subject: [PATCH] Petite amelioration pour ne rechercher que sur la partie du document rechargee apres un ajaxLoad --- ecrire/inc/surligne.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ecrire/inc/surligne.php b/ecrire/inc/surligne.php index 44e9a9fffd..c900f17d69 100644 --- a/ecrire/inc/surligne.php +++ b/ecrire/inc/surligne.php @@ -73,11 +73,9 @@ function surligner_mots($page, $surcharge_surligne = '') { include_spip('inc/filtres'); $script = " <script type='text/javascript' src='" . url_absolue(find_in_path('javascript/SearchHighlight.js')) . "'></script> - <script type='text/javascript'>/*<![CDATA[*/ - if (window.jQuery) { + <script type='text/javascript'> var highlighter = function() { - jQuery(function($){ - \$(document).SearchHighlight({ + jQuery(this).SearchHighlight({ tag_name:'" . (html5_permis() ? 'mark' : 'span') . "', style_name:'spip_surligne', exact:'whole', @@ -87,14 +85,14 @@ function surligner_mots($page, $surcharge_surligne = '') { nohighlight:'.pas_surlignable'" . ($surcharge_surligne ? ", keys:'$surcharge_surligne'" : '') . ', - min_length: 3 + min_length: 3 }); - }); } - highlighter(); - onAjaxLoad(highlighter); - }(jQuery); - /*]]>*/</script> + if (window.jQuery) { + jQuery(function(){highlighter.apply(document, [])}); + onAjaxLoad(function(){highlighter.apply(this, [])}); + }; + </script> '; // on l'insere juste avant </head>, sinon tout en bas if (is_null($l = strpos($page, '</head>'))) { -- GitLab