LP#1772680: Fixed download issue
authorJaswinder Singh <Jaswinder.Singh0011@gmail.com>
Tue, 19 Jun 2018 03:43:34 +0000 (23:43 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Sat, 17 Nov 2018 13:37:01 +0000 (08:37 -0500)
Signed-off-by: Jaswinder Singh <jaswinder.singh0011@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm
Open-ILS/web/js/ui/default/opac/ebook_api/rbdigital.js

index ddfedc7..a3e582e 100755 (executable)
@@ -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);
index 7e828e1..337eeaa 100755 (executable)
@@ -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();
+        }
     });
 }