Orchard.Comments - Rework frontend and fix bugs ()

[Fixes , Fixes ]
This commit is contained in:
Matthew Harris 2016-12-22 20:22:15 +00:00 committed by Sébastien Ros
parent 34518b5ce2
commit b59fe0fd7a
16 changed files with 196 additions and 83 deletions

View File

@ -0,0 +1,8 @@
[
{
"inputs": [
"Assets/Scripts/Orchard.Comments.Threaded.js"
],
"output": "Scripts/Orchard.Comments.Threaded.js"
}
]

View File

@ -0,0 +1,55 @@
(function ($) {
$(document).ready(function () {
$('.comment-reply-form-settings').map(function () {
var $self = $(this);
var contentItemId = $self.data("contentitem-id");
var activeCommentId = $self.data('active-comment-id');
InitializeCommentReplyUI(contentItemId, activeCommentId);
});
$('.comment-reply-button').click(function () {
var $self = $(this);
var contentItemId = $self.data("contentitem-id");
var commentId = $self.data('id');
UpdateTheRepliedOnHiddenField(contentItemId, commentId);
MoveReplyFormToBeacon(contentItemId, commentId);
UpdateReplyButtonsUI(contentItemId, commentId);
return false;
});
});
function InitializeCommentReplyUI(contentItemId, activeCommentId) {
UpdateTheRepliedOnHiddenField(contentItemId, activeCommentId);
MoveReplyFormToBeacon(contentItemId, activeCommentId);
InitializeRootReplyButtonUI();
}
function InitializeRootReplyButtonUI(contentItemId, activeCommentId) {
if (activeCommentId === "root") {
$('.comment-reply-button[data-contentitem-id="' + contentItemId + '"][data-id="root"]').hide();
}
}
function UpdateTheRepliedOnHiddenField(contentItemId, commentId) {
var $reply = $('.comments-repliedon[data-contentitem-id="' + contentItemId + '"]');
// The ternary operator is because the UI uses root but Orchard expects the value to be empty
$reply.val(commentId === "root" ? "" : commentId);
}
function UpdateReplyButtonsUI(contentItemId, commentId) {
$('.comment-reply-button[data-contentitem-id="' + contentItemId + '"]').show();
$('.comment-reply-button[data-contentitem-id="' + contentItemId + '"][data-id="' + commentId + '"]').fadeOut("fast");
}
function MoveReplyFormToBeacon(contentItemId, commentId) {
var $replyFormBeacon = $('.comment-reply-form-beacon[data-contentitem-id="' + contentItemId + '"][data-id="' + commentId + '"]');
$('.comment-form[data-contentitem-id="' + contentItemId + '"]')
.slideUp("fast", function () {
$(this)
.appendTo($replyFormBeacon)
.slideDown();
});
}
})(jQuery)

View File

@ -9,7 +9,7 @@ Features:
Orchard.Comments:
Name: Comments
Description: Standard content item comments.
Dependencies: Settings, Orchard.Tokens
Dependencies: Settings, Orchard.Tokens, Orchard.Resources
Category: Social
Orchard.Comments.Workflows:
Name: Comments Workflows Activities

View File

@ -135,6 +135,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Assets\Scripts\Orchard.Comments.Threaded.js" />
<Content Include="Scripts\Orchard.Comments.Threaded.js" />
<Content Include="Scripts\Orchard.Comments.Threaded.min.js" />
<Content Include="Styles\images\menu.comments.png" />
<Content Include="Styles\menu.comments-admin.css" />
<Content Include="Styles\orchard-comments-admin.css" />
@ -211,6 +214,14 @@
<ItemGroup>
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\Web.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Assets.json" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@ -5,6 +5,9 @@ namespace Orchard.Comments {
public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add();
manifest.DefineStyle("Admin").SetUrl("orchard-comments-admin.css");
manifest.DefineScript("Comments.Threaded")
.SetUrl("Orchard.Comments.Threaded.min.js", "Orchard.Comments.Threaded.js").SetDependencies("jQuery");
}
}
}

View File

@ -0,0 +1,61 @@
/*
** NOTE: This file is generated by Gulp and should not be edited directly!
** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp.
*/
(function ($) {
$(document).ready(function () {
$('.comment-reply-form-settings').map(function () {
var $self = $(this);
var contentItemId = $self.data("contentitem-id");
var activeCommentId = $self.data('active-comment-id');
InitializeCommentReplyUI(contentItemId, activeCommentId);
});
$('.comment-reply-button').click(function () {
var $self = $(this);
var contentItemId = $self.data("contentitem-id");
var commentId = $self.data('id');
UpdateTheRepliedOnHiddenField(contentItemId, commentId);
MoveReplyFormToBeacon(contentItemId, commentId);
UpdateReplyButtonsUI(contentItemId, commentId);
return false;
});
});
function InitializeCommentReplyUI(contentItemId, activeCommentId) {
UpdateTheRepliedOnHiddenField(contentItemId, activeCommentId);
MoveReplyFormToBeacon(contentItemId, activeCommentId);
InitializeRootReplyButtonUI();
}
function InitializeRootReplyButtonUI(contentItemId, activeCommentId) {
if (activeCommentId === "root") {
$('.comment-reply-button[data-contentitem-id="' + contentItemId + '"][data-id="root"]').hide();
}
}
function UpdateTheRepliedOnHiddenField(contentItemId, commentId) {
var $reply = $('.comments-repliedon[data-contentitem-id="' + contentItemId + '"]');
// The ternary operator is because the UI uses root but Orchard expects the value to be empty
$reply.val(commentId === "root" ? "" : commentId);
}
function UpdateReplyButtonsUI(contentItemId, commentId) {
$('.comment-reply-button[data-contentitem-id="' + contentItemId + '"]').show();
$('.comment-reply-button[data-contentitem-id="' + contentItemId + '"][data-id="' + commentId + '"]').fadeOut("fast");
}
function MoveReplyFormToBeacon(contentItemId, commentId) {
var $replyFormBeacon = $('.comment-reply-form-beacon[data-contentitem-id="' + contentItemId + '"][data-id="' + commentId + '"]');
$('.comment-form[data-contentitem-id="' + contentItemId + '"]')
.slideUp("fast", function () {
$(this)
.appendTo($replyFormBeacon)
.slideDown();
});
}
})(jQuery)
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk9yY2hhcmQuQ29tbWVudHMuVGhyZWFkZWQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLEFBTEE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FB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Y29uID0gJCgnLmNvbW1lbnQtcmVwbHktZm9ybS1iZWFjb25bZGF0YS1jb250ZW50aXRlbS1pZD1cIicgKyBjb250ZW50SXRlbUlkICsgJ1wiXVtkYXRhLWlkPVwiJyArIGNvbW1lbnRJZCArICdcIl0nKTtcclxuICAgICAgICAkKCcuY29tbWVudC1mb3JtW2RhdGEtY29udGVudGl0ZW0taWQ9XCInICsgY29udGVudEl0ZW1JZCArICdcIl0nKVxyXG4gICAgICAgICAgICAuc2xpZGVVcChcImZhc3RcIiwgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgJCh0aGlzKVxyXG4gICAgICAgICAgICAgICAgICAgIC5hcHBlbmRUbygkcmVwbHlGb3JtQmVhY29uKVxyXG4gICAgICAgICAgICAgICAgICAgIC5zbGlkZURvd24oKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICB9XHJcbn0pKGpRdWVyeSkiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -0,0 +1 @@
!function(t){function n(t,n){e(t,n),a(t,n),o()}function o(n,o){"root"===o&&t('.comment-reply-button[data-contentitem-id="'+n+'"][data-id="root"]').hide()}function e(n,o){var e=t('.comments-repliedon[data-contentitem-id="'+n+'"]');e.val("root"===o?"":o)}function i(n,o){t('.comment-reply-button[data-contentitem-id="'+n+'"]').show(),t('.comment-reply-button[data-contentitem-id="'+n+'"][data-id="'+o+'"]').fadeOut("fast")}function a(n,o){var e=t('.comment-reply-form-beacon[data-contentitem-id="'+n+'"][data-id="'+o+'"]');t('.comment-form[data-contentitem-id="'+n+'"]').slideUp("fast",function(){t(this).appendTo(e).slideDown()})}t(document).ready(function(){t(".comment-reply-form-settings").map(function(){var o=t(this),e=o.data("contentitem-id"),i=o.data("active-comment-id");n(e,i)}),t(".comment-reply-button").click(function(){var n=t(this),o=n.data("contentitem-id"),d=n.data("id");return e(o,d),a(o,d),i(o,d),!1})})}(jQuery);

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<handlers accessPolicy="Script,Read">
<!-- For any request to a file exists on disk, return it via native http module. AccessPolicy="Script" above is to allow for a managed 404 page. -->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>

View File

@ -74,8 +74,7 @@
}
</td>
<td>
@* would ideally have permalinks for individual comments *@
<p><a href="@Url.ItemDisplayUrl(commentEntry.CommentedOn)#comments"><time>@Display.DateTime(DateTimeUtc: commentEntry.Comment.CommentDateUtc.GetValueOrDefault())</time></a></p>
<p><a href="@Url.ItemDisplayUrl(commentEntry.CommentedOn)#comment-@commentEntry.Comment.Id"><time>@Display.DateTime(DateTimeUtc: commentEntry.Comment.CommentDateUtc.GetValueOrDefault())</time></a></p>
@if (commentEntry.Comment.CommentText != null) {
var ellipsized = Html.Ellipsize(commentEntry.Comment.CommentText, 500);
var paragraphed = new HtmlString(ellipsized.ToHtmlString().Replace("\r\n", "</p><p>"));

View File

@ -3,4 +3,4 @@
CommentPart comment = Model.ContentPart;
}
@T("said") <time datetime="@comment.CommentDateUtc.GetValueOrDefault().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")">@Html.Link((string)Display.DateTimeRelative(DateTimeUtc: comment.CommentDateUtc.GetValueOrDefault()).ToString(), @Url.RouteUrl(comment.CommentedOnContentItemMetadata.DisplayRouteValues) + "#comment-" + comment.Id)</time>
@T("said") <time datetime="@comment.CommentDateUtc.GetValueOrDefault().ToString("yyyy-MM-ddTHH:mm:ss.fffZ")">@Html.Link((string)Display.DateTimeRelative(DateTimeUtc: comment.CommentDateUtc.GetValueOrDefault()).ToString(), @Url.RouteUrl(comment.CommentedOnContentItemMetadata.DisplayRouteValues) + "#comment-" + comment.Id)</time>

View File

@ -3,4 +3,4 @@
CommentPart comment = Model.ContentPart;
}
<a class="comment-reply-button" href="#" data-id="@comment.Id">@T("Reply")</a>
<a class="comment-reply-button" href="#" data-contentitem-id="@comment.CommentedOnContentItem.Id" data-id="@comment.Id">@T("Reply")</a>

View File

@ -1,38 +1,37 @@
@model Orchard.Comments.Models.CommentPart
@if (WorkContext.CurrentUser == null) {
<fieldset class="who">
<legend id="add-comment">@T("Add a Comment")</legend>
<legend class="add-comment">@T("Add a Comment")</legend>
<ol>
<li>
@Html.LabelFor(m => m.Author, T("Name"))
@Html.TextBoxFor(m => m.Author)
@Html.LabelFor(m => m.Author, T("Name").Text, new { id = string.Format("Comments_Author_{0}", Model.CommentedOn) })
@Html.TextBoxFor(m => m.Author, new { id = string.Format("Comments_Author_{0}", Model.CommentedOn) })
</li>
<li>
@Html.LabelFor(m => m.Email, T("Email"))
@Html.TextBoxFor(m => m.Email)
@Html.LabelFor(m => m.Email, T("Email").Text, new { id = string.Format("Comments_Email_{0}", Model.CommentedOn) })
@Html.TextBoxFor(m => m.Email, new { id = string.Format("Comments_Email_{0}", Model.CommentedOn) })
</li>
<li>
@Html.LabelFor(m => m.SiteName, T("Url"))
@Html.TextBoxFor(m => m.SiteName)
@Html.LabelFor(m => m.SiteName, T("Url").Text, new { id = string.Format("Comments_Url_{0}", Model.CommentedOn) })
@Html.TextBoxFor(m => m.SiteName, new { id = string.Format("Comments_Url_{0}", Model.CommentedOn) })
</li>
</ol>
</fieldset>
}
else {
@Html.Hidden("Name", WorkContext.CurrentUser.UserName ?? "")
@Html.Hidden("Email", WorkContext.CurrentUser.Email ?? "")
@Html.Hidden("Name", WorkContext.CurrentUser.UserName ?? "", new { id = string.Empty })
@Html.Hidden("Email", WorkContext.CurrentUser.Email ?? "", new { id = string.Empty })
}
@if (WorkContext.CurrentUser != null) {
<h2 class="commenter">@if (WorkContext.CurrentUser != null) { @T("Hi, {0}!", Convert.ToString(Html.ItemDisplayText(WorkContext.CurrentUser)))}</h2>
}
@if (WorkContext.CurrentUser != null) { <h2 id="commenter">@if (WorkContext.CurrentUser != null) { @T("Hi, {0}!", Convert.ToString(Html.ItemDisplayText(WorkContext.CurrentUser)))}</h2> }
<fieldset class="what">
<ol>
<li>
@Html.LabelFor(m => m.CommentText, T("Comment"))
@Html.TextAreaFor(m => m.CommentText, new { rows = 10, cols = 30, @class = "comment-text" })
@Html.LabelFor(m => m.CommentText, T("Comment").Text, new { id = string.Format("Comments_CommenText_{0}", Model.CommentedOn) })
@Html.TextAreaFor(m => m.CommentText, new { rows = 10, cols = 30, @class = "comment-text", id = string.Format("Comments_CommenText_{0}", Model.CommentedOn) })
</li>
</ol>
@Html.HiddenFor(m => m.CommentedOn)
@Html.HiddenFor(m => m.RepliedOn)
@Html.HiddenFor(m => m.CommentedOn, new { id = string.Empty })
@Html.HiddenFor(m => m.RepliedOn, new { @class = "comments-repliedon", data_contentitem_id = Model.CommentedOn, id = string.Empty })
</fieldset>

View File

@ -24,13 +24,15 @@
<h4>
<span class="who">@Display.CommentAuthor(ContentPart: comment)</span>
<span class="when">@Display.CommentMetadata(ContentPart: comment)</span>
@if (comments.ThreadedComments && comments.CommentsActive && isAuthorized) {
@Display.CommentReplyButton(ContentPart: comment)
}
</h4>
</header>
@Display.CommentText(ContentPart: Model.ContentPart, ContentItem: Model.ContentItem)
@if (comments.ThreadedComments && comments.CommentsActive && isAuthorized) {
<div>@Display.CommentReplyButton(ContentPart: comment)</div>
<div class="comment-reply-form-beacon" data-contentitem-id="@comment.CommentedOnContentItem.Id" data-id="@comment.ContentItem.Id"></div>
}
@Display(children)
@tag.EndElement

View File

@ -8,34 +8,39 @@
bool canStillCommentOn = Model.CanStillComment;
var settings = commentsPart.TypePartDefinition.Settings.GetModel<CommentsPartSettings>();
var isAuthorized = AuthorizedFor(Permissions.AddComment, Model.ContentItem);
var activeCommentId = TempData.ContainsKey("Comments.RepliedOn") ? TempData["Comments.RepliedOn"] : "root";
}
@if (!Model.ContentPart.CommentsActive || !canStillCommentOn) {
if (Model.ContentPart.Comments.Count > 0) {
<div id="comments">
<p class="comment-disabled">@T("Comments have been disabled for this content.")</p>
</div>
<div class="comments-disabled">
<p class="comment-disabled">@T("Comments have been disabled for this content.")</p>
</div>
}
}
else if ((settings.MustBeAuthenticated || !isAuthorized) && WorkContext.CurrentUser == null) {
<p class="info message">@T("You must {0} to comment.", Html.ActionLink(T("log on").ToString(), "LogOn",
new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = string.Format("{0}#addacomment", Context.Request.RawUrl) }))</p>
new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = string.Format("{0}#comments_{1}", Context.Request.RawUrl, commentsPart.ContentItem.Id) }))</p>
}
else if (WorkContext.CurrentUser != null && !isAuthorized) {
<div id="comments">
<div class="comments-disabled">
<p class="comment-disabled">@T("You are not authorized to add a comment.")</p>
</div>
}
else if (isAuthorized) {
if (Model.ContentPart.ThreadedComments && Model.ContentPart.CommentsActive) {
<div><a class="comment-reply-button" href="#" data-contentitem-id="@commentsPart.ContentItem.Id" data-id="root">@T("Start A New Thread")</a></div>
<div class="comment-reply-form-beacon" data-contentitem-id="@commentsPart.ContentItem.Id" data-id="root"></div>
<div class="comment-reply-form-settings" data-contentitem-id="@commentsPart.ContentItem.Id" data-active-comment-id="@activeCommentId"></div>
}
@Html.ValidationSummary()
<span id="comment-form-beacon"></span>
using (Html.BeginFormAntiForgeryPost(Url.Action("Create", "Comment", new { Area = "Orchard.Comments", ReturnUrl = Context.Request.ToUrlString() }), FormMethod.Post, new { @class = "comment-form" })) {
using (Html.BeginFormAntiForgeryPost(Url.Action("Create", "Comment", new { Area = "Orchard.Comments", ReturnUrl = Context.Request.ToUrlString() }), FormMethod.Post, new { @class = "comment-form", data_contentitem_id = commentsPart.ContentItem.Id })) {
if (TempData.ContainsKey("Comments.InvalidCommentEditorShape")) {
@Display(TempData["Comments.InvalidCommentEditorShape"]);
}
else {
@Display(Model.EditorShape)
}
<button class="primaryAction" type="submit">@T("Submit Comment")</button>
<button class="primaryAction" type="submit">@T("Submit Comment")</button>
}
}

View File

@ -4,6 +4,7 @@
// add 'comments' class on the list container
Model.List.Classes.Add("comments");
Model.List.Id = string.Format("comments_{0}", commentsPart.ContentItem.Id);
}
<h2 class="comment-count">@T.Plural("No Comments", "1 Comment", "{0} Comments", (int)Model.CommentCount)</h2>
@ -11,48 +12,5 @@
@* render reply button if threaded comments enabled *@
@if(commentsPart.ThreadedComments) {
Script.Require("jQuery");
using (Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
$(function() {
$('.comment-reply-button').click(function() {
var self = $(this);
var reply = $('#Comments_RepliedOn');
var currentReply = reply.val();
@* should we restore the form at its original location ? *@
if (currentReply && currentReply.length > 0) {
reply.val('');
$('#comment-form-beacon').after($('.comment-form'));
} else {
@* assign repliedOn id *@
var id = self.data('id');
reply.val(id);
@* inject the form in the replied zone *@
$('.comment-form').appendTo(self.parents('article').first());
}
@* don't execute the link action *@
return false;
});
@if (TempData.ContainsKey("Comments.RepliedOn")) {
// invalid form while replying
<text>
var reply = $('#Comments_RepliedOn');
reply.val(@TempData["Comments.RepliedOn"]);
$('.comment-form').appendTo($('#comment-@TempData["Comments.RepliedOn"]'));
</text>
}
});
//]]>
</script>
}
Script.Require("Comments.Threaded").AtFoot();
}

View File

@ -474,18 +474,17 @@ nav ul.breadcrumb
.meta {}
/* Comments */
#comments { margin: 24px 0 0 0; padding: 0; }
.comments-disabled { margin: 24px 0 0 0; padding: 0; }
.comment-form { margin: 24px 0 0 0; padding: 0; }
.comments { margin: 0; padding: 0; list-style: none; }
.comments { margin: 0 0 1em 0; padding: 0; list-style: none; }
.comments li { margin: 12px 0 0 0; padding: 12px; border: 1px solid #dbdbdb; }
.comments .comments { margin-bottom: 0; }
.comment { margin: 0; padding: 0; }
.comment h4 { font-size: 1.077em; }
.comment .who {}
.comment .what {}
.comment .reply { float: right;}
.comment #add-comment {}
.comment-form #comment-by { font-size: 1.231em; font-weight: normal; margin: 0 0 1.2em 0; border:none; }
.comment-form .comment-text { width: 33.2em; }
.comment-form .comment-text { width: 97%; max-width: 33.2em; }
.comment-form input[type="text"] { width: 32em; }
.comment-form li { border: inherit; margin: inherit; padding: inherit}
.comment-disabled {}