From b6b9ae0c54f22ce75ca8d07ddfa47a5920038566 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Wed, 6 May 2015 23:19:43 -0400 Subject: [PATCH] Bug 11270: Search Result highlighting should be refactored (3.16.x) Whilst working on Bug 6149 I found there to be many repeats of code in different file relating to the search highlighting. This patch tries to factor out some of the code into include's to enhance maintainability. This is just the bootstrap portions. Untested. This should apply. However, Martin Renvoize has yet to post a test plan. --- .../bootstrap/en/includes/opac-highlight.inc | 26 ++++++++++++++++++++++ .../bootstrap/en/modules/opac-results-grouped.tt | 13 ----------- .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 24 ++------------------ .../opac-tmpl/prog/en/includes/opac-highlight.inc | 26 ++++++++++++++++++++++ .../prog/en/modules/opac-results-grouped.tt | 13 ----------- .../opac-tmpl/prog/en/modules/opac-results.tt | 24 ++------------------ 6 files changed, 56 insertions(+), 70 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-highlight.inc create mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/opac-highlight.inc diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-highlight.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-highlight.inc new file mode 100644 index 0000000..f604bf5 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-highlight.inc @@ -0,0 +1,26 @@ + + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt index c0b37f2..016b6ad 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt @@ -341,19 +341,6 @@ $(document).ready(function(){ $("#highlight_toggle_off").show().click(function() {highlightOff();}); [% END %] }); - -function highlightOff() { - $("td").removeHighlight(); - $(".highlight_toggle").toggle(); -} -function highlightOn() { - var x; - for (x in q_array) { - q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1"); - $("td").highlight(q_array[x]); - } - $(".highlight_toggle").toggle(); -} //]]> [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 6e873a6..bd7d336 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -555,8 +555,8 @@ [% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% END %] [% IF ( OverDriveEnabled ) %][% END %] -[% IF ( OpacHighlightedWords ) %] -[% END %] + diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt index 14faf58..572fa20 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt @@ -75,19 +75,6 @@ $(document).ready(function(){ $("#highlight_toggle_off").show().click(function() {highlightOff();}); [% END %] }); - -function highlightOff() { - $("td").removeHighlight(); - $(".highlight_toggle").toggle(); -} -function highlightOn() { - var x; - for (x in q_array) { - q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1"); - $("td").highlight(q_array[x]); - } - $(".highlight_toggle").toggle(); -} //]]> 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 8ba8ff3..a179a00 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -18,8 +18,8 @@ -[% IF ( OpacHighlightedWords ) %] -[% END %]