PageSourceSearch

https://www.skyballoons.mx/assets/js/starrr.js

js skyballoons.mx collected 2026-10-06 06:45:56 UTC 2,943 bytes, 98 lines download raw bytes

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

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.