let $j = jQuery.noConflict(); $j(function(){ let currentMsg; let currentMsgRef; $j('body').on('click', '.answer-msg', function(e){ e.preventDefault(); currentMsg = $j(this).data('id'); currentMsgRef = $j(this).data('ref'); $j.post( ajaxurl, { 'action': 'getReponseForMsg', 'id' : currentMsg, }, function(response){ $j('#reponse-msg').empty().html(response); $j.fancybox.open({ src : '#reponse-msg', type : 'inline', afterClose: function (){ window.location.reload(); }, closeBtn: true }); } ); }); $j('body').on('click', '.show-msg', function(e){ e.preventDefault(); currentMsg = $j(this).data('id'); $j.post( ajaxurl, { 'action': 'getMsg', 'id' : currentMsg, }, function(response){ $j('#reponse-msg').empty().html(response); $j.fancybox.open({ src : '#reponse-msg', type : 'inline', afterClose: function (){ window.location.reload(); }, closeBtn: true }); } ); }); $j('body').on('click', '.send-answer', function(e){ e.preventDefault(); let email = $j('#emailTosend').val(); let message = $j('#msgTosend').val(); $j.post( ajaxurl, { 'action': 'sendReponse', 'email' : email, 'message' : message, 'id' : currentMsg, 'ref': currentMsgRef }, function(response){ $j('#reponse-msg').empty().html(response); } ); }); $j('body').on('click', '.mark-msg', function (e) { e.preventDefault(); let test = confirm("Êtes-vous sûr(e) ?"); if (!test) return; let self = this, currentMsg = $j(self).data('id'), $tdStatus = $j(self).parents('tr').eq(0).children('td').eq(2), $tdDate = $j(self).parents('tr').eq(0).children('td').eq(7); $j.post( ajaxurl, { 'action': 'markMsg', 'id': currentMsg, }, function (date) { $tdStatus.html("
"); $j(self).parent().html("Afficher"); $tdDate.text('Marqué comme traité'); } ); }); });