122 lines
5.0 KiB
Plaintext
122 lines
5.0 KiB
Plaintext
@page
|
|
@model GanjooRazor.Areas.User.Pages.MyCommentsModel
|
|
@using DNTPersianUtils.Core
|
|
@{
|
|
Layout = "_UserPanelLayout";
|
|
ViewData["Title"] = "حاشیههای من";
|
|
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
|
|
}
|
|
<div class="up-page-header">
|
|
<h1>@ViewData["Title"]</h1>
|
|
</div>
|
|
@if (Model.LastError != "")
|
|
{
|
|
<div class="up-alert up-alert--danger">@Model.LastError</div>
|
|
}
|
|
else
|
|
{
|
|
<script>
|
|
async function deleteThisComment(commentId) {
|
|
var ok = await upConfirm('آیا از حذف این حاشیه اطمینان دارید؟');
|
|
if (!ok) return;
|
|
|
|
$.ajax({
|
|
type: "DELETE",
|
|
url: '?handler=MyComment',
|
|
data: { id: commentId },
|
|
error: function (e) {
|
|
upToast(e.responseText || 'حذف حاشیه با خطا مواجه شد.', 'error');
|
|
},
|
|
success: function () {
|
|
$('#comment-' + commentId).remove();
|
|
upToast('حاشیه حذف شد.', 'success');
|
|
},
|
|
});
|
|
}
|
|
|
|
function editThisComment(commentId) {
|
|
var commentTextBlockId = '#comment-text-' + commentId;
|
|
tinymce.get('editCommentText').setContent($(commentTextBlockId).html());
|
|
$("#editCommentId").val(commentId);
|
|
document.getElementById('id02').style.display = 'block';
|
|
}
|
|
|
|
function editCommentFinal() {
|
|
$("#editcommentform").unbind('submit').bind('submit', function (e) {
|
|
e.preventDefault();
|
|
|
|
var commentId = $("#editCommentId").val();
|
|
|
|
$.ajax({
|
|
type: "PUT",
|
|
url: '?handler=MyComment',
|
|
data: {
|
|
id: commentId,
|
|
comment: $("textarea#editCommentText").val()
|
|
},
|
|
error: function (e) {
|
|
upToast(e.responseText || 'ویرایش حاشیه با خطا مواجه شد.', 'error');
|
|
},
|
|
success: function () {
|
|
document.getElementById('id02').style.display = 'none';
|
|
var commentTextBlockId = '#comment-text-' + commentId;
|
|
$(commentTextBlockId).html($("textarea#editCommentText").val());
|
|
upToast('حاشیه ویرایش شد.', 'success');
|
|
},
|
|
});
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<partial name="_Pagination" model="Model.PaginationLinks" />
|
|
|
|
@if (Model.Comments.Count == 0)
|
|
{
|
|
<partial name="_EmptyState" model="@("حاشیهای یافت نشد.")" />
|
|
}
|
|
else
|
|
{
|
|
<div class="up-list">
|
|
@foreach (var comment in Model.Comments)
|
|
{
|
|
<div class="up-list-item" id="comment-@comment.Id">
|
|
<div id="comment-text-@comment.Id">
|
|
@Html.Raw(comment.HtmlComment)
|
|
</div>
|
|
<div class="up-list-item__meta">
|
|
@Model.UserInfo.NickName در @comment.CommentDate.ToFriendlyPersianDateTextify() دربارهٔ <a href="@comment.Poem.UrlSlug#comment-@comment.Id">@comment.Poem.Title</a>
|
|
</div>
|
|
<div class="up-list-item__actions">
|
|
<a role="button" onclick="deleteThisComment(@comment.Id)" class="up-icon-btn" title="حذف حاشیه" aria-label="حذف این حاشیه"><i class="noindent-info-button delete-icon"></i></a>
|
|
<a role="button" onclick="editThisComment(@comment.Id)" class="up-icon-btn" title="ویرایش حاشیه" aria-label="ویرایش این حاشیه"><i class="noindent-info-button edit-poem-button"></i></a>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
|
|
<partial name="_Pagination" model="Model.PaginationLinks" />
|
|
|
|
<div id="id02" class="modal">
|
|
<span onclick="document.getElementById('id02').style.display='none'"
|
|
class="close" title="بستن">×</span>
|
|
<form class="modal-content animate" method="post" id="editcommentform" action="?handler=EditComment">
|
|
@Html.AntiForgeryToken()
|
|
<table style="max-width:100%; width:100%; margin:0">
|
|
<tr>
|
|
<td>
|
|
<textarea name="editCommentText" id="editCommentText" class="inputTextarea editor width-100per" tabindex="4" rows="10"></textarea>
|
|
<input type="hidden" name="editCommentId" id="editCommentId" value="" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<button name="editcomment" id="editcomment" class="submitCommentButton width-100per" onclick="return editCommentFinal();">ویرایش حاشیه</button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
</form>
|
|
</div>
|
|
}
|