PageSourceSearch

https://www.su-usedbook.com/assets/js/jquery.artarax.rating.star.js

js su-usedbook.com collected 2026-10-02 19:10:09 UTC 2,870 bytes, 84 lines download raw bytes

1/*  ---------------------------------------------------------------------
2    ----------------------- ARTARAX RATING STAR ---------------------------- 
3    -----------------------   Version 0.1    ---------------------------- 
4    ---------------- copyright 2018 by http://artarax.com ---------------
5    ---------------------------------------------------------------------
6    options:
7    {
8        onClickCallBack: 
9            callback function that can get selected star value and id (data-id attribute) as a param
10    }
11
12    methods:
13        1) highlightRating(3.9) : highligh stars on page load
14/*  --------------------------------------------------------------------- */
15(function ($) {
16
17    $.artaraxRatingStar = function (options) {
18
19        // ======================================== plugin definition ========================================
20        var defaults = {
21            onClickCallBack: null,
22        };
23
24        var settings = $.extend({}, defaults, options);
25
26        var onClickCallBack = settings.onClickCallBack;
27
28        // =============================================== main ===============================================
29        // -------------------------- events --------------------------
30        // hover
31        $(".rating-star span").hover(function () {
32            var hoverValue = parseInt($(this).attr('data-val'));
33            highlightStars(hoverValue, 'hover');
34        });
35
36        // mouseout
37        $(".rating-star span").mouseout(function () {
38            $(".rating-star span").each(function () {
39                $(this).removeClass("hover");
40            });
41        });
42
43        // click
44        $(".rating-star span").click(function () {
45            if (onClickCallBack != null) {
46                var rate = parseInt($(this).attr('data-val'));
47                var id = parseInt($(this).attr('data-id'));
48                highlightStars(rate, 'clicked');
49                onClickCallBack(rate, id);
50            }
51        });
52
53        // -------------------------- private functions --------------------------
54        function highlightStars(count, cssClass) {
55            var itemValue = 0;
56            $(".rating-star span").each(function () {
57                itemValue = parseInt($(this).attr('data-val'));
58                if (itemValue <= count) {
59                    $(this).addClass(cssClass);
60                }
61                else {
62                    $(this).removeClass(cssClass);
63                }
64            });
65        }
66
67
68
69        function highlightRating(rate) {
70            var roundedRate = Math.round(rate);
71            highlightStars(roundedRate, 'clicked');
72        }
73
74
75
76        // -------------------- public methods ------------------------
77        return {
78            highlightRatingStars: function (rate) {
79                highlightRating(rate);
80            }
81        }
82
83    }    
84}(jQuery));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.