|
|
|
@ -15,6 +15,40 @@ |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function registerEditLinks($container) { |
|
|
|
$container.find('.comment-edit-link').each(function () { |
|
|
|
var $link = $(this); |
|
|
|
$link.on('click', function (e) { |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
var commentId = $link.data('id'); |
|
|
|
|
|
|
|
var $relatedCommentContentArea = $container.find('.cms-comment-content-area[data-id='+ commentId +']'); |
|
|
|
var $relatedCommentEditFormArea = $container.find('.cms-comment-edit-area[data-id='+ commentId +']'); |
|
|
|
|
|
|
|
$relatedCommentContentArea.hide(); |
|
|
|
$relatedCommentEditFormArea.show(); |
|
|
|
$link.removeAttr('href'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$container.find('.comment-edit-cancel-button').each(function () { |
|
|
|
var $button = $(this); |
|
|
|
$button.on('click', function (e) { |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
var commentId = $button.data('id'); |
|
|
|
|
|
|
|
var $relatedCommentContentArea = $container.find('.cms-comment-content-area[data-id='+ commentId +']'); |
|
|
|
var $relatedCommentEditFormArea = $container.find('.cms-comment-edit-area[data-id='+ commentId +']'); |
|
|
|
var $link = $container.find('.comment-edit-link[data-id='+ commentId +']'); |
|
|
|
|
|
|
|
$relatedCommentContentArea.show(); |
|
|
|
$relatedCommentEditFormArea.hide(); |
|
|
|
$link.attr('href','#'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function registerReplyLinks($container) { |
|
|
|
$container.find('.comment-reply-link').each(function () { |
|
|
|
var $link = $(this); |
|
|
|
@ -23,9 +57,10 @@ |
|
|
|
|
|
|
|
var replyCommentId = $link.data('reply-id'); |
|
|
|
|
|
|
|
var relatedCommentArea = $container.find('.cms-comment-form-area[data-reply-id='+ replyCommentId +']'); |
|
|
|
var $relatedCommentArea = $container.find('.cms-comment-form-area[data-reply-id='+ replyCommentId +']'); |
|
|
|
|
|
|
|
relatedCommentArea.show(); |
|
|
|
$relatedCommentArea.show(); |
|
|
|
$link.removeAttr('href'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$container.find('.reply-cancel-button').each(function () { |
|
|
|
@ -35,9 +70,11 @@ |
|
|
|
|
|
|
|
var replyCommentId = $button.data('reply-id'); |
|
|
|
|
|
|
|
var relatedCommentArea = $container.find('.cms-comment-form-area[data-reply-id='+ replyCommentId +']'); |
|
|
|
var $relatedCommentArea = $container.find('.cms-comment-form-area[data-reply-id='+ replyCommentId +']'); |
|
|
|
var $replyLink = $container.find('.comment-reply-link[data-reply-id='+ replyCommentId +']'); |
|
|
|
|
|
|
|
relatedCommentArea.hide(); |
|
|
|
$relatedCommentArea.hide(); |
|
|
|
$replyLink.attr('href','#'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
@ -48,11 +85,31 @@ |
|
|
|
$link.on('click', '', function (e) { |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
abp.message.confirm(l("MessageDeletionConfirmationMessage"), function () { |
|
|
|
volo.cmsKit.comments.commentPublic.delete($link.data('comment-id') |
|
|
|
).then(function () { |
|
|
|
widgetManager.refresh($widget); |
|
|
|
}); |
|
|
|
abp.message.confirm(l("MessageDeletionConfirmationMessage"), function (ok) { |
|
|
|
if (ok){ |
|
|
|
volo.cmsKit.comments.commentPublic.delete($link.data('id') |
|
|
|
).then(function () { |
|
|
|
widgetManager.refresh($widget); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function registerUpdateOfNewComment($container) { |
|
|
|
$container.find('.cms-comment-update-form').each(function () { |
|
|
|
var $form = $(this); |
|
|
|
$form.submit(function (e) { |
|
|
|
e.preventDefault(); |
|
|
|
var formAsObject = $form.serializeFormToObject(); |
|
|
|
volo.cmsKit.comments.commentPublic.update( |
|
|
|
formAsObject.id, |
|
|
|
{ |
|
|
|
text: formAsObject.commentText |
|
|
|
} |
|
|
|
).then(function () { |
|
|
|
widgetManager.refresh($widget); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -64,13 +121,13 @@ |
|
|
|
$form.submit(function (e) { |
|
|
|
e.preventDefault(); |
|
|
|
var formAsObject = $form.serializeFormToObject(); |
|
|
|
console.log(formAsObject); |
|
|
|
volo.cmsKit.comments.commentPublic.create( |
|
|
|
$.extend(getFilters(), { |
|
|
|
repliedCommentId: formAsObject.repliedCommentId, |
|
|
|
text: formAsObject.commentText |
|
|
|
}) |
|
|
|
).then(function () { |
|
|
|
$form.find('textarea').val(''); |
|
|
|
widgetManager.refresh($widget); |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -79,7 +136,10 @@ |
|
|
|
|
|
|
|
function init() { |
|
|
|
registerReplyLinks($widget); |
|
|
|
registerEditLinks($widget); |
|
|
|
registerDeleteLinks($widget); |
|
|
|
|
|
|
|
registerUpdateOfNewComment($widget); |
|
|
|
registerSubmissionOfNewComment($widget); |
|
|
|
} |
|
|
|
|
|
|
|
|