View | Details | Raw Unified | Return to bug 25110
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +1 lines)
Lines 56-62 OPAC: Link Here
56
            - "Show star-ratings on"
56
            - "Show star-ratings on"
57
            - pref: OpacStarRatings
57
            - pref: OpacStarRatings
58
              choices:
58
              choices:
59
                  all: "results and details"
59
                  all: "results, details, and user"
60
                  disable: "no"
60
                  disable: "no"
61
                  details: "only details"
61
                  details: "only details"
62
            - "pages."
62
            - "pages."
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc (+53 lines)
Line 0 Link Here
1
<div class="results_summary ratings" id="rating-[% item.itemnumber | html %]">
2
3
    [% SET rating_avg = item.ratings.get_avg_rating() %]
4
    [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
5
6
    <div class="br-wrapper br-theme-fontawesome-stars js-hide">
7
        <div class="br-widget br-readonly">
8
            [% FOREACH i IN [ 1 2 3 4 5  ] %]
9
                [% IF rating_avg_int == i %]
10
                    <a href="#" class="br-selected br-current"></a>
11
                [% ELSIF rating_avg_int > i %]
12
                    <a href="#" class="br-selected"></a>
13
                [% ELSE %]
14
                    <a href="#"></a>
15
                [% END %]
16
            [% END %]
17
        </div>
18
    </div>
19
20
    <select class="star_rating" id="star_rating-[% item.itemnumber | html %]" name="rating" autocomplete="off" data-biblionumber="[% item.biblionumber | html %]" data-context="rating-[% item.itemnumber | html %]">
21
22
        [% IF ( rating_avg_int == 0 ) %]
23
            <option value="" selected="selected"></option>
24
        [% END %]
25
        [% FOREACH i IN [ 1 2 3 4 5  ] %]
26
            [% IF rating_avg_int == i %]
27
                <option value="[% i | html %]" selected="selected">[% i | html %]</option>
28
            [% ELSE %]
29
                <option value="[% i | html %]">[% i | html %]</option>
30
            [% END %]
31
        [% END %]
32
    </select>
33
    <img id="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" />
34
35
    <!-- define some hidden vars for ratings -->
36
37
    <input type="hidden" name="biblionumber" value="[% item.biblionumber | html %]" />
38
    <input type="hidden" name="rating_value" class="rating_value" value="[% item.my_rating.rating_value | html %]" />
39
40
    <input name="rate_button" type="submit" class="js-show" value="Rate me" />
41
42
    [% IF item.my_rating %]
43
        <div>
44
            <span class="rating_value_text">Your rating: [% item.my_rating.rating_value | html %].</span>
45
            <span class="cancel_rating_text js-show"><a href="#" data-context="star_rating-[% item.itemnumber | html %]"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
46
        </div>
47
    [% ELSE %]
48
        <span class="rating_value_text"></span>
49
        <span class="cancel_rating_text" style="display:none;"><a href="#" data-context="star_rating-[% item.itemnumber | html %]"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
50
    [% END %]
51
52
    <div class="rating_text">Average rating: [% rating_avg | html %] ([% item.ratings.count | html %] votes)</div>
53
</div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (-18 / +10 lines)
Lines 145-168 Link Here
145
                                                [% END %]
145
                                                [% END %]
146
                                                <p class="results-summary item-details">[% issue.author | html %]</p>
146
                                                <p class="results-summary item-details">[% issue.author | html %]</p>
147
147
148
                                                    [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' && issue.my_rating ) %]
148
                                                    [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' ) %]
149
                                                        <div class="results_summary ratings">
149
                                                        [% INCLUDE 'user-star-ratings.inc' item=issue %]
150
                                                            <div class="br-wrapper br-theme-fontawesome-stars">
150
                                                    [% END %]
151
                                                                <div class="br-widget br-readonly">
152
                                                                    [% FOREACH i IN [ 1 2 3 4 5  ] %]
153
                                                                        [% IF issue.my_rating.rating_value == i %]
154
                                                                            <a href="#" class="br-selected br-current"></a>
155
                                                                        [% ELSIF issue.my_rating.rating_value > i %]
156
                                                                            <a href="#" class="br-selected"></a>
157
                                                                        [% ELSE %]
158
                                                                            <a href="#"></a>
159
                                                                        [% END %]
160
                                                                    [% END %]
161
                                                                </div>
162
                                                            </div>
163
                                                            Rated on [% issue.my_rating.timestamp | $KohaDates %]
164
                                                        </div> <!-- / .results_summary -->
165
                                                    [% END # / IF OpacStarRatings %]
166
151
167
                                                </td>
152
                                                </td>
168
                                                <td>
153
                                                <td>
Lines 235-239 Link Here
235
            }
220
            }
236
        });
221
        });
237
    });
222
    });
223
    var borrowernumber = "[% borrowernumber | html %]";
224
    var MSG_YOUR_RATING = _("Your rating: %s, ");
225
    var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)");
238
</script>
226
</script>
227
    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
228
        [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
229
        [% Asset.js("js/ratings.js") | $raw %]
230
    [% END %]
239
[% END %]
231
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-2 / +12 lines)
Lines 294-300 Link Here
294
                                                <td class="title">
294
                                                <td class="title">
295
                                                    <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ISSUE.biblionumber | html %]">[% INCLUDE 'biblio-title.inc' biblio=ISSUE %]</a>
295
                                                    <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ISSUE.biblionumber | html %]">[% INCLUDE 'biblio-title.inc' biblio=ISSUE %]</a>
296
                                                    [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron | html %][% END %]
296
                                                    [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron | html %][% END %]
297
297
                                                    [% IF ( ISSUE.onsite_checkout ) %] <i class="onsite_checkout">(On-site checkout)</i>[% END %]
298
                                                    [% IF ( ISSUE.onsite_checkout ) %] <i class="onsite_checkout">(On-site checkout)</i>[% END %]
299
300
                                                    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
301
                                                        [% INCLUDE 'user-star-ratings.inc' item=ISSUE %]
302
                                                    [% END %]
298
                                                </td>
303
                                                </td>
299
304
300
                                                <td class="author">[% ISSUE.author | html %]</td>
305
                                                <td class="author">[% ISSUE.author | html %]</td>
Lines 779-786 Link Here
779
784
780
        $(document).ready(function(){
785
        $(document).ready(function(){
781
            $('#opac-user-views').tabs();
786
            $('#opac-user-views').tabs();
782
            $(".js-show").show();
783
            $(".js-hide").hide();
784
            $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs");
787
            $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs");
785
            $(".suspend-until").prop("readonly",1);
788
            $(".suspend-until").prop("readonly",1);
786
789
Lines 964-970 Link Here
964
            }
967
            }
965
        });
968
        });
966
        //]]>
969
        //]]>
970
        var borrowernumber = "[% borrowernumber | html %]";
971
        var MSG_YOUR_RATING = _("Your rating: %s, ");
972
        var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)");
967
    </script>
973
    </script>
974
    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
975
        [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
976
        [% Asset.js("js/ratings.js") | $raw %]
977
    [% END %]
968
    [% IF Koha.Preference('OverDriveCirculation') %]
978
    [% IF Koha.Preference('OverDriveCirculation') %]
969
    [% Asset.js("js/overdrive.js") | $raw %]
979
    [% Asset.js("js/overdrive.js") | $raw %]
970
    <script>
980
    <script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js (+46 lines)
Line 0 Link Here
1
/* global borrowernumber MSG_YOUR_RATING MSG_AVERAGE_RATING */
2
// -----------------------------------------------------
3
// star-ratings code
4
// -----------------------------------------------------
5
// hide 'rate' button if javascript enabled
6
7
$(document).ready(function(){
8
    $("input[name='rate_button']").remove();
9
10
    var star_ratings = $(".star_rating");
11
12
    star_ratings.barrating({
13
        theme: 'fontawesome-stars',
14
        showSelectedRating: false,
15
        allowEmpty: true,
16
        deselectable: false,
17
        onSelect: function( value ) {
18
            var context = $("#" + this.$elem.data("context") );
19
            $(".rating-loading", context ).show();
20
            $.post("/cgi-bin/koha/opac-ratings-ajax.pl", {
21
                rating_old_value: $(".rating_value", context ).attr("value"),
22
                borrowernumber: borrowernumber,
23
                biblionumber: this.$elem.data('biblionumber'),
24
                rating_value: value,
25
                auth_error: value
26
            }, function (data) {
27
                $(".rating_value", context ).val(data.rating_value);
28
                if (data.rating_value) {
29
                    $(".rating_value_text", context ).text( MSG_YOUR_RATING.format(data.rating_value) );
30
                    $(".cancel_rating_text", context ).show();
31
                } else {
32
                    $(".rating_value_text", context ).text("");
33
                    $(".cancel_rating_text", context ).hide();
34
                }
35
                $(".rating_text", context ).text( MSG_AVERAGE_RATING.format(data.rating_avg, data.rating_total) );
36
                $(".rating-loading", context ).hide();
37
            }, "json");
38
        }
39
    });
40
41
    $("body").on("click", ".cancel_rating_text a", function(e){
42
        e.preventDefault();
43
        var context = "#" + $(this).data("context");
44
        $(context).barrating("set", "");
45
    });
46
});
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/script.js (-1 / +3 lines)
Lines 42-47 $(document).ready(function(){ Link Here
42
        window.close();
42
        window.close();
43
    });
43
    });
44
    $(".focus").focus();
44
    $(".focus").focus();
45
    $(".js-show").show();
46
    $(".js-hide").hide();
45
47
46
    if( $(window).width() < 768 ){
48
    if( $(window).width() < 768 ){
47
        facetMenu("hide");
49
        facetMenu("hide");
Lines 70-73 $(document).ready(function(){ Link Here
70
        e.preventDefault();
72
        e.preventDefault();
71
        $("#loginModal").modal("show");
73
        $("#loginModal").modal("show");
72
    });
74
    });
73
});
75
});
(-)a/opac/opac-user.pl (-1 / +7 lines)
Lines 43-48 use Koha::Patrons; Link Here
43
use Koha::Patron::Messages;
43
use Koha::Patron::Messages;
44
use Koha::Patron::Discharge;
44
use Koha::Patron::Discharge;
45
use Koha::Patrons;
45
use Koha::Patrons;
46
use Koha::Ratings;
46
use Koha::Token;
47
use Koha::Token;
47
48
48
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
49
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
Lines 267-272 if ( $pending_checkouts->count ) { # Useless test Link Here
267
            $issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
268
            $issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
268
        }
269
        }
269
270
271
        if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
272
            my $ratings = Koha::Ratings->search({ biblionumber => $issue->{biblionumber} });
273
            $issue->{ratings} = $ratings;
274
            $issue->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
275
        }
276
270
        $issue->{biblio_object} = Koha::Biblios->find($issue->{biblionumber});
277
        $issue->{biblio_object} = Koha::Biblios->find($issue->{biblionumber});
271
        push @issuedat, $issue;
278
        push @issuedat, $issue;
272
        $count++;
279
        $count++;
273
- 

Return to bug 25110