Lines 299-313
Link Here
|
299 |
[% IF ( OpacStarRatings != 'disable' ) %] |
299 |
[% IF ( OpacStarRatings != 'disable' ) %] |
300 |
<form method="post" action="/cgi-bin/koha/opac-ratings.pl"> |
300 |
<form method="post" action="/cgi-bin/koha/opac-ratings.pl"> |
301 |
<legend class="sr-only">Star ratings</legend> |
301 |
<legend class="sr-only">Star ratings</legend> |
302 |
<div class="results_summary ratings"> |
302 |
<div class="results_summary ratings" id="rating-[% biblio.biblionumber | html %]"> |
303 |
|
303 |
|
304 |
[% SET rating_avg = ratings.get_avg_rating() %] |
304 |
[% SET rating_avg = ratings.get_avg_rating() %] |
305 |
[% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] |
305 |
[% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] |
306 |
|
306 |
|
307 |
[% IF ( borrowernumber ) %] |
307 |
[% IF ( borrowernumber ) %] |
308 |
<select id="star_rating" name="rating" data-rating-enabled="1" autocomplete="off"> |
308 |
<select id="star_rating" class="star_rating" name="rating" data-biblionumber="[% biblio.biblionumber | html %]" data-context="rating-[% biblio.biblionumber | html %]" autocomplete="off"> |
309 |
[% ELSE %] |
309 |
[% ELSE %] |
310 |
<select id="star_rating" name="rating" data-rating-enabled="0" disabled="disabled" autocomplete="off"> |
310 |
<select id="star_rating" class="star_rating" name="rating" disabled="disabled" autocomplete="off"> |
311 |
[% END %] |
311 |
[% END %] |
312 |
[% IF ( rating_avg_int == 0 ) %] |
312 |
[% IF ( rating_avg_int == 0 ) %] |
313 |
<option value="" selected="selected"></option> |
313 |
<option value="" selected="selected"></option> |
Lines 320-343
Link Here
|
320 |
[% END %] |
320 |
[% END %] |
321 |
[% END %] |
321 |
[% END %] |
322 |
</select> |
322 |
</select> |
323 |
<img id="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" /> |
323 |
<img id="rating-loading" class="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" /> |
324 |
|
324 |
|
325 |
<!-- define some hidden vars for ratings --> |
325 |
<!-- define some hidden vars for ratings --> |
326 |
|
326 |
|
327 |
<input type="hidden" name='biblionumber' value="[% biblio.biblionumber | html %]" /> |
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 %]" /> |
328 |
<input type="hidden" name='rating_value' id='rating_value' class="rating_value" value="[% my_rating.rating_value | html %]" /> |
329 |
|
329 |
|
330 |
[% UNLESS ( rating_readonly ) %] <input name="rate_button" type="submit" value="Rate me" />[% END %] |
330 |
[% UNLESS ( rating_readonly ) %] <input name="rate_button" type="submit" value="Rate me" />[% END %] |
331 |
|
331 |
|
332 |
[% IF my_rating %] |
332 |
[% IF my_rating %] |
333 |
<span id="rating_value_text">Your rating: [% my_rating.rating_value | html %].</span> |
333 |
<span id="rating_value_text" class="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> |
334 |
<span id="cancel_rating_text" class="cancel_rating_text"><a href="#" data-context="star_rating"><i class="fa fa-remove" aria-hidden="true"></i> Cancel rating.</a></span> |
335 |
[% ELSE %] |
335 |
[% ELSE %] |
336 |
<span id="rating_value_text"></span> |
336 |
<span id="rating_value_text" class="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> |
337 |
<span id="cancel_rating_text" class="cancel_rating_text" style="display: none;"><a href="#" data-context="star_rating"><i class="fa fa-remove" aria-hidden="true"></i> Cancel rating.</a></span> |
338 |
[% END %] |
338 |
[% END %] |
339 |
|
339 |
|
340 |
<span id="rating_text">Average rating: [% rating_avg | html %] ([% ratings.count | html %] votes)</span> |
340 |
<span id="rating_text" class="rating_text">Average rating: [% rating_avg | html %] ([% ratings.count | html %] votes)</span> |
341 |
</div> |
341 |
</div> |
342 |
</form> |
342 |
</form> |
343 |
[% END # / IF OpacStarRatings != 'disable' %] |
343 |
[% END # / IF OpacStarRatings != 'disable' %] |
Lines 1432-1438
Link Here
|
1432 |
[% INCLUDE 'datatables.inc' %] |
1432 |
[% INCLUDE 'datatables.inc' %] |
1433 |
[% INCLUDE 'columns_settings.inc' %] |
1433 |
[% INCLUDE 'columns_settings.inc' %] |
1434 |
[% INCLUDE greybox.inc %] |
1434 |
[% INCLUDE greybox.inc %] |
1435 |
[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %][% END %] |
1435 |
[% IF ( OpacStarRatings != 'disable' ) %] |
|
|
1436 |
[% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] |
1437 |
[% Asset.js("js/ratings.js") | $raw %] |
1438 |
[% END %] |
1436 |
|
1439 |
|
1437 |
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] |
1440 |
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] |
1438 |
[% IF ( Koha.Preference('OPACDetailQRCode') ) %] |
1441 |
[% IF ( Koha.Preference('OPACDetailQRCode') ) %] |
Lines 1883-1933
Link Here
|
1883 |
}); |
1886 |
}); |
1884 |
}()); |
1887 |
}()); |
1885 |
[% END # /IF ( OPACShelfBrowser ) %] |
1888 |
[% END # /IF ( OPACShelfBrowser ) %] |
1886 |
|
|
|
1887 |
[% IF ( OpacStarRatings != 'disable' ) %] |
1888 |
// ----------------------------------------------------- |
1889 |
// star-ratings code |
1890 |
// ----------------------------------------------------- |
1891 |
// hide 'rate' button if javascript enabled |
1892 |
|
1893 |
$('input[name="rate_button"]').remove(); |
1894 |
|
1895 |
var rating_enabled = ( $("#star_rating").data("rating-enabled") == "1" ) ? false : true; |
1896 |
$('#star_rating').barrating({ |
1897 |
theme: 'fontawesome-stars', |
1898 |
showSelectedRating: false, |
1899 |
allowEmpty: true, |
1900 |
deselectable: false, |
1901 |
readonly: rating_enabled, |
1902 |
onSelect: function(value, text) { |
1903 |
$("#rating-loading").show(); |
1904 |
$.post("/cgi-bin/koha/opac-ratings-ajax.pl", { |
1905 |
rating_old_value: $("#rating_value").attr("value"), |
1906 |
borrowernumber: "[% borrowernumber | html %]", |
1907 |
biblionumber: "[% biblio.biblionumber | html %]", |
1908 |
rating_value: value, |
1909 |
auth_error: value |
1910 |
}, function (data) { |
1911 |
$("#rating_value").val(data.rating_value); |
1912 |
if (data.rating_value) { |
1913 |
$("#rating_value_text").text(_("Your rating: %s, ").format(data.rating_value)); |
1914 |
$("#cancel_rating_text").show(); |
1915 |
} else { |
1916 |
$("#rating_value_text").text(''); |
1917 |
$("#cancel_rating_text").hide(); |
1918 |
} |
1919 |
$("#rating_text").text(_("Average rating: %s (%s votes)").format(data.rating_avg, data.rating_total)); |
1920 |
$("#rating-loading").hide(); |
1921 |
}, "json"); |
1922 |
} |
1923 |
}); |
1924 |
|
1925 |
$("#cancel_rating_text a").on("click", function(e){ |
1926 |
e.preventDefault(); |
1927 |
$("#star_rating").barrating("set", ""); |
1928 |
}); |
1929 |
|
1930 |
[% END # / IF ( OpacStarRatings != 'disable' )%] |
1931 |
}); |
1889 |
}); |
1932 |
|
1890 |
|
1933 |
$(document).ready(function() { |
1891 |
$(document).ready(function() { |