From 9dd16f8b6575b209776740356ff694e2654fae07 Mon Sep 17 00:00:00 2001 From: ToutPratique Date: Fri, 26 May 2017 15:19:11 +0200 Subject: [PATCH] remove one file js voting --- modules/cmsps/cmsps.php | 2 +- themes/toutpratique/js/global.js | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/modules/cmsps/cmsps.php b/modules/cmsps/cmsps.php index 9a9998a9..a3db5aee 100644 --- a/modules/cmsps/cmsps.php +++ b/modules/cmsps/cmsps.php @@ -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); diff --git a/themes/toutpratique/js/global.js b/themes/toutpratique/js/global.js index f324607b..972f3cf3 100644 --- a/themes/toutpratique/js/global.js +++ b/themes/toutpratique/js/global.js @@ -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('Déjà voté'); + + + } + } else { + if($(boxes).children('.already_vote').length == 0) { + $(boxes).append('Merci'); + + } + $('.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) { + + }, + }); + }); +});