From 82c203bc01b82dedc81eac73f0598a756ca17281 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 10 Sep 2018 13:31:23 +0300 Subject: [PATCH] blog module detail.js refactor --- .../Pages/Blog/Posts/Detail.cshtml | 6 ++-- .../Pages/Blog/Posts/detail.js | 35 +++++++++---------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml index df1a9e7a53..5310a81eb8 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml @@ -129,13 +129,13 @@

- + @L["Reply"] @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete)) { | - + @L["Delete"] } @@ -143,7 +143,7 @@ @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) { | - + @L["Edit"] } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js index 6f327b522c..c6f7e0004f 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js @@ -6,7 +6,7 @@ $('form[class="editFormClass"]').submit(function (event) { event.preventDefault(); var form = $(this).serializeFormToObject(); - + $.ajax({ type: "POST", url: "/Blog/Comments/Update", @@ -23,15 +23,13 @@ }); }); - $('a').click(function (event) { + $('.replyLink').click(function (event) { + event.preventDefault(); var linkElement = $(this); var replyCommentId = linkElement.attr('data-relpyid'); if (replyCommentId != '' && replyCommentId !== undefined) { - - event.preventDefault(); - - var div = $(this).parent().next(); + var div = linkElement.parent().next(); if (div.is(":hidden")) { $('div .replyForm').hide(); @@ -41,18 +39,18 @@ } return; } + }); - var deleteCommentId = $(this).attr('data-deleteid'); + $('.deleteLink').click(function(event) { + event.preventDefault(); + var linkElement = $(this); + var deleteCommentId = linkElement.attr('data-deleteid'); if (deleteCommentId != '' && deleteCommentId !== undefined) { - - console.log(deleteCommentId); - event.preventDefault(); abp.message.confirm( - 'User admin will be deleted.', + 'Comment will be deleted.', // TODO: localize 'Are you sure?', - function (isConfirmed) { - console.log(deleteCommentId); + function(isConfirmed) { if (isConfirmed) { $.ajax({ type: "POST", @@ -65,16 +63,17 @@ } } ); - } + }); + $('.updateLink').click(function (event) { + event.preventDefault(); + var linkElement = $(this); var updateCommentId = $(this).attr('data-updateid'); if (updateCommentId != '' && updateCommentId !== undefined) { - event.preventDefault(); - - var div = $(this).parent().next().next(); + var div = linkElement.parent().next().next(); if (div.is(":hidden")) { $('div .editForm').hide(); @@ -84,8 +83,6 @@ } return; } - - }); })(jQuery);