From d734608298bab87b9e1a4130d3bb00bae3abb845 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 17 Jan 2013 16:52:18 +0100 Subject: [PATCH] Bug 9419: The highlight feature can cause a browser freeze Test plan: - switch on the OpacHighlightedWords syspref - search at the opac and intranet a string with a space (e.g. au,wrdl:"Shakespeare, William" note the double space after the comma) - without the patch your browser will be frozen during a few seconds, after applying it, the highlight works better. Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Signed-off-by: Jared Camins-Esakov Signed-off-by: Chris Cormack --- .../intranet-tmpl/prog/en/modules/catalogue/results.tt | 4 +++- koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 4d89a53d3b..56dcfd06ac 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -115,7 +115,9 @@ $(".addtocart").show(); function highlightOn() { var x; for (x in q_array) { - toHighlight.highlight(q_array[x]); + if ( q_array[x].length > 0 ) { + toHighlight.highlight(q_array[x]); + } } $(".highlight_toggle").toggle(); }[% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt index bd7d04db01..f193dc0367 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -95,9 +95,11 @@ function highlightOff() { function highlightOn() { var x; for (x in q_array) { - $(".title").highlight(q_array[x]); - $(".author").highlight(q_array[x]); - $(".results_summary").highlight(q_array[x]); + if ( q_array[x].length > 0 ) { + $(".title").highlight(q_array[x]); + $(".author").highlight(q_array[x]); + $(".results_summary").highlight(q_array[x]); + } } $(".highlight_toggle").toggle(); } -- 2.39.5