@@ -1963,14 +1963,16 @@ class="avatar-thumb">
1963
1963
1964
1964
$ isOwnWall = $ currentUserId == $ userIdLoop || $ currentUserId == $ receiverId ;
1965
1965
if ($ isOwnWall ) {
1966
- $ comment .= Display::url (
1967
- Display:: returnFontAwesomeIcon ( ' trash ' , '' , true ) ,
1968
- ' javascript:void(0) ' ,
1966
+ $ comment .= Display::button (
1967
+ '' ,
1968
+ Display:: returnFontAwesomeIcon ( ' trash ' , '' , true ) ,
1969
1969
[
1970
1970
'id ' => 'message_ ' .$ message ['id ' ],
1971
1971
'title ' => get_lang ('SocialMessageDelete ' ),
1972
- 'onclick ' => 'deleteComment( ' .$ message ['id ' ].') ' ,
1973
- 'class ' => 'btn btn-default ' ,
1972
+ 'type ' => 'button ' ,
1973
+ 'class ' => 'btn btn-default btn-delete-social-comment ' ,
1974
+ 'data-id ' => $ message ['id ' ],
1975
+ 'data-sectoken ' => Security::get_existing_token ('social ' ),
1974
1976
]
1975
1977
);
1976
1978
}
@@ -3017,30 +3019,6 @@ public static function getScrollJs($countPost, &$htmlHeadXtra)
3017
3019
}
3018
3020
3019
3021
$ htmlHeadXtra [] = '<script>
3020
- function deleteMessage(id)
3021
- {
3022
- $.ajax({
3023
- url: " ' .$ socialAjaxUrl .'?a=delete_message" + "&id=" + id,
3024
- success: function (result) {
3025
- if (result) {
3026
- $("#message_" + id).parent().parent().parent().parent().html(result);
3027
- }
3028
- }
3029
- });
3030
- }
3031
-
3032
- function deleteComment(id)
3033
- {
3034
- $.ajax({
3035
- url: " ' .$ socialAjaxUrl .'?a=delete_message" + "&id=" + id,
3036
- success: function (result) {
3037
- if (result) {
3038
- $("#message_" + id).parent().parent().parent().html(result);
3039
- }
3040
- }
3041
- });
3042
- }
3043
-
3044
3022
function submitComment(messageId)
3045
3023
{
3046
3024
var data = $("#form_comment_"+messageId).serializeArray();
@@ -3069,33 +3047,39 @@ function submitComment(messageId)
3069
3047
$(function() {
3070
3048
timeAgo();
3071
3049
3072
- /*$(".delete_message").on("click", function() {
3073
- var id = $(this).attr("id");
3074
- id = id.split("_")[1];
3075
- $.ajax({
3076
- url: " ' .$ socialAjaxUrl .'?a=delete_message" + "&id=" + id,
3077
- success: function (result) {
3050
+ $("body").on("click", ".btn-delete-social-message", function () {
3051
+ var id = $(this).data("id");
3052
+ var secToken = $(this).data("sectoken");
3053
+
3054
+ $.getJSON(
3055
+ " ' .$ socialAjaxUrl .'",
3056
+ { a: "delete_message", id: id, social_sec_token: secToken },
3057
+ function (result) {
3078
3058
if (result) {
3079
- $("#message_" + id).parent().parent().parent().parent().html(result);
3059
+ $("#message_" + id).parent().parent().parent().parent().html(result.message);
3060
+
3061
+ $(".btn-delete-social-message").data("sectoken", result.secToken);
3080
3062
}
3081
3063
}
3082
- } );
3064
+ );
3083
3065
});
3084
3066
3067
+ $("body").on("click", ".btn-delete-social-comment", function () {
3068
+ var id = $(this).data("id");
3069
+ var secToken = $(this).data("sectoken");
3085
3070
3086
- $(".delete_comment").on("click", function() {
3087
- var id = $(this).attr("id");
3088
- id = id.split("_")[1];
3089
- $.ajax({
3090
- url: " ' .$ socialAjaxUrl .'?a=delete_message" + "&id=" + id,
3091
- success: function (result) {
3071
+ $.getJSON(
3072
+ " ' .$ socialAjaxUrl .'",
3073
+ { a: "delete_message", id: id, social_sec_token: secToken },
3074
+ function (result) {
3092
3075
if (result) {
3093
- $("#message_" + id).parent().parent().parent().html(result);
3076
+ $("#message_" + id).parent().parent().parent().html(result.message);
3077
+
3078
+ $(".btn-delete-social-comment").data("sectoken", result.secToken);
3094
3079
}
3095
3080
}
3096
- } );
3081
+ );
3097
3082
});
3098
- */
3099
3083
});
3100
3084
3101
3085
function timeAgo() {
@@ -3467,14 +3451,16 @@ private static function headerMessagePost($authorInfo, $receiverInfo, $message)
3467
3451
);
3468
3452
3469
3453
if ($ canEdit ) {
3470
- $ htmlDelete = Display::url (
3454
+ $ htmlDelete = Display::button (
3455
+ '' ,
3471
3456
Display::returnFontAwesomeIcon ('trash ' , '' , true ),
3472
- 'javascript:void(0) ' ,
3473
3457
[
3474
3458
'id ' => 'message_ ' .$ message ['id ' ],
3475
3459
'title ' => get_lang ('SocialMessageDelete ' ),
3476
- 'onclick ' => 'deleteMessage( ' .$ message ['id ' ].') ' ,
3477
- 'class ' => 'btn btn-default ' ,
3460
+ 'type ' => 'button ' ,
3461
+ 'class ' => 'btn btn-default btn-delete-social-message ' ,
3462
+ 'data-id ' => $ message ['id ' ],
3463
+ 'data-sectoken ' => Security::get_existing_token ('social ' ),
3478
3464
]
3479
3465
);
3480
3466
0 commit comments