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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-3 / +3 lines)
Lines 980-989 Link Here
980
                    </li>
980
                    </li>
981
                </ul>
981
                </ul>
982
982
983
            <h2>jQuery Star Rating Plugin</h2>
983
            <h2>jQuery Bar Rating Plugin</h2>
984
              <p>jQuery Star Rating Plugin v3.14 by <a href="http://www.fyneworks.com/">Fyneworks.com</a> is licensed under the <a href="http://en.wikipedia.org/wiki/MIT_License">MIT License</a> and the <a href="http://creativecommons.org/licenses/GPL/2.0/">GPL License</a>.</p>
984
              <p>jQuery Bar Rating Plugin v1.22 by <a href="http://antenna.io/demo/jquery-bar-rating/examples/">Antenna.io</a> is licensed under the <a href="http://en.wikipedia.org/wiki/MIT_License">MIT License</a>.</p>
985
985
986
            <p>Copyright &copy; 2008 <a href="http://www.fyneworks.com/">Fyneworks.com</a></p>
986
            <p>Copyright &copy; 2012-2016 <a href="http://antenna.io">Kazik Pietruszewski</a></p>
987
987
988
            <h2>jQuery insertAtCaret Plugin</h2>
988
            <h2>jQuery insertAtCaret Plugin</h2>
989
            <p>jQuery insertAtCaret Plugin v1.0 by the phpMyAdmin devel team is licensed under the <a href="http://www.gnu.org/licenses/gpl.html">GPL License</a>.</p>
989
            <p>jQuery insertAtCaret Plugin v1.0 by the phpMyAdmin devel team is licensed under the <a href="http://www.gnu.org/licenses/gpl.html">GPL License</a>.</p>
(-)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/css/src/opac.scss (+86 lines)
Lines 3252-3255 button.closebtn { Link Here
3252
    max-height: 200px;
3252
    max-height: 200px;
3253
}
3253
}
3254
3254
3255
/* jQuery Bar Rating plugin for star ratings */
3256
3257
$star-default: #D2D2D2;
3258
$star-active: #C24A4A;
3259
$star-selected: #EDB867;
3260
3261
.br-wrapper {
3262
    display: inline-block;
3263
}
3264
3265
.br-theme-fontawesome-stars {
3266
3267
    .br-widget {
3268
        height: 28px;
3269
        white-space: nowrap;
3270
3271
        a {
3272
            -webkit-font-smoothing: antialiased;
3273
            font: normal normal normal 20px/1 FontAwesome;
3274
            margin-right: 2px;
3275
            text-decoration: none;
3276
            text-rendering: auto;
3277
3278
            &::after {
3279
                color: $star-default;
3280
                content: "\f005";
3281
            }
3282
3283
            &.br-active {
3284
                &::after {
3285
                    color: $star-active;
3286
                }
3287
            }
3288
3289
            &.br-selected {
3290
                &::after {
3291
                    color: $star-selected;
3292
                }
3293
            }
3294
        }
3295
3296
3297
        .br-current-rating {
3298
            display: none;
3299
        }
3300
    }
3301
3302
    .br-readonly {
3303
        a {
3304
            cursor: default;
3305
        }
3306
    }
3307
3308
}
3309
3310
#cancel_rating_text {
3311
    a {
3312
        color: #C24A4A;
3313
    }
3314
}
3315
3316
@media print {
3317
    .br-theme-fontawesome-stars {
3318
3319
        .br-widget {
3320
            a {
3321
                &::after {
3322
                    color: #000000;
3323
                    content: "\f006";
3324
                }
3325
3326
                &.br-active::after,
3327
                &.br-selected::after {
3328
                    color: #000000;
3329
                    content: "\f005";
3330
                }
3331
            }
3332
3333
        }
3334
3335
    }
3336
}
3337
3338
/* END jQuery Bar Rating plugin for star ratings */
3339
3340
3255
@import "responsive";
3341
@import "responsive";
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-53 / +49 lines)
Lines 32-46 Link Here
32
[% INCLUDE 'doc-head-open.inc' %]
32
[% INCLUDE 'doc-head-open.inc' %]
33
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Details for: [% title | html %][% FOREACH subtitl IN subtitle %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %] [% subtitl.subfield | html %][% END %]</title>
33
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Details for: [% title | html %][% FOREACH subtitl IN subtitle %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %] [% subtitl.subfield | html %][% END %]</title>
34
[% INCLUDE 'doc-head-close.inc' %]
34
[% INCLUDE 'doc-head-close.inc' %]
35
[% IF ( bidi ) %]
36
  [% BLOCK cssinclude %][% Asset.css("css/right-to-left.css") | $raw %][% END %]
37
[% END %]
38
[% IF ( OpacStarRatings != 'disable' ) %]
39
    [% BLOCK cssinclude %][% Asset.css("css/jquery.rating.css") | $raw %][% END %]
40
[% END %]
41
[% INCLUDE greybox.inc %]
42
    [% Asset.css("lib/emoji-picker/css/emoji.css") | $raw %]
35
    [% Asset.css("lib/emoji-picker/css/emoji.css") | $raw %]
43
</head>
36
</head>
37
[% BLOCK cssinclude %][% END %]
44
[% INCLUDE 'bodytag.inc' bodyid='opac-detail' bodyclass='scrollto' %]
38
[% INCLUDE 'bodytag.inc' bodyid='opac-detail' bodyclass='scrollto' %]
45
[% INCLUDE 'masthead.inc' %]
39
[% INCLUDE 'masthead.inc' %]
46
40
Lines 477-493 Link Here
477
471
478
                                [% SET rating_avg = ratings.get_avg_rating() %]
472
                                [% SET rating_avg = ratings.get_avg_rating() %]
479
                                [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
473
                                [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
480
                                [% FOREACH i  IN [ 1 2 3 4 5  ] %]
474
481
                                    [% IF rating_avg_int == i && borrowernumber %]
475
                                [% IF ( borrowernumber ) %]
482
                                        <input class="auto-submit-star" type="radio" name="rating"  value="[% i | html %]"  checked="checked" />
476
                                    <select id="star_rating" name="rating" data-rating-enabled="1" autocomplete="off">
483
                                    [% ELSIF rating_avg_int == i %]
477
                                [% ELSE %]
484
                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i | html %]" checked="checked" disabled="disabled" />
478
                                    <select id="star_rating" name="rating" data-rating-enabled="0" disabled="disabled" autocomplete="off">
485
                                    [% ELSIF borrowernumber  %]
486
                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i | html %]" />
487
                                    [% ELSE   %]
488
                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i | html %]" disabled="disabled" />
489
                                    [% END %]
490
                                [% END %]
479
                                [% END %]
480
                                    [% FOREACH i IN [ 1 2 3 4 5  ] %]
481
                                        [% IF rating_avg_int == i %]
482
                                            <option value="[% i | html %]" selected="selected">[% i | html %]</option>
483
                                        [% ELSE %]
484
                                            <option value"[% i | html %]">[% i | html %]</option>
485
                                        [% END %]
486
                                    [% END %]
487
                                </select>
488
                                <img id="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" />
491
489
492
                                <!-- define some hidden vars for ratings -->
490
                                <!-- define some hidden vars for ratings -->
493
491
Lines 497-508 Link Here
497
                                [% UNLESS ( rating_readonly ) %]&nbsp;  <input name="rate_button" type="submit" value="Rate me" />[% END %]&nbsp;
495
                                [% UNLESS ( rating_readonly ) %]&nbsp;  <input name="rate_button" type="submit" value="Rate me" />[% END %]&nbsp;
498
496
499
                                [% IF my_rating %]
497
                                [% IF my_rating %]
500
                                    <span id="rating_value_text">your rating: [% my_rating.rating_value | html %], </span>
498
                                    <span id="rating_value_text">Your rating: [% my_rating.rating_value | html %].</span>
499
                                    <span id="cancel_rating_text"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
501
                                [% ELSE %]
500
                                [% ELSE %]
502
                                    <span id="rating_value_text"></span>
501
                                    <span id="rating_value_text"></span>
502
                                    <span id="cancel_rating_text" style="display:none;"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
503
                                [% END %]
503
                                [% END %]
504
504
505
                                <span id="rating_text">average rating: [% rating_avg | html %] ([% ratings.count | html %] votes)</span>
505
                                <span id="rating_text">Average rating: [% rating_avg | html %] ([% ratings.count | html %] votes)</span>
506
                            </div>
506
                            </div>
507
                        </form>
507
                        </form>
508
                    [% END # / IF OpacStarRatings != 'disable' %]
508
                    [% END # / IF OpacStarRatings != 'disable' %]
Lines 1379-1384 Link Here
1379
[% BLOCK jsinclude %]
1379
[% BLOCK jsinclude %]
1380
[% INCLUDE 'datatables.inc' %]
1380
[% INCLUDE 'datatables.inc' %]
1381
[% INCLUDE 'columns_settings.inc' %]
1381
[% INCLUDE 'columns_settings.inc' %]
1382
[% INCLUDE greybox.inc %]
1382
[% IF ( SocialNetworks ) %]
1383
[% IF ( SocialNetworks ) %]
1383
    //<![CDATA[
1384
    //<![CDATA[
1384
      {lang: '[% lang | html %]'}
1385
      {lang: '[% lang | html %]'}
Lines 1386-1392 Link Here
1386
    </script>
1387
    </script>
1387
    <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>
1388
    <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>
1388
[% END %]
1389
[% END %]
1389
[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") | $raw %][% END %]
1390
[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %][% END %]
1390
1391
1391
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %]
1392
[% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %]
1392
1393
Lines 1618-1663 Link Here
1618
1619
1619
    $('input[name="rate_button"]').remove();
1620
    $('input[name="rate_button"]').remove();
1620
1621
1621
    $(function () {
1622
    var rating_enabled = ( $("#star_rating").data("rating-enabled") == "1" ) ? false : true;
1622
      $(".auto-submit-star").rating({
1623
    $('#star_rating').barrating({
1623
        cancel: _("Cancel rating"),
1624
        theme: 'fontawesome-stars',
1624
        callback: function (value, link) {
1625
        showSelectedRating: false,
1625
1626
        allowEmpty: true,
1626
          // if the new value equals the old value, dont execute callback...
1627
        deselectable: false,
1627
          // just do nothing!
1628
        readonly: rating_enabled,
1628
          if ($("#rating_value").attr("value") != value) {
1629
        onSelect: function(value, text) {
1629
1630
            $("#rating-loading").show();
1630
            $(function () {
1631
            $.post("/cgi-bin/koha/opac-ratings-ajax.pl", {
1631
1632
              $.post("/cgi-bin/koha/opac-ratings-ajax.pl", {
1633
                rating_old_value: $("#rating_value").attr("value"),
1632
                rating_old_value: $("#rating_value").attr("value"),
1634
                borrowernumber: "[% borrowernumber | html %]",
1633
                borrowernumber: "[% borrowernumber | html %]",
1635
                biblionumber: "[% biblio.biblionumber | html %]",
1634
                biblionumber: "[% biblio.biblionumber | html %]",
1636
                rating_value: value,
1635
                rating_value: value,
1637
                auth_error: value
1636
                auth_error: value
1638
              }, function (data) {
1637
            }, function (data) {
1639
1638
                    $("#rating_value").val(data.rating_value);
1640
                if (data.auth_status != 'ok') {
1639
                    if (data.rating_value) {
1641
                  window.alert(_("Your CGI session cookie is not current. Please refresh the page and try again."));
1640
                        $("#rating_value_text").text(_("Your rating: %s, ").format(data.rating_value));
1642
                } else {
1641
                        $("#cancel_rating_text").show();
1643
                  $("#rating_value").val(data.rating_value);
1642
                    } else {
1644
1643
                        $("#rating_value_text").text('');
1645
                  if (data.rating_value) {
1644
                        $("#cancel_rating_text").hide();
1646
                    $("#rating_value_text").text(_("your rating: %s, ").format(data.rating_value));
1645
                    }
1647
                  } else {
1646
                    $("#rating_text").text(_("Average rating: %s (%s votes)").format(data.rating_avg, data.rating_total));
1648
                    $("#rating_value_text").text('');
1647
                    $("#rating-loading").hide();
1649
                  }
1648
            }, "json");
1650
1651
                  $("#rating_text").text(_("average rating: %s (%s votes)").format(data.rating_avg, data.rating_total));
1652
1653
                }
1654
              }, "json");
1655
            });
1656
          };
1657
        }
1649
        }
1658
      });
1659
    });
1650
    });
1660
    // -----------------------------------------------------
1651
1652
    $("#cancel_rating_text a").on("click", function(e){
1653
        e.preventDefault();
1654
        $("#star_rating").barrating("set", "");
1655
    });
1656
1661
[% END # / IF ( OpacStarRatings != 'disable' )%]
1657
[% END # / IF ( OpacStarRatings != 'disable' )%]
1662
1658
1663
[% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %]
1659
[% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (-15 / +16 lines)
Lines 18-32 Link Here
18
    You did not specify any search criteria.
18
    You did not specify any search criteria.
19
[% END %]</title>
19
[% END %]</title>
20
[% INCLUDE 'doc-head-close.inc' %]
20
[% INCLUDE 'doc-head-close.inc' %]
21
[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %]
22
    [% BLOCK cssinclude %]
23
        [% Asset.css("css/jquery.rating.css") | $raw %]
24
    [% END %]
25
[% END %]
26
21
27
<link rel="alternate" type="application/rss+xml" title="[% LibraryName | html %] Search RSS feed" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;count=[% countrss |uri %]&amp;sort_by=acqdate_dsc&amp;format=rss2" />
22
<link rel="alternate" type="application/rss+xml" title="[% LibraryName | html %] Search RSS feed" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;count=[% countrss |uri %]&amp;sort_by=acqdate_dsc&amp;format=rss2" />
28
</head>
23
</head>
29
24
[% BLOCK cssinclude %][% END %]
30
[% INCLUDE 'bodytag.inc' bodyid='results' bodyclass='scrollto' %]
25
[% INCLUDE 'bodytag.inc' bodyid='results' bodyclass='scrollto' %]
31
[% INCLUDE 'masthead.inc' %]
26
[% INCLUDE 'masthead.inc' %]
32
27
Lines 503-517 Link Here
503
498
504
                                                [% IF ( OpacStarRatings == 'all' ) %]
499
                                                [% IF ( OpacStarRatings == 'all' ) %]
505
                                                    <div class="results_summary ratings">
500
                                                    <div class="results_summary ratings">
506
                                                      [% SET rating_avg = SEARCH_RESULT.ratings.get_avg_rating() %]
501
                                                        [% SET rating_avg = SEARCH_RESULT.ratings.get_avg_rating() %]
507
                                                      [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
502
                                                        [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
508
                                                        [% FOREACH i  IN [ 1 2 3 4 5  ] %]
503
                                                        <div class="br-wrapper br-theme-fontawesome-stars">
509
                                                            [% IF rating_avg_int == i %]
504
                                                            <div class="br-widget br-readonly">
510
                                                                <input class="star" type="radio"  name="rating-[% SEARCH_RESULT.biblionumber | html %]" value="[% i | html %]" checked="checked" disabled="disabled"   />
505
                                                                [% FOREACH i IN [ 1 2 3 4 5  ] %]
511
                                                            [% ELSE %]
506
                                                                    [% IF rating_avg_int == i %]
512
                                                                <input class="star" type="radio"  name="rating-[% SEARCH_RESULT.biblionumber | html %]" value="[% i | html %]" disabled="disabled"   />
507
                                                                        <a href="#" class="br-selected br-current"></a>
513
                                                            [% END %]
508
                                                                    [% ELSIF rating_avg_int > i %]
514
                                                        [% END %]
509
                                                                        <a href="#" class="br-selected"></a>
510
                                                                    [% ELSE %]
511
                                                                        <a href="#"></a>
512
                                                                    [% END %]
513
                                                                [% END %]
514
                                                            </div>
515
                                                        </div>
515
516
516
                                                        [% IF SEARCH_RESULT.ratings.count > 0  %]
517
                                                        [% IF SEARCH_RESULT.ratings.count > 0  %]
517
                                                            <span id="rating_total_[% SEARCH_RESULT.biblionumber | html %]">&nbsp;&nbsp;([% SEARCH_RESULT.ratings.count | html %] votes)</span>
518
                                                            <span id="rating_total_[% SEARCH_RESULT.biblionumber | html %]">&nbsp;&nbsp;([% SEARCH_RESULT.ratings.count | html %] votes)</span>
(-)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