|
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 1361-1368
Link Here
|
| 1361 |
[% INCLUDE 'datatables.inc' %] |
1321 |
[% INCLUDE 'datatables.inc' %] |
| 1362 |
[% INCLUDE 'columns_settings.inc' %] |
1322 |
[% INCLUDE 'columns_settings.inc' %] |
| 1363 |
[% INCLUDE greybox.inc %] |
1323 |
[% INCLUDE greybox.inc %] |
| 1364 |
[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %][% END %] |
|
|
| 1365 |
|
1324 |
|
|
|
1325 |
[% IF ( OpacStarRatings != 'disable' ) %] |
| 1326 |
[% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] |
| 1327 |
[% Asset.js("js/ratings.js") | $raw %] |
| 1328 |
<script> |
| 1329 |
var borrowernumber = [% borrowernumber | html %]; |
| 1330 |
var MSG_YOUR_RATING = _("Your rating: %s, "); |
| 1331 |
var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)"); |
| 1332 |
</script> |
| 1333 |
[% END %] |
| 1366 |
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] |
1334 |
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] |
| 1367 |
[% IF ( Koha.Preference('OPACDetailQRCode') ) %] |
1335 |
[% IF ( Koha.Preference('OPACDetailQRCode') ) %] |
| 1368 |
[% Asset.js("lib/kjua/kjua.min.js") | $raw %] |
1336 |
[% Asset.js("lib/kjua/kjua.min.js") | $raw %] |
|
Lines 1803-1853
Link Here
|
| 1803 |
}); |
1771 |
}); |
| 1804 |
}()); |
1772 |
}()); |
| 1805 |
[% END # /IF ( OPACShelfBrowser ) %] |
1773 |
[% END # /IF ( OPACShelfBrowser ) %] |
| 1806 |
|
|
|
| 1807 |
[% IF ( OpacStarRatings != 'disable' ) %] |
| 1808 |
// ----------------------------------------------------- |
| 1809 |
// star-ratings code |
| 1810 |
// ----------------------------------------------------- |
| 1811 |
// hide 'rate' button if javascript enabled |
| 1812 |
|
| 1813 |
$('input[name="rate_button"]').remove(); |
| 1814 |
|
| 1815 |
var rating_enabled = ( $("#star_rating").data("rating-enabled") == "1" ) ? false : true; |
| 1816 |
$('#star_rating').barrating({ |
| 1817 |
theme: 'fontawesome-stars', |
| 1818 |
showSelectedRating: false, |
| 1819 |
allowEmpty: true, |
| 1820 |
deselectable: false, |
| 1821 |
readonly: rating_enabled, |
| 1822 |
onSelect: function(value, text) { |
| 1823 |
$("#rating-loading").show(); |
| 1824 |
$.post("/cgi-bin/koha/opac-ratings-ajax.pl", { |
| 1825 |
rating_old_value: $("#rating_value").attr("value"), |
| 1826 |
borrowernumber: "[% borrowernumber | html %]", |
| 1827 |
biblionumber: "[% biblio.biblionumber | html %]", |
| 1828 |
rating_value: value, |
| 1829 |
auth_error: value |
| 1830 |
}, function (data) { |
| 1831 |
$("#rating_value").val(data.rating_value); |
| 1832 |
if (data.rating_value) { |
| 1833 |
$("#rating_value_text").text(_("Your rating: %s, ").format(data.rating_value)); |
| 1834 |
$("#cancel_rating_text").show(); |
| 1835 |
} else { |
| 1836 |
$("#rating_value_text").text(''); |
| 1837 |
$("#cancel_rating_text").hide(); |
| 1838 |
} |
| 1839 |
$("#rating_text").text(_("Average rating: %s (%s votes)").format(data.rating_avg, data.rating_total)); |
| 1840 |
$("#rating-loading").hide(); |
| 1841 |
}, "json"); |
| 1842 |
} |
| 1843 |
}); |
| 1844 |
|
| 1845 |
$("#cancel_rating_text a").on("click", function(e){ |
| 1846 |
e.preventDefault(); |
| 1847 |
$("#star_rating").barrating("set", ""); |
| 1848 |
}); |
| 1849 |
|
| 1850 |
[% END # / IF ( OpacStarRatings != 'disable' )%] |
| 1851 |
}); |
1774 |
}); |
| 1852 |
|
1775 |
|
| 1853 |
$(document).ready(function() { |
1776 |
$(document).ready(function() { |