Browse Source

blog module detail.js refactor

pull/441/head
Yunus Emre Kalkan 8 years ago
parent
commit
82c203bc01
  1. 6
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
  2. 35
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js

6
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml

@ -129,13 +129,13 @@
</p>
<div class="comment-buttons">
<a href="#" class="tag" data-relpyid="@commentWithRepliesDto.Comment.Id">
<a href="#" class="tag replyLink" data-relpyid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete))
{
<span class="seperator">|</span>
<a href="#" class="tag" data-deleteid="@commentWithRepliesDto.Comment.Id">
<a href="#" class="tag deleteLink" data-deleteid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"]
</a>
}
@ -143,7 +143,7 @@
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag" data-updateid="@commentWithRepliesDto.Comment.Id">
<a href="#" class="tag updateLink" data-updateid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-pencil" aria-hidden="true"></i> @L["Edit"]
</a>
}

35
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);

Loading…
Cancel
Save