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 %] 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 e28327a98d..db725b5814 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() {