From 12d84701a029f0ef922223f47077eb07bad6d02a Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 10 Jan 2022 22:47:11 +0000 Subject: [PATCH] Bug 29845: add IDs to overdrive results action buttons To test: 1. You must have OverDrive credentials populated in the OverDrive system preferences 2. Go to the Overdrive results page and make sure you are logged in. 3. Use your browsers dev tools to look at the check-in, check-out, place hold, cancel hold, and download as buttons, none of them contain ID's. 4. Apply patch 5. Repeat 3 again but this time they should all contain an ID which makes them much easier to style. Signed-off-by: Owen Leonard --- koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js b/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js index f71fd13fae..0e2cd1a507 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js @@ -320,7 +320,7 @@ KOHA.OverDriveCirculation = new function() { if (lockable_formats.length > 0 && checkout_popup) { $(el).append( ajax_button( __("Download as:"), function() { checkout_format(el, id, lockable_formats, copies_available); - }) ).append(" "); + }, "downloadas") ).append(" "); } } @@ -330,7 +330,7 @@ KOHA.OverDriveCirculation = new function() { if( confirm( __("Are you sure you want to return this item?") ) ) { item_action({action: "return", id: id}, el, copies_available + 1); } - }) ); + }, "checkin") ); return item; } @@ -371,12 +371,12 @@ KOHA.OverDriveCirculation = new function() { } }); } - }) ); + }, "checkout") ); } else if (!item) { $(el).append( ajax_button( __("Place hold"), function() { item_action({action: "place-hold", id: id}, el, copies_available); - }) ); + }, "placehold") ); } if (item) { @@ -384,27 +384,28 @@ KOHA.OverDriveCirculation = new function() { if( confirm( __("Are you sure you want to cancel this hold?") ) ) { item_action({action: "remove-hold", id: id}, el, copies_available); } - }) ); + }, "cancelhold") ); } return item; } } - function ajax_button(label, on_click) { + function ajax_button(label, on_click, uniqueName) { var button = $('') .click(function(e) { e.preventDefault(); on_click(); }); - decorate_button(button, label); + decorate_button(button, label, uniqueName); return button; } - function decorate_button(button, label) { + function decorate_button(button, label, uniqueName) { $(button) .addClass("btn btn-primary btn-sm") .css("color","white") - .text(label); + .text(label) + .addClass(uniqueName); } function checkout_format(el, id, formats, copies_available) { -- 2.20.1