/* * Delete message by AJAX * Date: 29/01/2014 * Author: waghcwb & JScript; * This work is free, you can share and modify it. But keep the original credits. * Update: 23/03/2015 */ $(function() { var oDelete = $('a[href*="mode=delete"]'); oDelete.click(function(event) { event.preventDefault(); var oLink = $(this).attr('href'); var choice = confirm("Tem certeza de que deseja remover esta mensagem?"); var self = $(this); if( choice ) { $.post(oLink, { confirm: 1 }).success(function() { var ID = oLink.match(/p\=(\d+)/g)[0].split('=')[1]; var post = (self.parents('.post').prev('.post') ? self.parents('.post').prev('.post') : self.parents('.post').next('.post')); $('html, body').animate({ scrollTop: post.offset().top - 55 }, 700); $('.post--' + ID).remove(); }); }; }); });