Browse Source

Upload new file

master
Repellent 9 years ago
parent
commit
e77d1d1718
  1. 43
      rating/js/rating.js

43
rating/js/rating.js

@ -0,0 +1,43 @@
$(function() {
// Рейтинг
$('.rating_mark').click(function(e) {
e.preventDefault();
var rating, doc_id, mark;
rating = $(this).parents('.rating');
doc_id = rating.attr('data-id');
mark = parseInt($(this).attr('data-mark'));
$.ajax({
type: 'GET',
url: '/index.php?module=rating&action=vote',
data: ({ 'mark':mark, 'doc_id': doc_id }),
success: function(data) {
var array = $.parseJSON(data);
if (array[0])
{
rating.find('.rating_percent').css('width',array[3]+'%');
rating.find('.rating_total_num').text(array[2]);
rating.find('.rating_summary').find('strong').text(array[4]);
}
rating.find('.rating_status').text(array[1]).fadeIn();
setTimeout(function() {
rating.find('.rating_status').fadeOut();
}, 3000);
}
});
});
//
$('.rating_mark').hover(
function () {
var rating, mark, hover, stars;
rating = $(this).parents('.rating');
mark = parseInt($(this).attr('data-mark'));
stars = rating.attr('data-stars');
hover = Math.round(mark / stars * 100);
rating.find('.rating_hover').css('width', hover+'%');
},
function () {
$(this).parents('.rating').find('.rating_hover').css('width', 0);
}
);
});
Loading…
Cancel
Save