forked from olton/metroui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrating.js
More file actions
46 lines (38 loc) · 1.1 KB
/
Copy pathrating.js
File metadata and controls
46 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(function($){
$.fn.Rating = function( options ){
var defaults = {
};
var $this = $(this)
;
var init = function(el){
var a = el.find("a");
var r = Math.round(el.data("rating")) || 0;
a.each(function(index){
console.log(index);
if (index < r) {
$(this).addClass("rated");
}
$(this).hover(
function(){
$(this).prevAll().andSelf().addClass("hover");
$(this).nextAll().removeClass("hover");
},
function(){
$(this).prevAll().andSelf().removeClass("hover");
}
)
})
}
return this.each(function(){
if ( options ) {
$.extend(defaults, options)
}
init($this);
});
}
$(function () {
$('[data-role="rating"]').each(function () {
$(this).Rating();
})
})
})(window.jQuery);