PageSourceSearch

https://www.pinglighting.com/modules/ets_reviews/views/js/jquery.rating.plugin.js

js pinglighting.com collected 2026-10-06 18:27:38 UTC 8,104 bytes, 153 lines download raw bytes

1/**
2  * Copyright ETS Software Technology Co., Ltd
3 *
4 * NOTICE OF LICENSE
5 *
6 * This file is not open source! Each license that you purchased is only available for 1 website only.
7 * If you want to use this file on more websites (or projects), you need to purchase additional licenses.
8 * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
9 *
10 * DISCLAIMER
11 *
12 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
13 * versions in the future.
14 *
15 * @author ETS Software Technology Co., Ltd
16 * @copyright  ETS Software Technology Co., Ltd
17 * @license    Valid for 1 website (or project) for each purchase of license
18 */
19
20jQuery.fn.etsRating = function (generalOptions) {
21    const $ratings = $(this);
22
23    $ratings.each(function initRating() {
24        const $ratingComponent = $(this);
25        var options = generalOptions ? generalOptions : {};
26        if (typeof options.grade === "undefined" && $ratingComponent.data('grade')) {
27            options.grade = $ratingComponent.data('grade');
28        }
29        if (!options.min && $ratingComponent.data('min')) {
30            options.min = $ratingComponent.data('min');
31        }
32        if (!options.max && $ratingComponent.data('max')) {
33            options.max = $ratingComponent.data('max');
34        }
35        if (!options.input && $ratingComponent.data('input')) {
36            options.input = $ratingComponent.data('input');
37        }
38        var componentOptions = jQuery.extend({
39            grade: null,
40            input: null,
41            min: 0,
42            max: 5,
43            starWidth: 20
44        }, options);
45
46        const minValue = Math.min(componentOptions.min, componentOptions.max);
47        const maxValue = Math.max(componentOptions.min, componentOptions.max);
48        const ratingValue = Math.min(Math.max(minValue, componentOptions.grade), maxValue);
49
50        $ratingComponent.html('');
51        $ratingComponent.append('<div class="ets-rv-star-content ets-rv-star-empty clearfix"></div>');
52        $ratingComponent.append('<div class="ets-rv-star-content ets-rv-star-full clearfix"></div>');
53
54        const emptyStars = $('.ets-rv-star-empty', this);
55        const fullStars = $('.ets-rv-star-full', this);
56        const emptyStar = $('<div class="star color1"><svg class="star_empty" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z"/></svg><svg class="star_full" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1728 647q0 22-26 48l-363 354 86 500q1 7 1 20 0 21-10.5 35.5t-30.5 14.5q-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z"/></svg></div>');
57        const fullStar = $('<div class="ets-rv-star-on"><svg class="star_empty" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z"/></svg><svg class="star_full" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1728 647q0 22-26 48l-363 354 86 500q1 7 1 20 0 21-10.5 35.5t-30.5 14.5q-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z"/></svg></div>');
58
59        var ratingInput;
60        if (componentOptions.input) {
61            ratingInput = $('<input type="number" name="' + componentOptions.input + '" id="' + componentOptions.input + '" />');
62            ratingInput.val(ratingValue);
63            ratingInput.css('display', 'none');
64            ratingInput.change(displayInteractiveGrade);
65            $ratingComponent.append(ratingInput);
66            initInteractiveGrade();
67        } else {
68            displayGrade(ratingValue);
69        }
70
71        function initInteractiveGrade() {
72            emptyStars.html('');
73            fullStars.html('');
74            var newStar;
75            for (var i = minValue; i < maxValue; ++i) {
76                newStar = emptyStar.clone();
77                newStar.data('grade', i + 1);
78                newStar.hover(function overStar() {
79                    var overIndex = $('.star', fullStars).index($(this));
80                    $('.star', fullStars).each(function overStars() {
81                        $(this).removeClass('ets-rv-star-on');
82                        var starIndex = $('.star', fullStars).index($(this));
83                        if (starIndex <= overIndex) {
84                            $(this).addClass('star-hover');
85                        } else {
86                            $(this).removeClass('star-hover');
87                        }
88                    });
89                    ratingInput.val(overIndex+1);
90                });
91                newStar.click(function selectGrade() {
92                    var selectedGrade = $(this).data('grade');
93                    ratingInput.val(selectedGrade);
94                });
95                fullStars.append(newStar);
96            }
97
98            fullStars.hover(function () {
99            }, displayInteractiveGrade);
100            displayInteractiveGrade();
101        }
102
103        function displayInteractiveGrade() {
104            $('.star', fullStars).each(function displayStar() {
105                var starValue = $(this).data('grade');
106                $(this).removeClass('star-hover');
107                if (starValue <= ratingInput.val()) {
108                    $(this).addClass('ets-rv-star-on');
109                } else {
110                    $(this).removeClass('ets-rv-star-on');
111                }
112            });
113        }
114
115        function displayGrade(grade) {
116            emptyStars.html('');
117            fullStars.html('');
118            var newStar;
119            for (var i = minValue; i <= maxValue; ++i) {
120                if (i <= Math.floor(grade)) {
121                    newStar = emptyStar.clone();
122                    newStar.css('visibility', 'hidden');
123                    emptyStars.append(newStar);
124                    fullStars.append(fullStar.clone());
125                } else if (i > Math.ceil(grade)) {
126                    newStar = emptyStar.clone();
127                    emptyStars.append(newStar.clone());
128                } else {
129                    //This the partial star composed of
130                    // - one invisible partial empty star
131                    // - one visible partial empty star (remaining part)
132                    // - one visible partial full star
133                    var fullWidth = (grade - i + 1) * componentOptions.starWidth;
134                    var emptyWidth = componentOptions.starWidth - fullWidth;
135                    newStar = emptyStar.clone();
136                    newStar.css('visibility', 'hidden');
137                    newStar.css('width', fullWidth);
138                    emptyStars.append(newStar);
139
140                    newStar = emptyStar.clone();
141                    newStar.css('width', emptyWidth);
142                    newStar.css('background-position', '0px -' + fullWidth + 'px');
143                    newStar.css('background-position', '-' + fullWidth + 'px 0px');
144                    newStar.css('marginLeft', 0);
145                    emptyStars.append(newStar);
146
147                    fullStar.css('width', fullWidth);
148                    fullStars.append(fullStar.clone());
149                }
150            }
151        }
152    });
153}

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.