Bugzilla – Attachment 38939 Details for
Bug 11270
Search Result highlighting should be refactored
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11270: Search Result highlighting should be refactored (master)
Bug-11270-Search-Result-highlighting-should-be-ref.patch (text/plain), 5.26 KB, created by
Mark Tompsett
on 2015-05-07 03:22:20 UTC
(
hide
)
Description:
Bug 11270: Search Result highlighting should be refactored (master)
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-05-07 03:22:20 UTC
Size:
5.26 KB
patch
obsolete
>From fc14fa59be0a918ffd0a205bb44117a1f8902062 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 6 May 2015 23:19:43 -0400 >Subject: [PATCH] Bug 11270: Search Result highlighting should be refactored > (master) > >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 | 17 -------------- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 26 ++-------------------- > 3 files changed, 28 insertions(+), 41 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/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..9d24a2d >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-highlight.inc >@@ -0,0 +1,26 @@ >+<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.highlight-3.js"></script> >+<script type="text/javascript"> >+var q_array = new Array(); // holds search terms if available >+ >+//HighlightOff >+function highlightOff() { >+ $("td").removeHighlight(); >+ $(".highlight_toggle").toggle(); >+} >+ >+//HighlightOn >+function highlightOn() { >+ var x; >+ for (x in q_array) { >+ q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1"); >+ q_array[x] = q_array[x].toLowerCase(); >+ var myStopwords = "[% Koha.Preference('HighlightedStopWords') %]".toLowerCase().split('|'); >+ if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) { >+ $(".title").highlight(q_array[x]); >+ $(".author").highlight(q_array[x]); >+ $(".results_summary").highlight(q_array[x]); >+ } >+ } >+ $(".highlight_toggle").toggle(); >+} >+</script> >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 05d022a..2220c3c 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 >@@ -335,23 +335,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"); >- q_array[x] = q_array[x].toLowerCase(); >- var myStopwords = "[% Koha.Preference('NotHighlightedWords') %]".toLowerCase().split('|'); >- if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) { >- $("td").highlight(q_array[x]); >- } >- } >- $(".highlight_toggle").toggle(); >-} > //]]> > </script> > [% 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 27c5a10..5fa03b8 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -583,8 +583,8 @@ > [% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %]<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.rating.js"></script>[% END %] > [% IF ( OverDriveEnabled ) %]<script type="text/javascript" src="[% interface %]/[% theme %]/js/overdrive.js"></script>[% END %] > <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >-[% IF ( OpacHighlightedWords ) %]<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.highlight-3.js"></script> >-[% END %]<script type="text/javascript"> >+[% IF ( OpacHighlightedWords ) %][% INCLUDE 'opac-highlight.inc' %][% END %] >+<script type="text/javascript"> > //<![CDATA[ > [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'RequestOnOpac' ) == 1 ) %] > function holdMultiple() { >@@ -669,28 +669,6 @@ function enableCheckboxActions(){ > } > } > >-[% IF ( OpacHighlightedWords ) %] >-var q_array = new Array(); // holds search terms if available >- >-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"); >- q_array[x] = q_array[x].toLowerCase(); >- var myStopwords = "[% Koha.Preference('NotHighlightedWords') %]".toLowerCase().split('|'); >- if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) { >- $(".title").highlight(q_array[x]); >- $(".author").highlight(q_array[x]); >- $(".results_summary").highlight(q_array[x]); >- } >- } >- $(".highlight_toggle").toggle(); >-} >-[% END %] > $(document).ready(function(){ > [% IF ( OpacHighlightedWords ) %] > $('a.title').each(function() { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11270
:
23039
| 38939 |
38940
|
38941