PageSourceSearch

https://reasonfunding.com/assets/plugins/starrr.js

js reasonfunding.com collected 2026-09-27 05:12:14 UTC 2,732 bytes, 96 lines download raw bytes

1var __slice = [].slice;
2
3(function($, window) {
4  var Starrr;
5
6  Starrr = (function() {
7    Starrr.prototype.defaults = {
8      rating: void 0,
9      numStars: 5,
10      change: function(e, value) {}
11    };
12
13    function Starrr($el, options) {
14      var i, _, _ref,
15        _this = this;
16
17      this.options = $.extend({}, this.defaults, options);
18      this.$el = $el;
19      _ref = this.defaults;
20      for (i in _ref) {
21        _ = _ref[i];
22        if (this.$el.data(i) != null) {
23          this.options[i] = this.$el.data(i);
24        }
25      }
26      this.createStars();
27      this.syncRating();
28
29      this.$el.on('starrr:change', this.options.change);
30    }
31
32    Starrr.prototype.createStars = function() {
33      var _i, _ref, _results;
34
35      _results = [];
36      for (_i = 1, _ref = this.options.numStars; 1 <= _ref ? _i <= _ref : _i >= _ref; 1 <= _ref ? _i++ : _i--) {
37        _results.push(this.$el.append("<span class='glyphicon .glyphicon-star-empty'></span>"));
38      }
39      return _results;
40    };
41
42    Starrr.prototype.setRating = function(rating) {
43      if (this.options.rating === rating) {
44        rating = void 0;
45      }
46      this.options.rating = rating;
47      this.syncRating();
48      return this.$el.trigger('starrr:change', rating);
49    };
50
51    Starrr.prototype.syncRating = function(rating) {
52      var i, _i, _j, _ref;
53
54      rating || (rating = this.options.rating);
55      if (rating) {
56        for (i = _i = 0, _ref = rating - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
57          this.$el.find('span').eq(i).removeClass('glyphicon-star-empty').addClass('glyphicon-star');
58        }
59      }
60      if (rating && rating < 5) {
61        for (i = _j = rating; rating <= 4 ? _j <= 4 : _j >= 4; i = rating <= 4 ? ++_j : --_j) {
62          this.$el.find('span').eq(i).removeClass('glyphicon-star').addClass('glyphicon-star-empty');
63        }
64      }
65      if (!rating) {
66        return this.$el.find('span').removeClass('glyphicon-star').addClass('glyphicon-star-empty');
67      }
68    };
69
70    return Starrr;
71
72  })();
73
74  return $.fn.extend({
75    starrr: function() {
76      var args, option;
77
78      option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
79      return this.each(function() {
80        var data;
81
82        data = $(this).data('star-rating');
83        if (!data) {
84          $(this).data('star-rating', (data = new Starrr($(this), option)));
85        }
86        if (typeof option === 'string') {
87          return data[option].apply(data, args);
88        }
89      });
90    }
91  });
92})(window.jQuery, window);
93
94$(function() {
95  return $(".starrr").starrr();
96});

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.