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