2014-12-28 12:14:01 -08:00
|
|
|
$(document).on "click", "a[data-action=ab-comment-destroy]", (ev) ->
|
|
|
|
ev.preventDefault()
|
2015-01-03 08:36:55 -08:00
|
|
|
swal
|
2015-01-03 10:43:51 -08:00
|
|
|
title: "Really delete?"
|
|
|
|
text: "You will not be able to recover this comment."
|
2015-01-03 08:36:55 -08:00
|
|
|
type: "warning"
|
|
|
|
showCancelButton: true
|
|
|
|
confirmButtonColor: "#DD6B55"
|
2015-01-03 10:43:51 -08:00
|
|
|
confirmButtonText: "Delete"
|
2015-01-03 08:36:55 -08:00
|
|
|
closeOnConfirm: false
|
|
|
|
, ->
|
2014-12-28 12:14:01 -08:00
|
|
|
btn = $(this)
|
|
|
|
cid = btn[0].dataset.cId
|
|
|
|
$.ajax
|
|
|
|
url: '/ajax/destroy_comment'
|
|
|
|
type: 'POST'
|
|
|
|
data:
|
|
|
|
comment: cid
|
|
|
|
success: (data, status, jqxhr) ->
|
|
|
|
if data.success
|
|
|
|
$("li[data-comment-id=#{cid}]").slideUp()
|
|
|
|
showNotification data.message, data.success
|
|
|
|
error: (jqxhr, status, error) ->
|
|
|
|
console.log jqxhr, status, error
|
|
|
|
showNotification "An error occurred, a developer should check the console for details", false
|
|
|
|
complete: (jqxhr, status) ->
|