|
Lines 1-3
Link Here
|
|
|
1 |
/* global MSG_OVERDRIVE_LOGIN MSG_OVERDRIVE_LINK MSG_OVERDRIVE_LOGOUT MSG_OVERDRIVE_CHECKEDOUT_UNTIL MSG_DOWNLOAD MSG_OVERDRIVE_ACCESS_ONLINE MSG_OVERDRIVE_DOWNLOAD_AS MSG_CHECK_IN MSG_CHECK_OUT MSG_CHECKOUTS MSG_HOLDS MSG_ON_HOLD MSG_PLACE_HOLD MSG_CANCEL_HOLD MSG_OVERDRIVE_CANNOT_CHECKOUT MSG_CANCEL_HOLD_CONFIRM MSG_CHECK_IN_CONFIRM MSG_CHECK_OUT_CONFIRM OD_password_required */ |
| 2 |
|
| 1 |
if ( typeof KOHA == "undefined" || !KOHA ) { |
3 |
if ( typeof KOHA == "undefined" || !KOHA ) { |
| 2 |
var KOHA = {}; |
4 |
var KOHA = {}; |
| 3 |
} |
5 |
} |
|
Lines 74-80
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 74 |
if( OD_password_required ) { $("#overdrive-login").modal('show'); } |
76 |
if( OD_password_required ) { $("#overdrive-login").modal('show'); } |
| 75 |
else { login(""); } |
77 |
else { login(""); } |
| 76 |
}) |
78 |
}) |
| 77 |
.text(_("Login to OverDrive account")); |
79 |
.text( MSG_OVERDRIVE_LOGIN ); |
| 78 |
|
80 |
|
| 79 |
var login_div = $('<div class="overdrive-login">').append(login_link); |
81 |
var login_div = $('<div class="overdrive-login">').append(login_link); |
| 80 |
|
82 |
|
|
Lines 97-102
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 97 |
|
99 |
|
| 98 |
$( document ).ready(function() { |
100 |
$( document ).ready(function() { |
| 99 |
var p = window.opener; |
101 |
var p = window.opener; |
|
|
102 |
var cb; |
| 100 |
if (p) { |
103 |
if (p) { |
| 101 |
try { cb = p.refresh_overdrive_account_details;} |
104 |
try { cb = p.refresh_overdrive_account_details;} |
| 102 |
catch(err){ return; } //Catch error if opener is not accessible |
105 |
catch(err){ return; } //Catch error if opener is not accessible |
|
Lines 116-122
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 116 |
} |
119 |
} |
| 117 |
|
120 |
|
| 118 |
var overdrive_link = $('<a href="https://www.overdrive.com/account/" target="overdrive-account" class="overdrive-link" style="float:right">') |
121 |
var overdrive_link = $('<a href="https://www.overdrive.com/account/" target="overdrive-account" class="overdrive-link" style="float:right">') |
| 119 |
.text("OverDrive Account Page"); |
122 |
.text( MSG_OVERDRIVE_LINK ); |
| 120 |
$(container).append(overdrive_link); |
123 |
$(container).append(overdrive_link); |
| 121 |
|
124 |
|
| 122 |
var logout_link = $('<a href="#logout" class="overdrive-logout" style="float:left">') |
125 |
var logout_link = $('<a href="#logout" class="overdrive-logout" style="float:left">') |
|
Lines 126-137
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 126 |
logout(function(data) { |
129 |
logout(function(data) { |
| 127 |
display_account(container, data); |
130 |
display_account(container, data); |
| 128 |
}); |
131 |
}); |
| 129 |
}).text(_("Logout from OverDrive account")); |
132 |
}).text( MSG_OVERDRIVE_LOGOUT ); |
| 130 |
$(container).append(logout_link); |
133 |
$(container).append(logout_link); |
| 131 |
$(container).append('<br style="clear:both;"/>'); |
134 |
$(container).append('<br style="clear:both;"/>'); |
| 132 |
|
135 |
|
| 133 |
if (data.checkouts) { |
136 |
if (data.checkouts) { |
| 134 |
var checkouts_div = $('<div class="overdrive-div">').html('<h3>' + _("Checkouts") + '</h3>'); |
137 |
var checkouts_div = $('<div class="overdrive-div">').html('<h3>' + MSG_CHECKOUTS + '</h3>'); |
| 135 |
var checkouts_list = $('<ul class="overdrive-list">'); |
138 |
var checkouts_list = $('<ul class="overdrive-list">'); |
| 136 |
data.checkouts.items.forEach(function(item) { |
139 |
data.checkouts.items.forEach(function(item) { |
| 137 |
item_line(checkouts_list, item); |
140 |
item_line(checkouts_list, item); |
|
Lines 141-147
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 141 |
} |
144 |
} |
| 142 |
|
145 |
|
| 143 |
if (data.holds) { |
146 |
if (data.holds) { |
| 144 |
var holds_div = $('<div class="overdrive-div">').html('<h3>' + _("Holds") + '</h3>'); |
147 |
var holds_div = $('<div class="overdrive-div">').html('<h3>' + MSG_HOLDS + '</h3>'); |
| 145 |
var holds_list = $('<ul class="overdrive-list">'); |
148 |
var holds_list = $('<ul class="overdrive-list">'); |
| 146 |
data.holds.items.forEach(function(item) { |
149 |
data.holds.items.forEach(function(item) { |
| 147 |
item_line(holds_list, item); |
150 |
item_line(holds_list, item); |
|
Lines 212-218
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 212 |
if( $("#overdrive-results-page").length > 0 ){ |
215 |
if( $("#overdrive-results-page").length > 0 ){ |
| 213 |
location.reload(); |
216 |
location.reload(); |
| 214 |
} else { |
217 |
} else { |
| 215 |
KOHA.OverDriveCirculation.display_account_details( $("#opac-user-overdrive") ); |
218 |
KOHA.OverDriveCirculation.display_account_details( $("#opac-user-overdrive") ); |
| 216 |
} |
219 |
} |
| 217 |
} |
220 |
} |
| 218 |
}); |
221 |
}); |
|
Lines 274-286
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 274 |
if (item) { |
277 |
if (item) { |
| 275 |
var expires = new Date(item.expires); |
278 |
var expires = new Date(item.expires); |
| 276 |
$('<span class="overdrive-item-status">') |
279 |
$('<span class="overdrive-item-status">') |
| 277 |
.text(_("Checked out until") + " " + expires.toLocaleString()) |
280 |
.text( MSG_OVERDRIVE_CHECKEDOUT_UNTIL + " " + expires.toLocaleString()) |
| 278 |
.appendTo(el); |
281 |
.appendTo(el); |
| 279 |
$(el).append(" "); |
282 |
$(el).append(" "); |
| 280 |
|
283 |
|
| 281 |
if (item.format) { |
284 |
if (item.format) { |
| 282 |
var download = $('<a href="#">').appendTo(el); |
285 |
var download = $('<a href="#">').appendTo(el); |
| 283 |
decorate_button(download, _("Download") + " " + item.format); |
286 |
decorate_button(download, MSG_DOWNLOAD + " " + item.format); |
| 284 |
svc_ajax('get', {action: "download-url", id: id, format: item.format}, function(data) { |
287 |
svc_ajax('get', {action: "download-url", id: id, format: item.format}, function(data) { |
| 285 |
download.attr("href", data.action); |
288 |
download.attr("href", data.action); |
| 286 |
}); |
289 |
}); |
|
Lines 294-300
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 294 |
|
297 |
|
| 295 |
if (item.formats[f]) { |
298 |
if (item.formats[f]) { |
| 296 |
var access = $('<a target="_blank">').appendTo(el); |
299 |
var access = $('<a target="_blank">').appendTo(el); |
| 297 |
decorate_button(access, _("Access online") + " " + f); |
300 |
decorate_button(access, MSG_OVERDRIVE_ACCESS_ONLINE + " " + f); |
| 298 |
svc_ajax('get', {action: "download-url", id: id, format: f}, function(data) { |
301 |
svc_ajax('get', {action: "download-url", id: id, format: f}, function(data) { |
| 299 |
access.attr("href", data.action); |
302 |
access.attr("href", data.action); |
| 300 |
}); |
303 |
}); |
|
Lines 305-311
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 305 |
} |
308 |
} |
| 306 |
} |
309 |
} |
| 307 |
if (lockable_formats.length > 0 && checkout_popup) { |
310 |
if (lockable_formats.length > 0 && checkout_popup) { |
| 308 |
$(el).append( ajax_button(_("Download as"), function() { |
311 |
$(el).append( ajax_button( MSG_OVERDRIVE_DOWNLOAD_AS, function() { |
| 309 |
checkout_format(el, id, lockable_formats, copies_available); |
312 |
checkout_format(el, id, lockable_formats, copies_available); |
| 310 |
}) ).append(" "); |
313 |
}) ).append(" "); |
| 311 |
} |
314 |
} |
|
Lines 313-320
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 313 |
|
316 |
|
| 314 |
if (item.format) return item; |
317 |
if (item.format) return item; |
| 315 |
|
318 |
|
| 316 |
$(el).append( ajax_button(_("Check in"), function() { |
319 |
$(el).append( ajax_button( MSG_CHECK_IN, function() { |
| 317 |
if( confirm(_("Are you sure you want to return this item?")) ) { |
320 |
if( confirm( MSG_CHECK_IN_CONFIRM ) ) { |
| 318 |
item_action({action: "return", id: id}, el, copies_available + 1); |
321 |
item_action({action: "return", id: id}, el, copies_available + 1); |
| 319 |
} |
322 |
} |
| 320 |
}) ); |
323 |
}) ); |
|
Lines 325-338
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 325 |
item = item_is_on_hold(id); |
328 |
item = item_is_on_hold(id); |
| 326 |
if (item) { |
329 |
if (item) { |
| 327 |
$('<span class="overdrive-status">') |
330 |
$('<span class="overdrive-status">') |
| 328 |
.text(_("On hold")) |
331 |
.text( MSG_ON_HOLD ) |
| 329 |
.appendTo(el); |
332 |
.appendTo(el); |
| 330 |
$(el).append(" "); |
333 |
$(el).append(" "); |
| 331 |
} |
334 |
} |
| 332 |
|
335 |
|
| 333 |
if(copies_available && checkout_popup) { |
336 |
if(copies_available && checkout_popup) { |
| 334 |
$(el).append( ajax_button(_("Check out"), function() { |
337 |
$(el).append( ajax_button( MSG_CHECK_OUT , function() { |
| 335 |
if( confirm(_("Are you sure you want to checkout this item?")) ) { |
338 |
if( confirm( MSG_CHECK_OUT_CONFIRM ) ) { |
| 336 |
svc_ajax('post', {action: "checkout", id: id}, function(data) { |
339 |
svc_ajax('post', {action: "checkout", id: id}, function(data) { |
| 337 |
if (data.checkouts) { |
340 |
if (data.checkouts) { |
| 338 |
details.checkouts = data.checkouts; |
341 |
details.checkouts = data.checkouts; |
|
Lines 361-374
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 361 |
}) ); |
364 |
}) ); |
| 362 |
} |
365 |
} |
| 363 |
else if (!item) { |
366 |
else if (!item) { |
| 364 |
$(el).append( ajax_button(_("Place hold"), function() { |
367 |
$(el).append( ajax_button( MSG_PLACE_HOLD, function() { |
| 365 |
item_action({action: "place-hold", id: id}, el, copies_available); |
368 |
item_action({action: "place-hold", id: id}, el, copies_available); |
| 366 |
}) ); |
369 |
}) ); |
| 367 |
} |
370 |
} |
| 368 |
|
371 |
|
| 369 |
if (item) { |
372 |
if (item) { |
| 370 |
$(el).append( ajax_button(_("Cancel"), function() { |
373 |
$(el).append( ajax_button( MSG_CANCEL_HOLD, function() { |
| 371 |
if( confirm(_("Are you sure you want to cancel this hold?")) ) { |
374 |
if( confirm( MSG_CANCEL_HOLD_CONFIRM ) ) { |
| 372 |
item_action({action: "remove-hold", id: id}, el, copies_available); |
375 |
item_action({action: "remove-hold", id: id}, el, copies_available); |
| 373 |
} |
376 |
} |
| 374 |
}) ); |
377 |
}) ); |
|
Lines 396-402
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 396 |
|
399 |
|
| 397 |
function checkout_format(el, id, formats, copies_available) { |
400 |
function checkout_format(el, id, formats, copies_available) { |
| 398 |
if (formats.length == 0) { |
401 |
if (formats.length == 0) { |
| 399 |
alert(_("Item cannot be checked out - no available formats")); |
402 |
alert( MSG_OVERDRIVE_CANNOT_CHECKOUT ); |
| 400 |
return false; |
403 |
return false; |
| 401 |
} |
404 |
} |
| 402 |
|
405 |
|
|
Lines 426-437
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 426 |
} |
429 |
} |
| 427 |
callback(data); |
430 |
callback(data); |
| 428 |
}); |
431 |
}); |
| 429 |
} |
432 |
}; |
| 430 |
|
433 |
|
| 431 |
this.display_account_details = function( el ) { |
434 |
this.display_account_details = function( el ) { |
| 432 |
window.refresh_overdrive_account_details = function () { |
435 |
window.refresh_overdrive_account_details = function () { |
| 433 |
KOHA.OverDriveCirculation.display_account_details( el ); |
436 |
KOHA.OverDriveCirculation.display_account_details( el ); |
| 434 |
} |
437 |
}; |
| 435 |
$(el).empty().append(error_div); |
438 |
$(el).empty().append(error_div); |
| 436 |
load_account_details(function(data) { |
439 |
load_account_details(function(data) { |
| 437 |
display_account(el, data); |
440 |
display_account(el, data); |
|
Lines 452-455
KOHA.OverDriveCirculation = new function() {
Link Here
|
| 452 |
.append(actions) |
455 |
.append(actions) |
| 453 |
.appendTo(el); |
456 |
.appendTo(el); |
| 454 |
}; |
457 |
}; |
| 455 |
} |
458 |
}; |
| 456 |
- |
|
|