From: Jaswinder Singh Date: Tue, 19 Jun 2018 03:43:34 +0000 (-0400) Subject: LP#1772680: Fixed download issue X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f14dc602698aaa317a04a968849bd663bc68e90d;p=evergreen%2Fpines.git LP#1772680: Fixed download issue Signed-off-by: Jaswinder Singh Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm index ddfedc7dc5..a3e582e5e0 100755 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm @@ -173,7 +173,6 @@ sub do_patron_auth { my ($self, $username, $email) = @_; my $patron_id = 0; - if ($email) { # first try to authenticate the user with a email $patron_id = $self->_get_patron_id($email); diff --git a/Open-ILS/web/js/ui/default/opac/ebook_api/rbdigital.js b/Open-ILS/web/js/ui/default/opac/ebook_api/rbdigital.js index 7e828e1183..337eeaa442 100755 --- a/Open-ILS/web/js/ui/default/opac/ebook_api/rbdigital.js +++ b/Open-ILS/web/js/ui/default/opac/ebook_api/rbdigital.js @@ -190,27 +190,44 @@ function setupEventHandlers() { ebook_rbdigital.cancelHold(authtoken, rbdigitalPatronId, cancelHoldCallback); }); + $(document).on('click','#ebook_circs_main_table_body a', function () { + var that = $(this); + var api_url = that.attr('href'); + + if (that.html() == "Download" && api_url.indexOf('api.rbdigital') > 0) { + showEbookSpinner(that); + downloadUrl(api_url); + } + return false; + }); + //Download File $(document).on('click', '.ebook_checkout_download_link', function () { var that = $(this); - var downloadUrl = that.attr('data-downloadurl'); + var api_url = that.attr('data-downloadurl'); showEbookSpinner(that); - //Change http protocol to https to avoid browser error on Mixed contents - if (downloadUrl.indexOf('https') == -1) { - downloadUrl = downloadUrl.replace("http", "https"); - } + downloadUrl(api_url); - //Make an ajax call to get a download link - $.ajax({ - type: 'GET', - url: downloadUrl, - success: function(result){ - console.log('success'); - console.log(result.url); - window.open(result.url, '_self'); - hideEbookSpinner(); - } - }); + return false; + }); +} + +function downloadUrl(api_url) { + //Change http protocol to https to avoid browser error on Mixed contents + if (api_url.indexOf('https') == -1) { + api_url = api_url.replace("http", "https"); + } + + //Make an ajax call to get a download link + $.ajax({ + type: 'GET', + url: api_url, + success: function(result){ + console.log('success'); + console.log(result.url); + window.open(result.url, '_self'); + hideEbookSpinner(); + } }); }