remove one file js voting

This commit is contained in:
ToutPratique 2017-05-26 15:19:11 +02:00
parent b5fc8defed
commit 9dd16f8b65
2 changed files with 46 additions and 1 deletions

View File

@ -50,7 +50,7 @@ if (!class_exists('CmsPS')) {
}
public function hookdisplayFooter() {
$this->context->controller->addJS(($this->_path).'voting.js', 'all');
// $this->context->controller->addJS(($this->_path).'voting.js', 'all');
if($this->context->controller->php_self == 'categorycms' && $this->context->controller->categorycms->id_category == 1){
$this->context->controller->addJqueryUI('ui.autocomplete', $theme = 'toutpratique', $check_dependencies = true);

View File

@ -799,3 +799,48 @@ function readCookie(name)
function deleteCookie(name) {
createCookie(name, "", -1);
}
$( document ).ready(function() {
$('.vote_box').on('click', '.vote', function(e){
var boxes = $(this).parent('.vote_box');
var id_post = $(this).data('id');
var uri = baseUri+'modules/cmsps/ajax_voting.php';
$.ajax({
url : uri,
type : 'POST',
data : 'id_post=' + id_post,
dataType : 'json',
success : function(json, statut) {
if(!json.errors) {
$(boxes).addClass('active');
if (json.already_vote) {
if($(boxes).children('.already_vote').length == 0) {
$(boxes).append('<span class="already_vote">Déjà voté</span>');
}
} else {
if($(boxes).children('.already_vote').length == 0) {
$(boxes).append('<span class="already_vote">Merci</span>');
}
$('.nb_vote_'+id_post).each(function(index) {
$(this).html(json.nb_vote);
});
}
$('#shareCtn').slideDown(function() {
$('html, body').animate({scrollTop: $('#shareCtn').offset().top}, 'slow');
});
}
},
error : function(resultat, statut, erreur) {
},
});
});
});