Lines 1-4
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 */ |
1 |
/* global OD_password_required __ */ |
2 |
|
2 |
|
3 |
if ( typeof KOHA == "undefined" || !KOHA ) { |
3 |
if ( typeof KOHA == "undefined" || !KOHA ) { |
4 |
var KOHA = {}; |
4 |
var KOHA = {}; |
Lines 76-82
KOHA.OverDriveCirculation = new function() {
Link Here
|
76 |
if( OD_password_required ) { $("#overdrive-login").modal('show'); } |
76 |
if( OD_password_required ) { $("#overdrive-login").modal('show'); } |
77 |
else { login(""); } |
77 |
else { login(""); } |
78 |
}) |
78 |
}) |
79 |
.text( MSG_OVERDRIVE_LOGIN ); |
79 |
.text( __("Log in to your OverDrive account") ); |
80 |
|
80 |
|
81 |
var login_div = $('<div class="overdrive-login">').append(login_link); |
81 |
var login_div = $('<div class="overdrive-login">').append(login_link); |
82 |
|
82 |
|
Lines 121-127
KOHA.OverDriveCirculation = new function() {
Link Here
|
121 |
} |
121 |
} |
122 |
|
122 |
|
123 |
var overdrive_link = $('<a href="https://www.overdrive.com/account/" target="overdrive-account" class="overdrive-link" style="float:right">') |
123 |
var overdrive_link = $('<a href="https://www.overdrive.com/account/" target="overdrive-account" class="overdrive-link" style="float:right">') |
124 |
.text( MSG_OVERDRIVE_LINK ); |
124 |
.text( __( "OverDrive account page" ) ); |
125 |
$(container).append(overdrive_link); |
125 |
$(container).append(overdrive_link); |
126 |
|
126 |
|
127 |
var logout_link = $('<a href="#logout" class="overdrive-logout" style="float:left">') |
127 |
var logout_link = $('<a href="#logout" class="overdrive-logout" style="float:left">') |
Lines 131-142
KOHA.OverDriveCirculation = new function() {
Link Here
|
131 |
logout(function(data) { |
131 |
logout(function(data) { |
132 |
display_account(container, data); |
132 |
display_account(container, data); |
133 |
}); |
133 |
}); |
134 |
}).text( MSG_OVERDRIVE_LOGOUT ); |
134 |
}).text( __("Log out of your OverDrive account") ); |
135 |
$(container).append(logout_link); |
135 |
$(container).append(logout_link); |
136 |
$(container).append('<br style="clear:both;"/>'); |
136 |
$(container).append('<br style="clear:both;"/>'); |
137 |
|
137 |
|
138 |
if (data.checkouts) { |
138 |
if (data.checkouts) { |
139 |
var checkouts_div = $('<div class="overdrive-div">').html('<h3>' + MSG_CHECKOUTS + '</h3>'); |
139 |
var checkouts_div = $('<div class="overdrive-div">').html('<h3>' + __("Checkouts") + '</h3>'); |
140 |
var checkouts_list = $('<ul class="overdrive-list">'); |
140 |
var checkouts_list = $('<ul class="overdrive-list">'); |
141 |
data.checkouts.items.forEach(function(item) { |
141 |
data.checkouts.items.forEach(function(item) { |
142 |
item_line(checkouts_list, item); |
142 |
item_line(checkouts_list, item); |
Lines 146-152
KOHA.OverDriveCirculation = new function() {
Link Here
|
146 |
} |
146 |
} |
147 |
|
147 |
|
148 |
if (data.holds) { |
148 |
if (data.holds) { |
149 |
var holds_div = $('<div class="overdrive-div">').html('<h3>' + MSG_HOLDS + '</h3>'); |
149 |
var holds_div = $('<div class="overdrive-div">').html('<h3>' + __("Holds") + '</h3>'); |
150 |
var holds_list = $('<ul class="overdrive-list">'); |
150 |
var holds_list = $('<ul class="overdrive-list">'); |
151 |
data.holds.items.forEach(function(item) { |
151 |
data.holds.items.forEach(function(item) { |
152 |
item_line(holds_list, item); |
152 |
item_line(holds_list, item); |
Lines 279-291
KOHA.OverDriveCirculation = new function() {
Link Here
|
279 |
if (item) { |
279 |
if (item) { |
280 |
var expires = new Date(item.expires); |
280 |
var expires = new Date(item.expires); |
281 |
$('<span class="overdrive-item-status">') |
281 |
$('<span class="overdrive-item-status">') |
282 |
.text( MSG_OVERDRIVE_CHECKEDOUT_UNTIL + " " + expires.toLocaleString()) |
282 |
.text( __( "Checked out until: " ) + " " + expires.toLocaleString()) |
283 |
.appendTo(el); |
283 |
.appendTo(el); |
284 |
$(el).append(" "); |
284 |
$(el).append(" "); |
285 |
|
285 |
|
286 |
if (item.format) { |
286 |
if (item.format) { |
287 |
var download = $('<a href="#">').appendTo(el); |
287 |
var download = $('<a href="#">').appendTo(el); |
288 |
decorate_button(download, MSG_DOWNLOAD + " " + item.format); |
288 |
decorate_button(download, __("Download") + " " + item.format); |
289 |
svc_ajax('get', {action: "download-url", id: id, format: item.format}, function(data) { |
289 |
svc_ajax('get', {action: "download-url", id: id, format: item.format}, function(data) { |
290 |
download.attr("href", data.action); |
290 |
download.attr("href", data.action); |
291 |
}); |
291 |
}); |
Lines 299-305
KOHA.OverDriveCirculation = new function() {
Link Here
|
299 |
|
299 |
|
300 |
if (item.formats[f]) { |
300 |
if (item.formats[f]) { |
301 |
var access = $('<a target="_blank">').appendTo(el); |
301 |
var access = $('<a target="_blank">').appendTo(el); |
302 |
decorate_button(access, MSG_OVERDRIVE_ACCESS_ONLINE + " " + f); |
302 |
decorate_button(access, __("Access online") + " " + f); |
303 |
svc_ajax('get', {action: "download-url", id: id, format: f}, function(data) { |
303 |
svc_ajax('get', {action: "download-url", id: id, format: f}, function(data) { |
304 |
access.attr("href", data.action); |
304 |
access.attr("href", data.action); |
305 |
}); |
305 |
}); |
Lines 310-316
KOHA.OverDriveCirculation = new function() {
Link Here
|
310 |
} |
310 |
} |
311 |
} |
311 |
} |
312 |
if (lockable_formats.length > 0 && checkout_popup) { |
312 |
if (lockable_formats.length > 0 && checkout_popup) { |
313 |
$(el).append( ajax_button( MSG_OVERDRIVE_DOWNLOAD_AS, function() { |
313 |
$(el).append( ajax_button( __("Download as:"), function() { |
314 |
checkout_format(el, id, lockable_formats, copies_available); |
314 |
checkout_format(el, id, lockable_formats, copies_available); |
315 |
}) ).append(" "); |
315 |
}) ).append(" "); |
316 |
} |
316 |
} |
Lines 318-325
KOHA.OverDriveCirculation = new function() {
Link Here
|
318 |
|
318 |
|
319 |
if (item.format) return item; |
319 |
if (item.format) return item; |
320 |
|
320 |
|
321 |
$(el).append( ajax_button( MSG_CHECK_IN, function() { |
321 |
$(el).append( ajax_button( __("Check in"), function() { |
322 |
if( confirm( MSG_CHECK_IN_CONFIRM ) ) { |
322 |
if( confirm( __("Are you sure you want to return this item?") ) ) { |
323 |
item_action({action: "return", id: id}, el, copies_available + 1); |
323 |
item_action({action: "return", id: id}, el, copies_available + 1); |
324 |
} |
324 |
} |
325 |
}) ); |
325 |
}) ); |
Lines 330-343
KOHA.OverDriveCirculation = new function() {
Link Here
|
330 |
item = item_is_on_hold(id); |
330 |
item = item_is_on_hold(id); |
331 |
if (item) { |
331 |
if (item) { |
332 |
$('<span class="overdrive-status">') |
332 |
$('<span class="overdrive-status">') |
333 |
.text( MSG_ON_HOLD ) |
333 |
.text( __("On hold") ) |
334 |
.appendTo(el); |
334 |
.appendTo(el); |
335 |
$(el).append(" "); |
335 |
$(el).append(" "); |
336 |
} |
336 |
} |
337 |
|
337 |
|
338 |
if(copies_available && checkout_popup) { |
338 |
if(copies_available && checkout_popup) { |
339 |
$(el).append( ajax_button( MSG_CHECK_OUT , function() { |
339 |
$(el).append( ajax_button( __("Check out") , function() { |
340 |
if( confirm( MSG_CHECK_OUT_CONFIRM ) ) { |
340 |
if( confirm( __("Are you sure you want to check out this item?") ) ) { |
341 |
svc_ajax('post', {action: "checkout", id: id}, function(data) { |
341 |
svc_ajax('post', {action: "checkout", id: id}, function(data) { |
342 |
if (data.checkouts) { |
342 |
if (data.checkouts) { |
343 |
details.checkouts = data.checkouts; |
343 |
details.checkouts = data.checkouts; |
Lines 366-379
KOHA.OverDriveCirculation = new function() {
Link Here
|
366 |
}) ); |
366 |
}) ); |
367 |
} |
367 |
} |
368 |
else if (!item) { |
368 |
else if (!item) { |
369 |
$(el).append( ajax_button( MSG_PLACE_HOLD, function() { |
369 |
$(el).append( ajax_button( __("Place hold"), function() { |
370 |
item_action({action: "place-hold", id: id}, el, copies_available); |
370 |
item_action({action: "place-hold", id: id}, el, copies_available); |
371 |
}) ); |
371 |
}) ); |
372 |
} |
372 |
} |
373 |
|
373 |
|
374 |
if (item) { |
374 |
if (item) { |
375 |
$(el).append( ajax_button( MSG_CANCEL_HOLD, function() { |
375 |
$(el).append( ajax_button( __("Cancel"), function() { |
376 |
if( confirm( MSG_CANCEL_HOLD_CONFIRM ) ) { |
376 |
if( confirm( __("Are you sure you want to cancel this hold?") ) ) { |
377 |
item_action({action: "remove-hold", id: id}, el, copies_available); |
377 |
item_action({action: "remove-hold", id: id}, el, copies_available); |
378 |
} |
378 |
} |
379 |
}) ); |
379 |
}) ); |
Lines 401-407
KOHA.OverDriveCirculation = new function() {
Link Here
|
401 |
|
401 |
|
402 |
function checkout_format(el, id, formats, copies_available) { |
402 |
function checkout_format(el, id, formats, copies_available) { |
403 |
if (formats.length == 0) { |
403 |
if (formats.length == 0) { |
404 |
alert( MSG_OVERDRIVE_CANNOT_CHECKOUT ); |
404 |
alert( __("Item cannot be checked out. There are no available formats") ); |
405 |
return false; |
405 |
return false; |
406 |
} |
406 |
} |
407 |
|
407 |
|
408 |
- |
|
|