Browse Source

cmskit: focus after login improvements

pull/5155/head
Yunus Emre Kalkan 6 years ago
parent
commit
12b4f79559
  1. 10
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml
  2. 38
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/default.js

10
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml

@ -60,7 +60,7 @@
{ {
@if (CurrentUser.IsAuthenticated) @if (CurrentUser.IsAuthenticated)
{ {
<a href="#" class="comment-reply-link" data-reply-id="@id.ToString()"> <a href="#" class="comment-reply-link" data-reply-id="@id.ToString()" id="@($"cms-comment_{Model.EntityType}_{Model.EntityId}_{id}_link")">
<i class="fa fa-reply"></i> @L["Reply"] <i class="fa fa-reply"></i> @L["Reply"]
</a> </a>
} }
@ -87,7 +87,7 @@
</a> </a>
} }
</div> </div>
<div class="cms-comment-edit-area" data-id="@id.ToString()" style="display:none"> <div class="cms-comment-edit-area" id="@($"cms-comment_{Model.EntityType}_{Model.EntityId}_{id}")" data-id="@id.ToString()" style="display:none">
<form class="cms-comment-update-form"> <form class="cms-comment-update-form">
<input hidden value="@id.ToString()" name="id"/> <input hidden value="@id.ToString()" name="id"/>
<div class="form-group"> <div class="form-group">
@ -100,7 +100,7 @@
</div>; </div>;
} }
<div class="cms-comment-area" data-entity-type="@Model.EntityType" data-entity-id="@Model.EntityId" id="@($"cms-comment_{Model.EntityType}_{Model.EntityId}")"> <div class="cms-comment-area" data-entity-type="@Model.EntityType" data-entity-id="@Model.EntityId">
<div class="pl-5 pt-3"> <div class="pl-5 pt-3">
<h4> <h4>
@ -160,7 +160,9 @@
<div> <div>
@if (CurrentUser.IsAuthenticated) @if (CurrentUser.IsAuthenticated)
{ {
@GetCommentArea(null).Invoke(null) <div id="@($"cms-comment_{Model.EntityType}_{Model.EntityId}")">
@GetCommentArea(null).Invoke(null)
</div>
} }
else if (!string.IsNullOrWhiteSpace(Model.LoginUrl)) else if (!string.IsNullOrWhiteSpace(Model.LoginUrl))
{ {

38
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/default.js

@ -23,8 +23,8 @@
var commentId = $link.data('id'); var commentId = $link.data('id');
var $relatedCommentContentArea = $container.find('.cms-comment-content-area[data-id='+ commentId +']'); var $relatedCommentContentArea = $container.find('.cms-comment-content-area[data-id=' + commentId + ']');
var $relatedCommentEditFormArea = $container.find('.cms-comment-edit-area[data-id='+ commentId +']'); var $relatedCommentEditFormArea = $container.find('.cms-comment-edit-area[data-id=' + commentId + ']');
$relatedCommentContentArea.hide(); $relatedCommentContentArea.hide();
$relatedCommentEditFormArea.show(); $relatedCommentEditFormArea.show();
@ -38,13 +38,13 @@
var commentId = $button.data('id'); var commentId = $button.data('id');
var $relatedCommentContentArea = $container.find('.cms-comment-content-area[data-id='+ commentId +']'); var $relatedCommentContentArea = $container.find('.cms-comment-content-area[data-id=' + commentId + ']');
var $relatedCommentEditFormArea = $container.find('.cms-comment-edit-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 +']'); var $link = $container.find('.comment-edit-link[data-id=' + commentId + ']');
$relatedCommentContentArea.show(); $relatedCommentContentArea.show();
$relatedCommentEditFormArea.hide(); $relatedCommentEditFormArea.hide();
$link.attr('href','#'); $link.attr('href', '#');
}); });
}); });
} }
@ -57,9 +57,10 @@
var replyCommentId = $link.data('reply-id'); 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();
$relatedCommentArea.find('textarea').focus();
$link.removeAttr('href'); $link.removeAttr('href');
}); });
}); });
@ -70,11 +71,11 @@
var replyCommentId = $button.data('reply-id'); 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 +']'); var $replyLink = $container.find('.comment-reply-link[data-reply-id=' + replyCommentId + ']');
$relatedCommentArea.hide(); $relatedCommentArea.hide();
$replyLink.attr('href','#'); $replyLink.attr('href', '#');
}); });
}); });
} }
@ -86,7 +87,7 @@
e.preventDefault(); e.preventDefault();
abp.message.confirm(l("MessageDeletionConfirmationMessage"), function (ok) { abp.message.confirm(l("MessageDeletionConfirmationMessage"), function (ok) {
if (ok){ if (ok) {
volo.cmsKit.public.comments.commentPublic.delete($link.data('id') volo.cmsKit.public.comments.commentPublic.delete($link.data('id')
).then(function () { ).then(function () {
widgetManager.refresh($widget); widgetManager.refresh($widget);
@ -136,15 +137,18 @@
} }
function focusOnHash($container) { function focusOnHash($container) {
if (!location.hash.toLowerCase().startsWith('#cms-comment')){ if (!location.hash.toLowerCase().startsWith('#cms-comment')) {
return; return;
} }
$('html, body').animate( var $link = $(location.hash + '_link');
{
scrollTop: $(location.hash).offset().top + $(this).height() / 2 if ($link.length > 0) {
}, $link.click();
'slow'); }
else {
$(location.hash).find('textarea').focus();
}
} }
function init() { function init() {

Loading…
Cancel
Save