Lines 296-345
Link Here
|
296 |
[%# Following on one line due to translation issues %] |
296 |
[%# Following on one line due to translation issues %] |
297 |
[% INCLUDE "openlibrary-readapi.inc" bib = { normalized_isbn => normalized_isbn,lccn => lccn, normalized_oclc => normalized_oclc } %] |
297 |
[% INCLUDE "openlibrary-readapi.inc" bib = { normalized_isbn => normalized_isbn,lccn => lccn, normalized_oclc => normalized_oclc } %] |
298 |
|
298 |
|
299 |
[% IF ( OpacStarRatings != 'disable' ) %] |
299 |
[% IF ( OpacStarRatings != 'disable' && loggedinusername) %] |
300 |
<form method="post" action="/cgi-bin/koha/opac-ratings.pl"> |
300 |
[% INCLUDE 'user-star-ratings.inc' item=rating interact=1 %] |
301 |
<legend class="sr-only">Star ratings</legend> |
301 |
[% ELSIF ( OpacStarRatings != 'disable' )%] |
302 |
<div class="results_summary ratings"> |
302 |
[% INCLUDE 'user-star-ratings.inc' item=rating %] |
303 |
|
|
|
304 |
[% SET rating_avg = ratings.get_avg_rating() %] |
305 |
[% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] |
306 |
|
307 |
[% IF ( borrowernumber ) %] |
308 |
<select id="star_rating" name="rating" data-rating-enabled="1" autocomplete="off"> |
309 |
[% ELSE %] |
310 |
<select id="star_rating" name="rating" data-rating-enabled="0" disabled="disabled" autocomplete="off"> |
311 |
[% END %] |
312 |
[% IF ( rating_avg_int == 0 ) %] |
313 |
<option value="" selected="selected"></option> |
314 |
[% END %] |
315 |
[% FOREACH i IN [ 1 2 3 4 5 ] %] |
316 |
[% IF rating_avg_int == i %] |
317 |
<option value="[% i | html %]" selected="selected">[% i | html %]</option> |
318 |
[% ELSE %] |
319 |
<option value="[% i | html %]">[% i | html %]</option> |
320 |
[% END %] |
321 |
[% END %] |
322 |
</select> |
323 |
<img id="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" /> |
324 |
|
325 |
<!-- define some hidden vars for ratings --> |
326 |
|
327 |
<input type="hidden" name='biblionumber' value="[% biblio.biblionumber | html %]" /> |
328 |
<input type="hidden" name='rating_value' id='rating_value' value="[% my_rating.rating_value | html %]" /> |
329 |
|
330 |
[% UNLESS ( rating_readonly ) %] <input name="rate_button" type="submit" value="Rate me" />[% END %] |
331 |
|
332 |
[% IF my_rating %] |
333 |
<span id="rating_value_text">Your rating: [% my_rating.rating_value | html %].</span> |
334 |
<span id="cancel_rating_text"><a href="#"><i class="fa fa-remove" aria-hidden="true"></i> Cancel rating</a>.</span> |
335 |
[% ELSE %] |
336 |
<span id="rating_value_text"></span> |
337 |
<span id="cancel_rating_text" style="display:none;"><a href="#"><i class="fa fa-remove" aria-hidden="true"></i> Cancel rating</a>.</span> |
338 |
[% END %] |
339 |
|
340 |
<span id="rating_text">Average rating: [% rating_avg | html %] ([% ratings.count | html %] votes)</span> |
341 |
</div> |
342 |
</form> |
343 |
[% END # / IF OpacStarRatings != 'disable' %] |
303 |
[% END # / IF OpacStarRatings != 'disable' %] |
344 |
|
304 |
|
345 |
[% IF ( BakerTaylorContentURL ) %] |
305 |
[% IF ( BakerTaylorContentURL ) %] |
Lines 1379-1386
Link Here
|
1379 |
[% INCLUDE 'datatables.inc' %] |
1339 |
[% INCLUDE 'datatables.inc' %] |
1380 |
[% INCLUDE 'columns_settings.inc' %] |
1340 |
[% INCLUDE 'columns_settings.inc' %] |
1381 |
[% INCLUDE greybox.inc %] |
1341 |
[% INCLUDE greybox.inc %] |
1382 |
[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %][% END %] |
|
|
1383 |
|
1342 |
|
|
|
1343 |
[% IF ( OpacStarRatings != 'disable' ) %] |
1344 |
[% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] |
1345 |
[% Asset.js("js/ratings.js") | $raw %] |
1346 |
<script> |
1347 |
var borrowernumber = [% borrowernumber | html %]; |
1348 |
var MSG_YOUR_RATING = _("Your rating: %s, "); |
1349 |
var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)"); |
1350 |
</script> |
1351 |
[% END %] |
1384 |
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] |
1352 |
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] |
1385 |
[% IF ( Koha.Preference('OPACDetailQRCode') ) %] |
1353 |
[% IF ( Koha.Preference('OPACDetailQRCode') ) %] |
1386 |
[% Asset.js("lib/kjua/kjua.min.js") | $raw %] |
1354 |
[% Asset.js("lib/kjua/kjua.min.js") | $raw %] |
Lines 1817-1867
Link Here
|
1817 |
}); |
1785 |
}); |
1818 |
}()); |
1786 |
}()); |
1819 |
[% END # /IF ( OPACShelfBrowser ) %] |
1787 |
[% END # /IF ( OPACShelfBrowser ) %] |
1820 |
|
|
|
1821 |
[% IF ( OpacStarRatings != 'disable' ) %] |
1822 |
// ----------------------------------------------------- |
1823 |
// star-ratings code |
1824 |
// ----------------------------------------------------- |
1825 |
// hide 'rate' button if javascript enabled |
1826 |
|
1827 |
$('input[name="rate_button"]').remove(); |
1828 |
|
1829 |
var rating_enabled = ( $("#star_rating").data("rating-enabled") == "1" ) ? false : true; |
1830 |
$('#star_rating').barrating({ |
1831 |
theme: 'fontawesome-stars', |
1832 |
showSelectedRating: false, |
1833 |
allowEmpty: true, |
1834 |
deselectable: false, |
1835 |
readonly: rating_enabled, |
1836 |
onSelect: function(value, text) { |
1837 |
$("#rating-loading").show(); |
1838 |
$.post("/cgi-bin/koha/opac-ratings-ajax.pl", { |
1839 |
rating_old_value: $("#rating_value").attr("value"), |
1840 |
borrowernumber: "[% borrowernumber | html %]", |
1841 |
biblionumber: "[% biblio.biblionumber | html %]", |
1842 |
rating_value: value, |
1843 |
auth_error: value |
1844 |
}, function (data) { |
1845 |
$("#rating_value").val(data.rating_value); |
1846 |
if (data.rating_value) { |
1847 |
$("#rating_value_text").text(_("Your rating: %s, ").format(data.rating_value)); |
1848 |
$("#cancel_rating_text").show(); |
1849 |
} else { |
1850 |
$("#rating_value_text").text(''); |
1851 |
$("#cancel_rating_text").hide(); |
1852 |
} |
1853 |
$("#rating_text").text(_("Average rating: %s (%s votes)").format(data.rating_avg, data.rating_total)); |
1854 |
$("#rating-loading").hide(); |
1855 |
}, "json"); |
1856 |
} |
1857 |
}); |
1858 |
|
1859 |
$("#cancel_rating_text a").on("click", function(e){ |
1860 |
e.preventDefault(); |
1861 |
$("#star_rating").barrating("set", ""); |
1862 |
}); |
1863 |
|
1864 |
[% END # / IF ( OpacStarRatings != 'disable' )%] |
1865 |
}); |
1788 |
}); |
1866 |
|
1789 |
|
1867 |
$(document).ready(function() { |
1790 |
$(document).ready(function() { |