Bug 27882: Move external search results links out of page heading

This patch modifies the JavaScript which adds search result information
to the OPAC search results page which is returned from OverDrive,
Recorded Books, or Open Library. The information now displays below the
page heading instead of inside it.

To test you must have OpenLibrarySearch enabled, OverDrive-related
preferences populated (OverDriveClientKey, OverDriveClientSecret,
OverDriveLibraryID), or RecordedBooks preferences (RecordedBooksClientSecret,
RecordedBooksDomain, RecordedBooksLibraryID).

This patch was written with OverDrive and Open Library results active.

- Apply the patch and perform a search in the OPAC catalog.
- On the search results page you should see results for your external
  services appear below the page heading ("You search returned..."),
  e.g.

  "Found 20257 results in the library's OpenLibrary collection"
  "Found 337 results in the library's OverDrive collection"

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2021-03-05 15:19:40 +00:00 committed by Jonathan Druart
parent d8bafe7eae
commit a34bdcb59f
1 changed files with 3 additions and 6 deletions

View File

@ -921,8 +921,7 @@
[% END # /IF OpacHighlightedWords %]
[% IF ( OverDriveEnabled ) %]
var $overdrive_results = $( '<div id="overdrive-results">' + MSG_SEARCHING.format('OverDrive') + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></div>' );
$( '#numresults' ) .append( ' ' )
.append( $overdrive_results );
$( '#numresults' ) .after( $overdrive_results );
//Clean querystring, first we remove CCL entities, then decode HTML entities, then swap double quotes for single quotes
//as the overdrive API treats double quotes as a search term and returns extra results
od_querystring = querystring.replace(/(?:^|\W)([\w-]+)(,[\w-]+)*([:=])/g,' ');
@ -943,8 +942,7 @@
[% END # /IF OverDriveEnabled %]
[% IF ( RecordedBooksEnabled ) %]
var $recordedbooks_results = $( '<div id="recordedbooks-results">' + MSG_SEARCHING.format('RecordedBooks') + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></div>' );
$( '#numresults' ) .append( ' ' )
.append( $recordedbooks_results );
$( '#numresults' ) .after( $recordedbooks_results );
KOHA.RecordedBooks.search( querystring, [% OPACnumSearchResults || "null" | html %], null, function( data ) {
if ( data.error ) {
$recordedbooks_results.html( MSG_ERROR_SEARCHING_COLLECTION.format('RecordedBooks') + ': ' + data.error);
@ -961,8 +959,7 @@
[% END # /IF RecordedBooksEnabled %]
[% IF ( OpenLibrarySearch ) %]
var $openlibrary_results = $( '<div id="openlibrary-results">' + MSG_SEARCHING.format('OpenLibrary' ) + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></div>' );
$( '#numresults' ) .append( ' ' )
.append( $openlibrary_results );
$( '#numresults' ) .after( $openlibrary_results );
KOHA.OpenLibrary.search( querystring, null, function( data ) {
if ( data.error ) {
$openlibrary_results.html( MSG_ERROR_SEARCHING_COLLECTION.format('OpenLibrary') );