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

(-)a/koha-tmpl/opac-tmpl/bootstrap/css/jquery.rating.css (-14 lines)
Lines 1-14 Link Here
1
/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */
2
div.rating-cancel,div.star-rating{float:left;width:15px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden}
3
div.rating-cancel,div.rating-cancel a{background:url(../images/star-ratings-sprite.png) no-repeat 0 -49px}
4
div.star-rating,div.star-rating a{background:url(../images/star-ratings-sprite.png) no-repeat 0 0px}
5
div.rating-cancel a{display:block;width:16px;height:100%;background-position:0 -49px;border:0}
6
div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0}
7
div.star-rating-on a{background-position:0 -32px!important}
8
div.rating-cancel.star-rating-hover a{background-position:0 -65px}
9
div.star-rating-hover a{background-position:0 -16px}
10
/* Read Only CSS */
11
div.star-rating-readonly a{cursor:default !important}
12
/* Partial Star CSS */
13
div.star-rating{background:transparent!important;overflow:hidden!important}
14
/* END jQuery.Rating Plugin CSS */
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-47 / +43 lines)
Lines 37-45 Link Here
37
[% IF ( bidi ) %]
37
[% IF ( bidi ) %]
38
  [% BLOCK cssinclude %][% Asset.css("css/right-to-left.css") %][% END %]
38
  [% BLOCK cssinclude %][% Asset.css("css/right-to-left.css") %][% END %]
39
[% END %]
39
[% END %]
40
[% IF ( OpacStarRatings != 'disable' ) %]
41
    [% BLOCK cssinclude %][% Asset.css("css/jquery.rating.css") %][% END %]
42
[% END %]
43
[% INCLUDE greybox.inc %]
40
[% INCLUDE greybox.inc %]
44
    [% Asset.css("lib/emoji-picker/css/emoji.css") %]
41
    [% Asset.css("lib/emoji-picker/css/emoji.css") %]
45
</head>
42
</head>
Lines 495-512 Link Here
495
492
496
                                [% SET rating_avg = ratings.get_avg_rating() %]
493
                                [% SET rating_avg = ratings.get_avg_rating() %]
497
                                [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
494
                                [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
498
                                [% FOREACH i  IN [ 1 2 3 4 5  ] %]
495
                                [% IF ( borrowernumber ) %]
499
                                    [% IF rating_avg_int == i && borrowernumber %]
496
                                    <select id="star_rating" name="rating" data-rating-enabled="1" autocomplete="off">
500
                                        <input class="auto-submit-star" type="radio" name="rating"  value="[% i %]"  checked="checked" />
497
                                [% ELSE %]
501
                                    [% ELSIF rating_avg_int == i %]
498
                                    <select id="star_rating" name="rating" data-rating-enabled="0" disabled="disabled" autocomplete="off">
502
                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i %]" checked="checked" disabled="disabled" />
503
                                    [% ELSIF borrowernumber  %]
504
                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i %]" />
505
                                    [% ELSE   %]
506
                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i %]" disabled="disabled" />
507
                                    [% END %]
508
                                [% END %]
499
                                [% END %]
509
500
                                        [% FOREACH i IN [ 1 2 3 4 5  ] %]
501
                                            [% IF rating_avg_int == i %]
502
                                                <option value="[% i %]" selected="selected">[% i %]</option>
503
                                            [% ELSE %]
504
                                                <option value"[% i %]">[% i %]</option>
505
                                            [% END %]
506
                                        [% END %]
507
                                    </select>
510
                                <!-- define some hidden vars for ratings -->
508
                                <!-- define some hidden vars for ratings -->
511
509
512
                                <input  type="hidden" name='biblionumber'  value="[% biblio.biblionumber %]" />
510
                                <input  type="hidden" name='biblionumber'  value="[% biblio.biblionumber %]" />
Lines 515-526 Link Here
515
                                [% UNLESS ( rating_readonly ) %]&nbsp;  <input name="rate_button" type="submit" value="Rate me" />[% END %]&nbsp;
513
                                [% UNLESS ( rating_readonly ) %]&nbsp;  <input name="rate_button" type="submit" value="Rate me" />[% END %]&nbsp;
516
514
517
                                [% IF my_rating %]
515
                                [% IF my_rating %]
518
                                    <span id="rating_value_text">your rating: [% my_rating.rating_value %], </span>
516
                                    <span id="rating_value_text">Your rating: [% my_rating.rating_value %].</span>
517
                                    <span id="cancel_rating_text"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
519
                                [% ELSE %]
518
                                [% ELSE %]
520
                                    <span id="rating_value_text"></span>
519
                                    <span id="rating_value_text"></span>
520
                                    <span id="cancel_rating_text" style="display:none;"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
521
                                [% END %]
521
                                [% END %]
522
522
523
                                <span id="rating_text">average rating: [% rating_avg %] ([% ratings.count %] votes)</span>
523
                                <span id="rating_text">Average rating: [% rating_avg %] ([% ratings.count %] votes)</span>
524
                            </div>
524
                            </div>
525
                        </form>
525
                        </form>
526
                    [% END # / IF OpacStarRatings != 'disable' %]
526
                    [% END # / IF OpacStarRatings != 'disable' %]
Lines 1389-1395 Link Here
1389
    </script>
1389
    </script>
1390
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
1390
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
1391
[% END %]
1391
[% END %]
1392
[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") %][% END %]
1392
[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") %][% END %]
1393
1393
1394
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %][% END %]
1394
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %][% END %]
1395
1395
Lines 1649-1698 Link Here
1649
    // -----------------------------------------------------
1649
    // -----------------------------------------------------
1650
    // star-ratings code
1650
    // star-ratings code
1651
    // -----------------------------------------------------
1651
    // -----------------------------------------------------
1652
    // hide 'rate' button if javascript enabled
1653
1652
1653
    // hide 'rate' button if javascript enabled
1654
    $('input[name="rate_button"]').remove();
1654
    $('input[name="rate_button"]').remove();
1655
1655
1656
    $(function () {
1656
    var rating_enabled = ( $("#star_rating").data("rating-enabled") == "1" ) ? false : true;
1657
      $(".auto-submit-star").rating({
1657
    $('#star_rating').barrating({
1658
        cancel: _("Cancel rating"),
1658
        theme: 'fontawesome-stars',
1659
        callback: function (value, link) {
1659
        showSelectedRating: false,
1660
1660
        allowEmpty: true,
1661
          // if the new value equals the old value, dont execute callback...
1661
        readonly: rating_enabled,
1662
          // just do nothing!
1662
        onSelect: function(value, text) {
1663
          if ($("#rating_value").attr("value") != value) {
1663
            $.post("/cgi-bin/koha/opac-ratings-ajax.pl", {
1664
1665
            $(function () {
1666
1667
              $.post("/cgi-bin/koha/opac-ratings-ajax.pl", {
1668
                rating_old_value: $("#rating_value").attr("value"),
1664
                rating_old_value: $("#rating_value").attr("value"),
1669
                borrowernumber: "[% borrowernumber %]",
1665
                borrowernumber: "[% borrowernumber %]",
1670
                biblionumber: "[% biblio.biblionumber %]",
1666
                biblionumber: "[% biblio.biblionumber %]",
1671
                rating_value: value,
1667
                rating_value: value,
1672
                auth_error: value
1668
                auth_error: value
1673
              }, function (data) {
1669
            }, function (data) {
1674
1670
1675
                if (data.auth_status != 'ok') {
1671
                if (data.auth_status != 'ok') {
1676
                  window.alert(_("Your CGI session cookie is not current. Please refresh the page and try again."));
1672
                    window.alert(_("Your session has expired. Please refresh the page and try again."));
1677
                } else {
1673
                } else {
1678
                  $("#rating_value").val(data.rating_value);
1674
                    $("#rating_value").val(data.rating_value);
1679
1675
                    if (data.rating_value) {
1680
                  if (data.rating_value) {
1676
                        $("#rating_value_text").text(_("Your rating: %s.").format(data.rating_value));
1681
                    $("#rating_value_text").text(_("your rating: %s, ").format(data.rating_value));
1677
                        $("#cancel_rating_text").show();
1682
                  } else {
1678
                    } else {
1683
                    $("#rating_value_text").text('');
1679
                        $("#rating_value_text").text('');
1684
                  }
1680
                        $("#cancel_rating_text").hide();
1685
1681
                    }
1686
                  $("#rating_text").text(_("average rating: %s (%s votes)").format(data.rating_avg, data.rating_total));
1682
                    $("#rating_text").text(_("Average rating: %s (%s votes)").format(data.rating_avg, data.rating_total));
1687
1688
                }
1683
                }
1689
              }, "json");
1684
            }, "json");
1690
            });
1691
          };
1692
        }
1685
        }
1693
      });
1694
    });
1686
    });
1695
    // -----------------------------------------------------
1687
1688
    $("#cancel_rating_text a").on("click", function(){
1689
        $("#star_rating").barrating("set", "");
1690
    });
1691
1696
[% END # / IF ( OpacStarRatings != 'disable' )%]
1692
[% END # / IF ( OpacStarRatings != 'disable' )%]
1697
1693
1698
[% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %]
1694
[% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (-16 / +18 lines)
Lines 11-22 Link Here
11
    You did not specify any search criteria.
11
    You did not specify any search criteria.
12
[% END %]</title>
12
[% END %]</title>
13
[% INCLUDE 'doc-head-close.inc' %]
13
[% INCLUDE 'doc-head-close.inc' %]
14
[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %]
14
[% BLOCK cssinclude %][% END %]
15
    [% BLOCK cssinclude %]
16
        [% Asset.css("css/jquery.rating.css") %]
17
    [% END %]
18
[% END %]
19
20
<link rel="alternate" type="application/rss+xml" title="[% LibraryName |html %] Search RSS feed" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi |uri %]&amp;count=[% countrss |uri %]&amp;sort_by=acqdate_dsc&amp;format=rss2" />
15
<link rel="alternate" type="application/rss+xml" title="[% LibraryName |html %] Search RSS feed" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi |uri %]&amp;count=[% countrss |uri %]&amp;sort_by=acqdate_dsc&amp;format=rss2" />
21
</head>
16
</head>
22
17
Lines 425-430 Link Here
425
                                                                <div class="star-rating rater-[% i %] star star-rating-applied star-rating-readonly"><a title="[% i %]">[% i %]</a></div>
420
                                                                <div class="star-rating rater-[% i %] star star-rating-applied star-rating-readonly"><a title="[% i %]">[% i %]</a></div>
426
                                                            [% END %]
421
                                                            [% END %]
427
                                                        [% END %]
422
                                                        [% END %]
423
428
                                                        <span id="babeltheque-rating_total_[% SEARCH_RESULT.biblionumber %]">&nbsp;&nbsp; [% SEARCH_RESULT.score_avg %] / 5 (on [% SEARCH_RESULT.num_scores %] rates)</span>
424
                                                        <span id="babeltheque-rating_total_[% SEARCH_RESULT.biblionumber %]">&nbsp;&nbsp; [% SEARCH_RESULT.score_avg %] / 5 (on [% SEARCH_RESULT.num_scores %] rates)</span>
429
425
430
                                                        [% IF ( SEARCH_RESULT.num_critics ) %]
426
                                                        [% IF ( SEARCH_RESULT.num_critics ) %]
Lines 482-496 Link Here
482
478
483
                                                [% IF ( OpacStarRatings == 'all' ) %]
479
                                                [% IF ( OpacStarRatings == 'all' ) %]
484
                                                    <div class="results_summary ratings">
480
                                                    <div class="results_summary ratings">
485
                                                      [% SET rating_avg = SEARCH_RESULT.ratings.get_avg_rating() %]
481
                                                        [% SET rating_avg = SEARCH_RESULT.ratings.get_avg_rating() %]
486
                                                      [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
482
                                                        [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
487
                                                        [% FOREACH i  IN [ 1 2 3 4 5  ] %]
483
                                                        <div class="br-wrapper br-theme-fontawesome-stars">
488
                                                            [% IF rating_avg_int == i %]
484
                                                            <div class="br-widget br-readonly">
489
                                                                <input class="star" type="radio"  name="rating-[% SEARCH_RESULT.biblionumber %]" value="[% i %]" checked="checked" disabled="disabled"   />
485
                                                                [% FOREACH i IN [ 1 2 3 4 5  ] %]
490
                                                            [% ELSE %]
486
                                                                    [% IF rating_avg_int == i %]
491
                                                                <input class="star" type="radio"  name="rating-[% SEARCH_RESULT.biblionumber %]" value="[% i %]" disabled="disabled"   />
487
                                                                        <a href="#" class="br-selected br-current"></a>
492
                                                            [% END %]
488
                                                                    [% ELSIF rating_avg_int > i %]
493
                                                        [% END %]
489
                                                                        <a href="#" class="br-selected"></a>
490
                                                                    [% ELSE %]
491
                                                                        <a href="#"></a>
492
                                                                    [% END %]
493
                                                                [% END %]
494
                                                            </div>
495
                                                        </div>
494
496
495
                                                        [% IF SEARCH_RESULT.ratings.count > 0  %]
497
                                                        [% IF SEARCH_RESULT.ratings.count > 0  %]
496
                                                            <span id="rating_total_[% SEARCH_RESULT.biblionumber %]">&nbsp;&nbsp;([% SEARCH_RESULT.ratings.count %] votes)</span>
498
                                                            <span id="rating_total_[% SEARCH_RESULT.biblionumber %]">&nbsp;&nbsp;([% SEARCH_RESULT.ratings.count %] votes)</span>
Lines 591-597 Link Here
591
[% IF ( LibraryThingForLibrariesID ) %]
593
[% IF ( LibraryThingForLibrariesID ) %]
592
    <script src="https://ltfl.librarything.com/forlibraries/widget.js?id=[% LibraryThingForLibrariesID %]&amp;systype=koha"></script>
594
    <script src="https://ltfl.librarything.com/forlibraries/widget.js?id=[% LibraryThingForLibrariesID %]&amp;systype=koha"></script>
593
[% END %]
595
[% END %]
594
[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") %][% END %]
596
[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") %][% END %]
595
[% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") %][% END %]
597
[% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") %][% END %]
596
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %]
598
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %]
597
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %]
599
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less (+71 lines)
Lines 2643-2648 a.reviewlink:visited { Link Here
2643
    }
2643
    }
2644
}
2644
}
2645
2645
2646
/* jQuery Bar Rating plugin for star ratings */
2647
2648
@star-default: #d2d2d2;
2649
@star-active: #C24A4A;
2650
@star-selected: #EDB867;
2651
2652
.br-wrapper {
2653
    display: inline-block;
2654
}
2655
2656
.br-theme-fontawesome-stars {
2657
2658
    .br-widget {
2659
        height: 28px;
2660
        white-space: nowrap;
2661
        a {
2662
            font: normal normal normal 20px/1 FontAwesome;
2663
            text-rendering: auto;
2664
            -webkit-font-smoothing: antialiased;
2665
            text-decoration: none;
2666
            margin-right: 2px;
2667
        }
2668
2669
        a:after {
2670
            content: '\f005';
2671
            color: @star-default;
2672
        }
2673
2674
        a.br-active:after {
2675
            color: @star-active;
2676
        }
2677
2678
        a.br-selected:after {
2679
            color: @star-selected;
2680
        }
2681
2682
        .br-current-rating {
2683
            display: none;
2684
        }
2685
    }
2686
2687
    .br-readonly {
2688
        a {
2689
            cursor: default;
2690
        }
2691
    }
2692
2693
}
2694
2695
#cancel_rating_text a {
2696
    color: #C24A4A;
2697
}
2698
2699
@media print {
2700
    .br-theme-fontawesome-stars {
2701
2702
        .br-widget {
2703
            a:after {
2704
                content: '\f006';
2705
                color: black;
2706
            }
2707
2708
            a.br-active:after,
2709
            a.br-selected:after {
2710
                content: '\f005';
2711
                color: black;
2712
            }
2713
        }
2714
2715
    }
2716
}
2646
2717
2647
2718
2648
@import "responsive.less";
2719
@import "responsive.less";
(-)a/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.rating.js (-392 lines)
Lines 1-392 Link Here
1
/*
2
 ### jQuery Star Rating Plugin v3.14 - 2012-01-26 ###
3
 * Home: http://www.fyneworks.com/jquery/star-rating/
4
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
5
 *
6
    * Dual licensed under the MIT and GPL licenses:
7
 *   http://www.opensource.org/licenses/mit-license.php
8
 *   http://www.gnu.org/licenses/gpl.html
9
 ###
10
*/
11
12
/*# AVOID COLLISIONS #*/
13
;if(window.jQuery) (function($){
14
/*# AVOID COLLISIONS #*/
15
16
    // IE6 Background Image Fix
17
    if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { };
18
    // Thanks to http://www.visualjquery.com/rating/rating_redux.html
19
20
    // plugin initialization
21
    $.fn.rating = function(options){
22
        if(this.length==0) return this; // quick fail
23
24
        // Handle API methods
25
        if(typeof arguments[0]=='string'){
26
            // Perform API methods on individual elements
27
            if(this.length>1){
28
                var args = arguments;
29
                return this.each(function(){
30
                    $.fn.rating.apply($(this), args);
31
    });
32
            };
33
            // Invoke API method handler
34
            $.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
35
            // Quick exit...
36
            return this;
37
        };
38
39
        // Initialize options for this call
40
        var options = $.extend(
41
            {}/* new object */,
42
            $.fn.rating.options/* default options */,
43
            options || {} /* just-in-time options */
44
        );
45
46
        // Allow multiple controls with the same name by making each call unique
47
        $.fn.rating.calls++;
48
49
        // loop through each matched element
50
        this
51
         .not('.star-rating-applied')
52
            .addClass('star-rating-applied')
53
        .each(function(){
54
55
            // Load control parameters / find context / etc
56
            var control, input = $(this);
57
            var eid = (this.name || 'unnamed-rating').replace(/\[|\]/g, '_').replace(/^\_+|\_+$/g,'');
58
            var context = $(this.form || document.body);
59
60
            // FIX: http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=23
61
            var raters = context.data('rating');
62
            if(!raters || raters.call!=$.fn.rating.calls) raters = { count:0, call:$.fn.rating.calls };
63
            var rater = raters[eid];
64
65
            // if rater is available, verify that the control still exists
66
            if(rater) control = rater.data('rating');
67
68
            if(rater && control)//{// save a byte!
69
                // add star to control if rater is available and the same control still exists
70
                control.count++;
71
72
            //}// save a byte!
73
            else{
74
                // create new control if first star or control element was removed/replaced
75
76
                // Initialize options for this rater
77
                control = $.extend(
78
                    {}/* new object */,
79
                    options || {} /* current call options */,
80
                    ($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */
81
                    { count:0, stars: [], inputs: [] }
82
                );
83
84
                // increment number of rating controls
85
                control.serial = raters.count++;
86
87
                // create rating element
88
                rater = $('<span class="star-rating-control"/>');
89
                input.before(rater);
90
91
                // Mark element for initialization (once all stars are ready)
92
                rater.addClass('rating-to-be-drawn');
93
94
                // Accept readOnly setting from 'disabled' property
95
                if(input.attr('disabled') || input.hasClass('disabled')) control.readOnly = true;
96
97
                // Accept required setting from class property (class='required')
98
                if(input.hasClass('required')) control.required = true;
99
100
                // Create 'cancel' button
101
                rater.append(
102
                    control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>')
103
                    .mouseover(function(){
104
                        $(this).rating('drain');
105
                        $(this).addClass('star-rating-hover');
106
                        //$(this).rating('focus');
107
                    })
108
                    .mouseout(function(){
109
                        $(this).rating('draw');
110
                        $(this).removeClass('star-rating-hover');
111
                        //$(this).rating('blur');
112
                    })
113
                    .click(function(){
114
                     $(this).rating('select');
115
                    })
116
                    .data('rating', control)
117
                );
118
119
            }; // first element of group
120
121
            // insert rating star
122
            var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="' + (this.title || this.value) + '">' + this.value + '</a></div>');
123
            rater.append(star);
124
125
            // inherit attributes from input element
126
            if(this.id) star.attr('id', this.id);
127
            if(this.className) star.addClass(this.className);
128
129
            // Half-stars?
130
            if(control.half) control.split = 2;
131
132
            // Prepare division control
133
            if(typeof control.split=='number' && control.split>0){
134
                var stw = ($.fn.width ? star.width() : 0) || control.starWidth;
135
                var spi = (control.count % control.split), spw = Math.floor(stw/control.split);
136
                star
137
                // restrict star's width and hide overflow (already in CSS)
138
                .width(spw)
139
                // move the star left by using a negative margin
140
                // this is work-around to IE's stupid box model (position:relative doesn't work)
141
                .find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })
142
            };
143
144
            // readOnly?
145
            if(control.readOnly)//{ //save a byte!
146
                // Mark star as readOnly so user can customize display
147
                star.addClass('star-rating-readonly');
148
            //}  //save a byte!
149
            else//{ //save a byte!
150
             // Enable hover css effects
151
                star.addClass('star-rating-live')
152
                 // Attach mouse events
153
                    .mouseover(function(){
154
                        $(this).rating('fill');
155
                        $(this).rating('focus');
156
                    })
157
                    .mouseout(function(){
158
                        $(this).rating('draw');
159
                        $(this).rating('blur');
160
                    })
161
                    .click(function(){
162
                        $(this).rating('select');
163
                    })
164
                ;
165
            //}; //save a byte!
166
167
            // set current selection
168
            if(this.checked)	control.current = star;
169
170
            // set current select for links
171
            if(this.nodeName=="A"){
172
    if($(this).hasClass('selected'))
173
     control.current = star;
174
   };
175
176
            // hide input element
177
            input.hide();
178
179
            // backward compatibility, form element to plugin
180
            input.change(function(){
181
    $(this).rating('select');
182
   });
183
184
            // attach reference to star to input element and vice-versa
185
            star.data('rating.input', input.data('rating.star', star));
186
187
            // store control information in form (or body when form not available)
188
            control.stars[control.stars.length] = star[0];
189
            control.inputs[control.inputs.length] = input[0];
190
            control.rater = raters[eid] = rater;
191
            control.context = context;
192
193
            input.data('rating', control);
194
            rater.data('rating', control);
195
            star.data('rating', control);
196
            context.data('rating', raters);
197
  }); // each element
198
199
        // Initialize ratings (first draw)
200
        $('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');
201
202
        return this; // don't break the chain...
203
    };
204
205
    /*--------------------------------------------------------*/
206
207
    /*
208
        ### Core functionality and API ###
209
    */
210
    $.extend($.fn.rating, {
211
        // Used to append a unique serial number to internal control ID
212
        // each time the plugin is invoked so same name controls can co-exist
213
        calls: 0,
214
215
        focus: function(){
216
            var control = this.data('rating'); if(!control) return this;
217
            if(!control.focus) return this; // quick fail if not required
218
            // find data for event
219
            var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
220
   // focus handler, as requested by focusdigital.co.uk
221
            if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
222
        }, // $.fn.rating.focus
223
224
        blur: function(){
225
            var control = this.data('rating'); if(!control) return this;
226
            if(!control.blur) return this; // quick fail if not required
227
            // find data for event
228
            var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
229
   // blur handler, as requested by focusdigital.co.uk
230
            if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
231
        }, // $.fn.rating.blur
232
233
        fill: function(){ // fill to the current mouse position.
234
            var control = this.data('rating'); if(!control) return this;
235
            // do not execute when control is in read-only mode
236
            if(control.readOnly) return;
237
            // Reset all stars and highlight them up to this element
238
            this.rating('drain');
239
            this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');
240
        },// $.fn.rating.fill
241
242
        drain: function() { // drain all the stars.
243
            var control = this.data('rating'); if(!control) return this;
244
            // do not execute when control is in read-only mode
245
            if(control.readOnly) return;
246
            // Reset all stars
247
            control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');
248
        },// $.fn.rating.drain
249
250
        draw: function(){ // set value and stars to reflect current selection
251
            var control = this.data('rating'); if(!control) return this;
252
            // Clear all stars
253
            this.rating('drain');
254
            // Set control value
255
            if(control.current){
256
                control.current.data('rating.input').attr('checked','checked');
257
                control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on');
258
            }
259
            else
260
             $(control.inputs).removeAttr('checked');
261
            // Show/hide 'cancel' button
262
            control.cancel[control.readOnly || control.required?'hide':'show']();
263
            // Add/remove read-only classes to remove hand pointer
264
            this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');
265
        },// $.fn.rating.draw
266
267
268
269
270
271
        select: function(value,wantCallBack){ // select a value
272
273
                    // ***** MODIFICATION *****
274
                    // Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27
275
                    //
276
                    // ***** LIST OF MODIFICATION *****
277
                    // ***** added Parameter wantCallBack : false if you don't want a callback. true or undefined if you want postback to be performed at the end of this method'
278
                    // ***** recursive calls to this method were like : ... .rating('select') it's now like .rating('select',undefined,wantCallBack); (parameters are set.)
279
                    // ***** line which is calling callback
280
                    // ***** /LIST OF MODIFICATION *****
281
282
            var control = this.data('rating'); if(!control) return this;
283
            // do not execute when control is in read-only mode
284
            if(control.readOnly) return;
285
            // clear selection
286
            control.current = null;
287
            // programmatically (based on user input)
288
            if(typeof value!='undefined'){
289
             // select by index (0 based)
290
                if(typeof value=='number')
291
			 return $(control.stars[value]).rating('select',undefined,wantCallBack);
292
                // select by literal value (must be passed as a string
293
                if(typeof value=='string')
294
                    //return
295
                    $.each(control.stars, function(){
296
                        if($(this).data('rating.input').val()==value) $(this).rating('select',undefined,wantCallBack);
297
                    });
298
            }
299
            else
300
                control.current = this[0].tagName=='INPUT' ?
301
                 this.data('rating.star') :
302
                    (this.is('.rater-'+ control.serial) ? this : null);
303
304
            // Update rating control state
305
            this.data('rating', control);
306
            // Update display
307
            this.rating('draw');
308
            // find data for event
309
            var input = $( control.current ? control.current.data('rating.input') : null );
310
            // click callback, as requested here: http://plugins.jquery.com/node/1655
311
312
                    // **** MODIFICATION *****
313
                    // Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27
314
                    //
315
                    //old line doing the callback :
316
                    //if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event
317
                    //
318
                    //new line doing the callback (if i want :)
319
                    if((wantCallBack ||wantCallBack == undefined) && control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event
320
                    //to ensure retro-compatibility, wantCallBack must be considered as true by default
321
                    // **** /MODIFICATION *****
322
323
  },// $.fn.rating.select
324
325
326
327
328
329
        readOnly: function(toggle, disable){ // make the control read-only (still submits value)
330
            var control = this.data('rating'); if(!control) return this;
331
            // setread-only status
332
            control.readOnly = toggle || toggle==undefined ? true : false;
333
            // enable/disable control value submission
334
            if(disable) $(control.inputs).attr("disabled", "disabled");
335
            else     			$(control.inputs).removeAttr("disabled");
336
            // Update rating control state
337
            this.data('rating', control);
338
            // Update display
339
            this.rating('draw');
340
        },// $.fn.rating.readOnly
341
342
        disable: function(){ // make read-only and never submit value
343
            this.rating('readOnly', true, true);
344
        },// $.fn.rating.disable
345
346
        enable: function(){ // make read/write and submit value
347
            this.rating('readOnly', false, false);
348
        }// $.fn.rating.select
349
350
 });
351
352
    /*--------------------------------------------------------*/
353
354
    /*
355
        ### Default Settings ###
356
        eg.: You can override default control like this:
357
        $.fn.rating.options.cancel = 'Clear';
358
    */
359
    $.fn.rating.options = { //$.extend($.fn.rating, { options: {
360
            cancel: 'Cancel Rating',   // advisory title for the 'cancel' link
361
            cancelValue: '',           // value to submit when user click the 'cancel' link
362
            split: 0,                  // split the star into how many parts?
363
364
            // Width of star image in case the plugin can't work it out. This can happen if
365
            // the jQuery.dimensions plugin is not available OR the image is hidden at installation
366
            starWidth: 16//,
367
368
            //NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!
369
            //half:     false,         // just a shortcut to control.split = 2
370
            //required: false,         // disables the 'cancel' button so user can only select one of the specified values
371
            //readOnly: false,         // disable rating plugin interaction/ values cannot be changed
372
            //focus:    function(){},  // executed when stars are focused
373
            //blur:     function(){},  // executed when stars are focused
374
            //callback: function(){},  // executed when a star is clicked
375
 }; //} });
376
377
    /*--------------------------------------------------------*/
378
379
    /*
380
        ### Default implementation ###
381
        The plugin will attach itself to file inputs
382
        with the class 'multi' when the page loads
383
    */
384
    $(function(){
385
     $('input[type=radio].star').rating();
386
    });
387
388
389
390
/*# AVOID COLLISIONS #*/
391
})(jQuery);
392
/*# AVOID COLLISIONS #*/
(-)a/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.barrating.min.js (-1 / +2 lines)
Line 0 Link Here
0
- 
1
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=function(){function e(){var e=this,n=function(){var n=["br-wrapper"];""!==e.options.theme&&n.push("br-theme-"+e.options.theme),e.$elem.wrap(t("<div />",{"class":n.join(" ")}))},i=function(){e.$elem.unwrap()},a=function(n){return t.isNumeric(n)&&(n=Math.floor(n)),t('option[value="'+n+'"]',e.$elem)},r=function(){var n=e.options.initialRating;return n?a(n):t("option:selected",e.$elem)},o=function(){var n=e.$elem.find('option[value="'+e.options.emptyValue+'"]');return!n.length&&e.options.allowEmpty?(n=t("<option />",{value:e.options.emptyValue}),n.prependTo(e.$elem)):n},l=function(t){var n=e.$elem.data("barrating");return"undefined"!=typeof t?n[t]:n},s=function(t,n){null!==n&&"object"==typeof n?e.$elem.data("barrating",n):e.$elem.data("barrating")[t]=n},u=function(){var t=r(),n=o(),i=t.val(),a=t.data("html")?t.data("html"):t.text(),l=null!==e.options.allowEmpty?e.options.allowEmpty:!!n.length,u=n.length?n.val():null,d=n.length?n.text():null;s(null,{userOptions:e.options,ratingValue:i,ratingText:a,originalRatingValue:i,originalRatingText:a,allowEmpty:l,emptyRatingValue:u,emptyRatingText:d,readOnly:e.options.readonly,ratingMade:!1})},d=function(){e.$elem.removeData("barrating")},c=function(){return l("ratingText")},f=function(){return l("ratingValue")},g=function(){var n=t("<div />",{"class":"br-widget"});return e.$elem.find("option").each(function(){var i,a,r,o;i=t(this).val(),i!==l("emptyRatingValue")&&(a=t(this).text(),r=t(this).data("html"),r&&(a=r),o=t("<a />",{href:"#","data-rating-value":i,"data-rating-text":a,html:e.options.showValues?a:""}),n.append(o))}),e.options.showSelectedRating&&n.append(t("<div />",{text:"","class":"br-current-rating"})),e.options.reverse&&n.addClass("br-reverse"),e.options.readonly&&n.addClass("br-readonly"),n},p=function(){return l("userOptions").reverse?"nextAll":"prevAll"},h=function(t){a(t).prop("selected",!0),e.$elem.change()},m=function(){t("option",e.$elem).prop("selected",function(){return this.defaultSelected}),e.$elem.change()},v=function(t){t=t?t:c(),t==l("emptyRatingText")&&(t=""),e.options.showSelectedRating&&e.$elem.parent().find(".br-current-rating").text(t)},y=function(t){return Math.round(Math.floor(10*t)/10%1*100)},b=function(){e.$widget.find("a").removeClass(function(t,e){return(e.match(/(^|\s)br-\S+/g)||[]).join(" ")})},w=function(){var n,i,a=e.$widget.find('a[data-rating-value="'+f()+'"]'),r=l("userOptions").initialRating,o=t.isNumeric(f())?f():0,s=y(r);if(b(),a.addClass("br-selected br-current")[p()]().addClass("br-selected"),!l("ratingMade")&&t.isNumeric(r)){if(o>=r||!s)return;n=e.$widget.find("a"),i=a.length?a[l("userOptions").reverse?"prev":"next"]():n[l("userOptions").reverse?"last":"first"](),i.addClass("br-fractional"),i.addClass("br-fractional-"+s)}},$=function(t){return l("allowEmpty")&&l("userOptions").deselectable?f()==t.attr("data-rating-value"):!1},x=function(n){n.on("click.barrating",function(n){var i,a,r=t(this),o=l("userOptions");return n.preventDefault(),i=r.attr("data-rating-value"),a=r.attr("data-rating-text"),$(r)&&(i=l("emptyRatingValue"),a=l("emptyRatingText")),s("ratingValue",i),s("ratingText",a),s("ratingMade",!0),h(i),v(a),w(),o.onSelect.call(e,f(),c(),n),!1})},R=function(e){e.on("mouseenter.barrating",function(){var e=t(this);b(),e.addClass("br-active")[p()]().addClass("br-active"),v(e.attr("data-rating-text"))})},V=function(t){e.$widget.on("mouseleave.barrating blur.barrating",function(){v(),w()})},O=function(e){e.on("touchstart.barrating",function(e){e.preventDefault(),e.stopPropagation(),t(this).click()})},C=function(t){t.on("click.barrating",function(t){t.preventDefault()})},S=function(t){x(t),e.options.hoverState&&(R(t),V(t))},T=function(t){t.off(".barrating")},j=function(t){var n=e.$widget.find("a");O&&O(n),t?(T(n),C(n)):S(n)};this.show=function(){l()||(n(),u(),e.$widget=g(),e.$widget.insertAfter(e.$elem),w(),v(),j(e.options.readonly),e.$elem.hide())},this.readonly=function(t){"boolean"==typeof t&&l("readOnly")!=t&&(j(t),s("readOnly",t),e.$widget.toggleClass("br-readonly"))},this.set=function(t){var n=l("userOptions");0!==e.$elem.find('option[value="'+t+'"]').length&&(s("ratingValue",t),s("ratingText",e.$elem.find('option[value="'+t+'"]').text()),s("ratingMade",!0),h(f()),v(c()),w(),n.silent||n.onSelect.call(this,f(),c()))},this.clear=function(){var t=l("userOptions");s("ratingValue",l("originalRatingValue")),s("ratingText",l("originalRatingText")),s("ratingMade",!1),m(),v(c()),w(),t.onClear.call(this,f(),c())},this.destroy=function(){var t=f(),n=c(),a=l("userOptions");T(e.$widget.find("a")),e.$widget.remove(),d(),i(),e.$elem.show(),a.onDestroy.call(this,t,n)}}return e.prototype.init=function(e,n){return this.$elem=t(n),this.options=t.extend({},t.fn.barrating.defaults,e),this.options},e}();t.fn.barrating=function(n,i){return this.each(function(){var a=new e;if(t(this).is("select")||t.error("Sorry, this plugin only works with select fields."),a.hasOwnProperty(n)){if(a.init(i,this),"show"===n)return a.show(i);if(a.$elem.data("barrating"))return a.$widget=t(this).next(".br-widget"),a[n](i)}else{if("object"==typeof n||!n)return i=n,a.init(i,this),a.show();t.error("Method "+n+" does not exist on jQuery.barrating")}})},t.fn.barrating.defaults={theme:"",initialRating:null,allowEmpty:null,emptyValue:"",showValues:!1,showSelectedRating:!0,deselectable:!0,reverse:!1,readonly:!1,fastClicks:!0,hoverState:!0,silent:!1,onSelect:function(t,e,n){},onClear:function(t,e){},onDestroy:function(t,e){}},t.fn.barrating.BarRating=e});
2
//# sourceMappingURL=jquery.barrating.min.js.map

Return to bug 10659