1
if ( jQuery(".penci_rateyo").length ) {
2
jQuery(".penci_rateyo").each( function(){
3
var $this = jQuery(this),
4
rate = parseFloat( $this.data('rate') ),
5
allow = $this.data('allow'),
6
total = $this.data('total'),
7
people_numb = parseInt( $this.data('people') );
8
9
$this.rateYo({
10
rating: rate,
11
fullStar: true,
12
starWidth: "13px",
13
spacing: "3px",
14
onSet: function ( rating, rateYoInstance ) {
15
jQuery(this).rateYo("option", "readOnly", true);
16
var postid = jQuery(this).data('postid');
17
18
jQuery.ajax({
19
type: "POST",
20
url: PENCI.ajaxUrl,
21
dataType: 'html',
22
data: { action: 'penci_rateyo', nonce: PENCI.nonce, postid: postid, rating: rating },
23
success: function( data ) {
24
var parent = jQuery(this).parent(),
25
new_rate = ( total + rating ) / ( people_numb + 1 );
26
jQuery('.penci-rate-number', parent).html(new_rate);
27
$this.rateYo("rating", new_rate);
28
$this.parent().find('.penci-rate-number').html( new_rate.toPrecision(2) );
29
$this.parent().find('.penci-number-people').html( people_numb + 1 );
30
}
31
});
32
}
33
});
34
35
if ( allow == '0' ) {
36
$this.rateYo("option", "readOnly", true);
37
}
38
} );
39
}