From f44a9df42e1a7a634817f69e8ff28153c1f2a8ff Mon Sep 17 00:00:00 2001 From: Jaswinder Singh Date: Mon, 18 Jun 2018 23:43:34 -0400 Subject: [PATCH] LP#1772680: Fixed download issue Signed-off-by: Jaswinder Singh Signed-off-by: Galen Charlton --- .../lib/OpenILS/Application/EbookAPI/RBDigital.pm | 1 - .../web/js/ui/default/opac/ebook_api/rbdigital.js | 49 +++++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) 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(); + } }); } -- 2.11.0