PageSourceSearch

https://www.strunki.ru/assets/snippets/star_rating/assets/js/scripts.min.js

js strunki.ru collected 2026-10-06 12:06:14 UTC 14,505 bytes, 248 lines download raw bytes

1!function (t) {
2    "use strict";
3    var s = {
4        init: function (a) {
5            return this.each(function () {
6                this.self = t(this), s.destroy.call(this.self), this.opt = t.extend(!0, {}, t.fn.raty.defaults, a), s._adjustCallback.call(this), s._adjustNumber.call(this), s._adjustHints.call(this), this.opt.score = s._adjustedScore.call(this, this.opt.score), "img" !== this.opt.starType && s._adjustStarType.call(this), s._adjustPath.call(this), s._createStars.call(this), this.opt.precision && s._adjustPrecision.call(this), s._createScore.call(this), s._apply.call(this, this.opt.score), s._setTitle.call(this, this.opt.score), s._target.call(this, this.opt.score), this.opt.readOnly ? s._lock.call(this) : (this.style.cursor = "pointer", s._binds.call(this))
7            })
8        }, _adjustCallback: function () {
9            for (var t = ["number", "readOnly", "score", "scoreName", "target", "path", "starOn", "starOff", "starHalf", "starType"], s = 0; s < t.length; s++) "function" == typeof this.opt[t[s]] && (this.opt[t[s]] = this.opt[t[s]].call(this))
10        }, _adjustedScore: function (t) {
11            return t ? s._between(t, 0, this.opt.number) : t
12        }, _adjustHints: function () {
13            if (this.opt.hints || (this.opt.hints = []), this.opt.halfShow || this.opt.half) for (var t = this.opt.precision ? 10 : 2, s = 0; s < this.opt.number; s++) {
14                var a = this.opt.hints[s];
15                "[object Array]" !== Object.prototype.toString.call(a) && (a = [a]), this.opt.hints[s] = [];
16                for (var i = 0; t > i; i++) {
17                    var e = a[i], r = a[a.length - 1];
18                    void 0 === r && (r = null), this.opt.hints[s][i] = void 0 === e ? r : e
19                }
20            }
21        }, _adjustNumber: function () {
22            this.opt.number = s._between(this.opt.number, 1, this.opt.numberMax)
23        }, _adjustPath: function () {
24            this.opt.path = this.opt.path || "", this.opt.path && "/" !== this.opt.path.charAt(this.opt.path.length - 1) && (this.opt.path += "/")
25        }, _adjustPrecision: function () {
26            this.opt.half = !0
27        }, _adjustStarType: function () {
28            var t = ["starHalf", "starOff", "starOn"];
29            this.opt.path = "";
30            for (var s = 0; s < t.length; s++) this.opt[t[s]] = this.opt[t[s]].replace(".", "-")
31        }, _apply: function (t) {
32            s._fill.call(this, t), t && (t > 0 && this.score.val(t), s._roundStars.call(this, t))
33        }, _between: function (t, s, a) {
34            return Math.min(Math.max(parseFloat(t), s), a)
35        }, _binds: function () {
36            s._bindOver.call(this), s._bindClick.call(this), s._bindOut.call(this)
37        }, _bindClick: function () {
38            var a = this;
39            a.stars.on("click.raty", function (i) {
40                var e = !0, r = a.opt.half || a.opt.precision ? a.self.data("score") : this.alt || t(this).data("alt");
41                a.opt.click && (e = a.opt.click.call(a, +r, i)), (e || void 0 === e) && (a.opt.half && !a.opt.precision && (r = s._roundHalfScore.call(a, r)), s._apply.call(a, r))
42            })
43        }, _bindOut: function () {
44            var t = this;
45            t.self.on("mouseleave.raty", function (a) {
46                var i = +t.score.val() || void 0;
47                s._apply.call(t, i), s._target.call(t, i, a), s._resetTitle.call(t), t.opt.mouseout && t.opt.mouseout.call(t, i, a)
48            })
49        }, _bindOver: function () {
50            var t = this, a = t.opt.half ? "mousemove.raty" : "mouseover.raty";
51            t.stars.on(a, function (a) {
52                var i = s._getScoreByPosition.call(t, a, this);
53                s._fill.call(t, i), t.opt.half && (s._roundStars.call(t, i, a), s._setTitle.call(t, i, a), t.self.data("score", i)), s._target.call(t, i, a), t.opt.mouseover && t.opt.mouseover.call(t, i, a)
54            })
55        }, _buildScoreField: function () {
56            return t("<input />", {name: this.opt.scoreName, type: "hidden"}).appendTo(this)
57        }, _createScore: function () {
58            var a = t(this.opt.targetScore);
59            this.score = a.length ? a : s._buildScoreField.call(this)
60        }, _createStars: function () {
61            for (var a = 1; a <= this.opt.number; a++) {
62                var i = s._nameForIndex.call(this, a), e = {alt: a, src: this.opt.path + this.opt[i]};
63                "img" !== this.opt.starType && (e = {
64                    "data-alt": a,
65                    "class": e.src
66                }), e.title = s._getHint.call(this, a), t("<" + this.opt.starType + " />", e).appendTo(this)
67            }
68            this.stars = this.self.children(this.opt.starType)
69        }, _error: function (s) {
70            t(this).text(s), t.error(s)
71        }, _fill: function (t) {
72            for (var a = 0, i = 1; i <= this.stars.length; i++) {
73                var e, r = this.stars[i - 1], o = s._turnOn.call(this, i, t);
74                if (this.opt.iconRange && this.opt.iconRange.length > a) {
75                    var n = this.opt.iconRange[a];
76                    e = s._getRangeIcon.call(this, n, o), i <= n.range && s._setIcon.call(this, r, e), i === n.range && a++
77                } else e = this.opt[o ? "starOn" : "starOff"], s._setIcon.call(this, r, e)
78            }
79        }
79, _getFirstDecimal: function (t) {
80            var s = t.toString().split(".")[1], a = 0;
81            return s && (a = parseInt(s.charAt(0), 10), "9999" === s.slice(1, 5) && a++), a
82        }, _getRangeIcon: function (t, s) {
83            return s ? t.on || this.opt.starOn : t.off || this.opt.starOff
84        }, _getScoreByPosition: function (a, i) {
85            var e = parseInt(i.alt || i.getAttribute("data-alt"), 10);
86            if (this.opt.half) {
87                var r = s._getWidth.call(this), o = parseFloat((a.pageX - t(i).offset().left) / r);
88                e = e - 1 + o
89            }
90            return e
91        }, _getHint: function (t, a) {
92            if (0 !== t && !t) return this.opt.noRatedMsg;
93            var i = s._getFirstDecimal.call(this, t), e = Math.ceil(t), r = this.opt.hints[(e || 1) - 1], o = r,
94                n = !a || this.move;
95            return this.opt.precision ? (n && (i = 0 === i ? 9 : i - 1), o = r[i]) : (this.opt.halfShow || this.opt.half) && (i = n && 0 === i ? 1 : i > 5 ? 1 : 0, o = r[i]), "" === o ? "" : o || t
96        }, _getWidth: function () {
97            var t = this.stars[0].width || parseFloat(this.stars.eq(0).css("font-size"));
98            return t || s._error.call(this, "Could not get the icon width!"), t
99        }, _lock: function () {
100            var t = s._getHint.call(this, this.score.val());
101            this.style.cursor = "", this.title = t, this.score.prop("readonly", !0), this.stars.prop("title", t), this.self.data("readonly", !0)
102        }, _nameForIndex: function (t) {
103            return this.opt.score && this.opt.score >= t ? "starOn" : "starOff"
104        }, _resetTitle: function () {
105            for (var t = 0; t < this.opt.number; t++) this.stars[t].title = s._getHint.call(this, t + 1)
106        }, _roundHalfScore: function (t) {
107            var a = parseInt(t, 10), i = s._getFirstDecimal.call(this, t);
108            return 0 !== i && (i = i > 5 ? 1 : .5), a + i
109        }, _roundStars: function (t, a) {
110            var i, e = (t % 1).toFixed(2);
111            if (a || this.move ? i = e > .5 ? "starOn" : "starHalf" : e > this.opt.round.down && (i = "starOn", this.opt.halfShow && e < this.opt.round.up ? i = "starHalf" : e < this.opt.round.full && (i = "starOff")), i) {
112                var r = this.opt[i], o = this.stars[Math.ceil(t) - 1];
113                s._setIcon.call(this, o, r)
114            }
115        }, _setIcon: function (t, s) {
116            t["img" === this.opt.starType ? "src" : "className"] = this.opt.path + s
117        }, _setTarget: function (t, s) {
118            s && (s = this.opt.targetFormat.toString().replace("{score}", s)), t.is(":input") ? t.val(s) : t.html(s)
119        }, _setTitle: function (t, a) {
120            if (t) {
121                var i = parseInt(Math.ceil(t), 10), e = this.stars[i - 1];
122                e.title = s._getHint.call(this, t, a)
123            }
124        }, _target: function (a, i) {
125            if (this.opt.target) {
126                var e = t(this.opt.target);
127                e.length || s._error.call(this, "Target selector invalid or missing!");
128                var r = i && "mouseover" === i.type;
129                if (void 0 === a) a = this.opt.targetText; else if (null === a) a = r ? this.opt.cancelHint : this.opt.targetText; else {
130                    "hint" === this.opt.targetType ? a = s._getHint.call(this, a, i) : this.opt.precision && (a = parseFloat(a).toFixed(1));
131                    var o = i && "mousemove" === i.type;
132                    r || o || this.opt.targetKeep || (a = this.opt.targetText)
133                }
134                s._setTarget.call(this, e, a)
135            }
136        }, _turnOn: function (t, s) {
137            return this.opt.single ? t === s : s >= t
138        }, _unlock: function () {
139            this.style.cursor = "pointer", this.removeAttribute("title"), this.score.removeAttr("readonly"), this.self.data("readonly", !1);
140            for (var t = 0; t < this.opt.number; t++) this.stars[t].title = s._getHint.call(this, t + 1)
141        }, click: function (a) {
142            return this.each(function () {
143                t(this).data("readonly") !== !0 && (a = s._adjustedScore.call(this, a), s._apply.call(this, a), this.opt.click && this.opt.click.call(this, a, t.Event("click")), s._target.call(this, a))
144            })
145        }, destroy: function () {
146            return this.each(function () {
147                var s = t(this), a = s.data("raw");
148                a ? s.off(".raty").empty().css({cursor: a.style.cursor}).removeData("readonly") : s.data("raw", s.clone()[0])
149            })
150        }, getScore: function () {
151            var t, s = [];
152            return this.each(function () {
153                t = this.score.val(), s.push(t ? +t : void 0)
154            }), s.length > 1 ? s : s[0]
155        }, move: function (a) {
156            return this.each(function () {
157                var i = parseInt(a, 10), e = s._getFirstDecimal.call(this, a);
158                i >= this.opt.number && (i = this.opt.number - 1, e = 10);
159                var r = s._getWidth.call(this), o = r / 10, n = t(this.stars[i]), l = n.offset().left + o * e,
160                    c = t.Event("mousemove", {pageX: l});
161                this.move = !0, n.trigger(c), this.move = !1
162            })
163        }, readOnly: function (a) {
164            return this.each(function () {
165                var i = t(this);
166                i.data("readonly") !== a && (a ? (i.off(".raty").children(this.opt.starType || "img").off(".raty"), s._lock.call(this)) : (s._binds.call(this), s._unlock.call(this)), i.data("readonly", a))
167            })
168        }, reload: function () {
169            return s.set.call(this, {})
170        }, score: function () {
171            var a = t(this);
172            return arguments.length ? s.setScore.apply(a, arguments) : s.getScore.call(a)
173        }, set: function (s) {
174            return this.each(function () {
175                t(this).raty(t.extend({}, this.opt, s))
176            })
177        }, setScore: function (a) {
178            return this.each(function () {
179                t(this).data("readonly") !== !0 && (a = s._adjustedScore.call(this, a), s._apply.call(this, a), s._target.call(this, a))
180            })
181        }
182    };
183    t.fn.raty = function (a) {
184        return s[a] ? s[a].apply(this, Array.prototype.slice.call(arguments, 1)) : "object" != typeof a && a ? void t.error("Method " + a + " does not exist!") : s.init.apply(this, arguments)
185    }, t.fn.raty.defaults = {
186        cancelHint: "Cancel this rating!",
187        click: void 0,
188        half: !1,
189        halfShow: !0,
190        hints: [],
191        iconRange: void 0,
192        mouseout: void 0,
193        mouseover: void 0,
194        noRatedMsg: "Not rated yet!",
195        number: 5,
196        numberMax: 20,
197        path: void 0,
198        precision: !1,
199        readOnly: !1,
200        round: {down: .25, full: .6, up: .76},
201        score: void 0,
202        scoreName: "score",
203        single: !1,
204        starHalf: "star-half.svg",
205        starOff: "star-off.png",
206        starOn: "star-on.png",
207        starType: "img",
208        target: void 0,
209        targetFormat: "{score}",
210        targetKeep: !1,
211        targetScore: void 0,
212        targetText: "",
213        targetType: "hint"
214    }
215}(jQuery), jQuery(document).ready(function (t) {
216    t(".star-rating").raty({
217        path: function () {
218            return this.dataset.path || "/assets/snippets/star_rating/assets/img/"
219        }, starOn: function () {
220            return this.dataset.on || "star-on.png"
221        }, starOff: function () {
222            return this.dataset.off || "star-off.png"
223        }, starHalf: function () {
224            return this.dataset.half || "star-half.svg"
225        }, number: function () {
226            return this.dataset.stars || 5
227        }, score: function () {
228            return this.dataset.rating || 0
229        }, readOnly: function () {
230            return 1 == this.dataset.disabled
231        }, starType: function () {
232            return this.dataset.type || "img"
233        }, click: function (s) {
234            var a = t(this), i = a.closest(".star-rating-container"), e = this.dataset.id;
235            t.ajax({
236                url: window.location.href, type: "get", data: {rid: e, vote: s}, success: function (s) {
237                    s ? (i.find(".msg").remove(), s.success !== !0 || s.error ? a.raty("reload") : (i.find(".star-rating-votes").text(s.votes), i.find(".star-rating-rating").text(s.rating), a.raty("score", s.rating), a.raty("readOnly", !0)), a.append('<div class="msg">' + s.message + "</div>"), a.find(".mask").fadeOut(100, function () {
238                        t(this).remove()
239                    }), setTimeout(function () {
240                        i.find(".msg").fadeOut(1e3)
241                    }, 2e3)) : alert("Unknown error. Try again later")
242                }, beforeSend: function () {
243                    a.append('<div class="mask" />')
244                }
245            })
246        }
247    })
248});

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.