Bugzilla – Attachment 154146 Details for
Bug 29578
Search term highlighting breaks with titles containing characters with Greek diacritics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29578: Upgrade the jQuery highlighter plugin
Bug-29578-Upgrade-the-jQuery-highlighter-plugin.patch (text/plain), 7.99 KB, created by
Andreas Roussos
on 2023-08-02 01:32:10 UTC
(
hide
)
Description:
Bug 29578: Upgrade the jQuery highlighter plugin
Filename:
MIME Type:
Creator:
Andreas Roussos
Created:
2023-08-02 01:32:10 UTC
Size:
7.99 KB
patch
obsolete
>From 0f96040b04d2d6debb18761fde4fe9ec73681577 Mon Sep 17 00:00:00 2001 >From: Andreas Roussos <a.roussos@dataly.gr> >Date: Tue, 21 Feb 2023 20:02:19 +0100 >Subject: [PATCH] Bug 29578: Upgrade the jQuery highlighter plugin >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Under certain conditions, the jQuery term highlighter >can break and in the process make the "Highlight" / >"Unhighlight" button disappear altogether. This affects >catalog searches in both the OPAC and the Staff Client, >with UNIMARC-based instances affected the most as the >"Highlight" / "Unhighlight" button disappears if you >perform a specific OPAC search (see Test plan below). > >This patch fixes that by upgrading the highlighter >plugin to its latest version for both the OPAC and >the Staff interface. Then, the changes from commit >2e4b574074 (Bug 5844) are applied to the plugin code. >Also, Koha uses "term" instead of "highlight" as the >class name for the <span> highlighting elements, so >the plugin code is modified for that aspect, too. >Finally, the plugin file is renamed to reflect the >version change (v3 -> v5) and all references to the >old filename in the Template files are updated. > >Test plan: > >0) In a UNIMARC instance, catalogue two books using > the titles given below (Title subfield = 200$a): > > Book 1: ΣÏÎ»Î»Î¿Î³Î®Ï ÏÏν εν εÏιÏομή Ïοá¿Ï Ïάλαι γεÏγÏαÏηθÎνÏÏν > Book 2: ÎÏιÏομή ÏÎ·Ï Î¹ÏÏοÏÎ¯Î±Ï ÏÏν ÎαλκανικÏν ΠολÎμÏν (1912-1913) > >1) OpacHighlightedWords and StaffHighlightedWords > should both be set to "Highlight". > >2) Search the OPAC for "εÏιÏομή ÏÏν" (without the > quotes). In the results page, notice that: > > a) You get an Uncaught DOMException error in the > web browswer's JavaScript Console (press F12): > "Failed to execute 'splitText' on 'Text': The > offset 3 is larger than the Text node's length." > b) the "Highlight" / "Unhighlight" button vanishes > c) some search terms matches are not highlighted > (for example "ÏÏν" in the 2nd Book) > >3) Repeat the same search in the Staff interface. > In the results page, notice that: > > a) You get an Uncaught DOMException error in the > web browswer's JavaScript Console (press F12): > "Failed to execute 'splitText' on 'Text': The > offset 3 is larger than the Text node's length." > b) Even though some terms are highlighted, the > button still says "Highlight" > c) some search terms matches are not highlighted > (for example "ÏÏν" in the 2nd Book) > >4) Apply this patch. > >5) Repeat the searches (you may have to press CTRL-F5 > to reload the JavaScript code). This time the > "Highlight" / "Unhighlight" button is displayed > in the OPAC, and all your search terms should be > highlighted in yellow. Toggling the highlight > should cause no problems, and there shouldn't be > any errors logged in your browser's Console. >--- > .../{jquery.highlight-3.js => jquery.highlight-5.js} | 7 ++++--- > koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc | 2 +- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 2 +- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 2 +- > .../{jquery.highlight-3.js => jquery.highlight-5.js} | 7 ++++--- > 5 files changed, 11 insertions(+), 9 deletions(-) > rename koha-tmpl/intranet-tmpl/lib/jquery/plugins/{jquery.highlight-3.js => jquery.highlight-5.js} (86%) > rename koha-tmpl/opac-tmpl/lib/jquery/plugins/{jquery.highlight-3.js => jquery.highlight-5.js} (86%) > >diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.highlight-3.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.highlight-5.js >similarity index 86% >rename from koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.highlight-3.js >rename to koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.highlight-5.js >index 8eabca4bfd..578da60639 100644 >--- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.highlight-3.js >+++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.highlight-5.js >@@ -1,6 +1,6 @@ > /* > >-highlight v3 >+highlight v5 > > Highlights arbitrary terms. > >@@ -19,6 +19,7 @@ jQuery.fn.highlight = function(pat) { > var skip = 0; > if (node.nodeType == 3) { > var pos = node.data.toUpperCase().indexOf(pat); >+ pos -= (node.data.substr(0, pos).toUpperCase().length - node.data.substr(0, pos).length); > if (pos >= 0) { > var spannode = document.createElement('span'); > spannode.className = 'term'; >@@ -37,9 +38,9 @@ jQuery.fn.highlight = function(pat) { > } > return skip; > } >- return this.each(function() { >+ return this.length && pat && pat.length ? this.each(function() { > innerHighlight(this, pat.toUpperCase()); >- }); >+ }) : this; > }; > > jQuery.fn.removeHighlight = function() { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index bd41d755a6..b1d131b65d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -21,7 +21,7 @@ > [% Asset.js("lib/jquery/jquery-ui-1.13.1.min.js") | $raw %] > [% Asset.js("lib/shortcut/shortcut.js") | $raw %] > [% Asset.js("lib/js-cookie/js.cookie-2.2.1.min.js") | $raw %] >-[% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %] >+[% Asset.js("lib/jquery/plugins/jquery.highlight-5.js") | $raw %] > [% Asset.js("lib/bootstrap/bootstrap.min.js") | $raw %] > [% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %] > <!-- koha core js --> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index 8449cc3b86..08803545b2 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1441,7 +1441,7 @@ > > [% CoverImagePlugins | $raw %] > >- [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] >+ [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-5.js") | $raw %][% END %] > [% IF ( Koha.Preference('OPACDetailQRCode') ) %] > [% Asset.js("lib/kjua/kjua.min.js") | $raw %] > [% 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 875bf71e2b..4182f5ad45 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -584,7 +584,7 @@ > [% Asset.js("js/authtoresults.js") | $raw %] > [% Asset.js("lib/hc-sticky.js") | $raw %] > [% IF ( OpacHighlightedWords ) %] >- [% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %] >+ [% Asset.js("lib/jquery/plugins/jquery.highlight-5.js") | $raw %] > [% END %] > [% IF OpenLibraryCovers || OpenLibrarySearch %] > [% Asset.js("js/openlibrary.js") | $raw %] >diff --git a/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.highlight-3.js b/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.highlight-5.js >similarity index 86% >rename from koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.highlight-3.js >rename to koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.highlight-5.js >index 8eabca4bfd..578da60639 100644 >--- a/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.highlight-3.js >+++ b/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.highlight-5.js >@@ -1,6 +1,6 @@ > /* > >-highlight v3 >+highlight v5 > > Highlights arbitrary terms. > >@@ -19,6 +19,7 @@ jQuery.fn.highlight = function(pat) { > var skip = 0; > if (node.nodeType == 3) { > var pos = node.data.toUpperCase().indexOf(pat); >+ pos -= (node.data.substr(0, pos).toUpperCase().length - node.data.substr(0, pos).length); > if (pos >= 0) { > var spannode = document.createElement('span'); > spannode.className = 'term'; >@@ -37,9 +38,9 @@ jQuery.fn.highlight = function(pat) { > } > return skip; > } >- return this.each(function() { >+ return this.length && pat && pat.length ? this.each(function() { > innerHighlight(this, pat.toUpperCase()); >- }); >+ }) : this; > }; > > jQuery.fn.removeHighlight = function() { >-- >2.20.1
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 29578
:
128034
|
128035
|
128053
|
128055
|
128067
|
128068
|
128150
|
131153
|
147088
|
147089
|
147090
|
154146
|
154494
|
154807