Bugzilla – Attachment 23039 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: Refactor hit highliginting code
Bug-11270-Refactor-hit-highliginting-code.patch (text/plain), 9.35 KB, created by
Martin Renvoize (ashimema)
on 2013-11-19 16:20:55 UTC
(
hide
)
Description:
Bug 11270: Refactor hit highliginting code
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2013-11-19 16:20:55 UTC
Size:
9.35 KB
patch
obsolete
>From 4efae8d6f11e4716e04899c3a6d5c65a38b26ae6 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 19 Nov 2013 13:08:32 +0000 >Subject: [PATCH] Bug 11270: Refactor hit highliginting code > >This patch tries to factor out some of the hit highlighting code >to aid in future maintainability. It should not affect current >operation. >--- > .../bootstrap/en/includes/opac-highlight.inc | 27 ++++++++++++++++++++ > .../bootstrap/en/modules/opac-results-grouped.tt | 17 ------------ > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 26 ++----------------- > .../opac-tmpl/prog/en/includes/opac-highlight.inc | 27 ++++++++++++++++++++ > .../prog/en/modules/opac-results-grouped.tt | 17 ------------ > .../opac-tmpl/prog/en/modules/opac-results.tt | 25 ++---------------- > 6 files changed, 58 insertions(+), 81 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..9eccfc8 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-highlight.inc >@@ -0,0 +1,27 @@ >+<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 e61c879..ac8e5a4 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,23 +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"); >- 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) ) { >- $("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 a870be7..9aeece9 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -551,8 +551,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() { >@@ -637,28 +637,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('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(); >-} >-[% END %] > $(document).ready(function(){ > [% IF ( OpacHighlightedWords ) %] > $('a.title').each(function() { >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-highlight.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-highlight.inc >new file mode 100644 >index 0000000..f48f296 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-highlight.inc >@@ -0,0 +1,27 @@ >+<script type="text/javascript" src="[% themelang %]/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/prog/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >index 8ceec20..29c7af2 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,23 +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"); >- 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) ) { >- $("td").highlight(q_array[x]); >- } >- } >- $(".highlight_toggle").toggle(); >-} > //]]> > </script> > </head> >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 fbe7bbe..22cf75f 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 @@ > > <script type="text/javascript" src="[% themelang %]/js/overdrive.js"></script> > <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >-[% IF ( OpacHighlightedWords ) %]<script type="text/javascript" src="[% themelang %]/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 ( opacuserlogin ) %][% IF ( RequestOnOpac ) %] > function holdMultiple() { >@@ -89,28 +89,7 @@ function tagAdded() { > KOHA.Tags.add_multitags_button(bibs, tag); > return false; > }[% END %] >-[% 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('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(); >-} >-[% END %] > $(document).ready(function(){ > [% IF ( OpacHighlightedWords ) %] > $('a.title').each(function() { >-- >1.7.10.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