PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/User controls/CommentView.ascx

#
ASP.NET | 152 lines | 115 code | 21 blank | 16 comment | 9 complexity | cfec5cb80f10673f2a321ac8e645cc9a MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. <%@ Control Language="C#" AutoEventWireup="true" CodeFile="CommentView.ascx.cs" Inherits="UserControls.CommentView" %>
  2. <%@ Import Namespace="BlogEngine.Core" %>
  3. <% if (CommentCounter > 0)
  4. { %>
  5. <h3 id="comment">
  6. <%=Resources.labels.comments %> (<%=CommentCounter%>)
  7. <a id="commenttoggle" style="float:right;width:20px;height:20px;border:1px solid #ccc;text-decoration:none;text-align:center" href="javascript:toggle_visibility('commentlist', 'commenttoggle');">-</a>
  8. </h3>
  9. <%} %>
  10. <div id="commentlist" style="display:block">
  11. <asp:PlaceHolder runat="server" ID="phComments" />
  12. </div>
  13. <asp:PlaceHolder runat="server" ID="phTrckbacks"></asp:PlaceHolder>
  14. <asp:PlaceHolder runat="Server" ID="phAddComment">
  15. <div id="comment-form">
  16. <img src="<%=Utils.RelativeWebRoot %>pics/ajax-loader.gif" alt="Saving the comment" style="display:none" id="ajaxLoader" />
  17. <span id="status"></span>
  18. <div class="commentForm">
  19. <h3 id="addcomment"><%=Resources.labels.addComment %></h3>
  20. <% if (NestingSupported){ %>
  21. <asp:HiddenField runat="Server" ID="hiddenReplyTo" />
  22. <p id="cancelReply" style="display:none;"><a href="javascript:void(0);" onclick="BlogEngine.cancelReply();"><%=Resources.labels.cancelReply %></a></p>
  23. <%} %>
  24. <p>
  25. <label for="<%=this.NameInputId %>" class="lbl-user"><%=Resources.labels.name %>*</label>
  26. <input type="text" class="txt-user" name="<%= this.NameInputId %>" id="<%= this.NameInputId %>" tabindex="2" value="<%= this.DefaultName %>" />
  27. <span id="spnNameRequired" style="color:Red;display:none;"> <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:labels, required %>"></asp:Literal></span>
  28. <span id="spnChooseOtherName" style="color:Red;display:none;"> <asp:Literal ID="Literal2" runat="server" Text="<%$Resources:labels, chooseOtherName %>"></asp:Literal></span>
  29. </p>
  30. <p>
  31. <label for="<%=txtEmail.ClientID %>" class="lbl-email"><%=Resources.labels.email %>*</label>
  32. <asp:TextBox runat="Server" CssClass="lbl-email" ID="txtEmail" TabIndex="3" ValidationGroup="AddComment" />
  33. <span id="gravatarmsg"></span>
  34. <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtEmail" ErrorMessage="<%$Resources:labels, required %>" Display="dynamic" ValidationGroup="AddComment" />
  35. <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail" ErrorMessage="<%$Resources:labels, enterValidEmail%>" Display="dynamic" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="AddComment" />
  36. </p>
  37. <% if (BlogSettings.Instance.EnableWebsiteInComments){ %>
  38. <p>
  39. <label for="<%=txtWebsite.ClientID %>" class="lbl-website"><%=Resources.labels.website%></label>
  40. <asp:TextBox runat="Server" CssClass="txt-website" ID="txtWebsite" TabIndex="4" ValidationGroup="AddComment" />
  41. <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="Server" ControlToValidate="txtWebsite" ValidationExpression="(http://|https://|)([\w-]+\.)+[\w-]+(/[\w- ./?%&=;~]*)?" ErrorMessage="<%$Resources:labels, enterValidUrl %>" Display="Dynamic" ValidationGroup="AddComment" />
  42. </p>
  43. <%} %>
  44. <% if(BlogSettings.Instance.EnableCountryInComments){ %>
  45. <p>
  46. <label for="<%=ddlCountry.ClientID %>" class="lbl-country"><%=Resources.labels.country %></label>
  47. <asp:DropDownList runat="server" CssClass="txt-country" ID="ddlCountry" onchange="BlogEngine.setFlag(this.value)" TabIndex="5" EnableViewState="false" ValidationGroup="AddComment" />&nbsp;
  48. <span class="CommentFlag"><asp:Image runat="server" ID="imgFlag" AlternateText="Country flag" Width="16" Height="11" EnableViewState="false" /></span>
  49. </p>
  50. <%} %>
  51. <blog:SimpleCaptchaControl ID="simplecaptcha" runat="server" TabIndex="6" />
  52. <%if (BlogEngine.Core.Web.Extensions.ExtensionManager.ExtensionEnabled("BBCode")){%>
  53. <span class="bbcode<%=!BlogSettings.Instance.ShowLivePreview ? " bbcodeNoLivePreview" : ""%>" title="BBCode tags"><%=BBCodes()%></span>
  54. <%}%>
  55. <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtContent" ErrorMessage="<%$Resources:labels, required %>" Display="dynamic" ValidationGroup="AddComment" /><br />
  56. <% if (BlogSettings.Instance.ShowLivePreview) { %>
  57. <ul id="commentMenu">
  58. <li id="compose" class="selected" onclick="BlogEngine.composeComment()"><%=Resources.labels.comment%></li>
  59. <li id="preview" onclick="BlogEngine.showCommentPreview()"><%=Resources.labels.livePreview%></li>
  60. </ul>
  61. <% } %>
  62. <div id="commentCompose">
  63. <label for="<%=txtContent.ClientID %>" class="lbl-content" style="display:none"><%=Resources.labels.comment%></label>
  64. <asp:TextBox runat="server" CssClass="txt-content" ID="txtContent" TextMode="multiLine" Columns="50" Rows="10" TabIndex="7" ValidationGroup="AddComment" />
  65. </div>
  66. <div id="commentPreview">
  67. <img src="<%=Utils.RelativeWebRoot %>pics/ajax-loader.gif" style="display:none" alt="Loading" />
  68. </div>
  69. <p>
  70. <input type="checkbox" id="cbNotify" class="cmnt-frm-notify" style="width: auto" tabindex="8" />
  71. <label for="cbNotify" style="width:auto;float:none;display:inline;padding-left:5px"><%=Resources.labels.notifyOnNewComments %></label>
  72. </p>
  73. <blog:RecaptchaControl ID="recaptcha" runat="server" TabIndex="9" />
  74. <p>
  75. <input type="button" id="btnSaveAjax" class="btn-save" style="margin-top:10px" value="<%=Resources.labels.saveComment %>" onclick="return BlogEngine.validateAndSubmitCommentForm()" tabindex="10" />
  76. <asp:HiddenField runat="server" ID="hfCaptcha" />
  77. </p>
  78. </div>
  79. </div>
  80. <script type="text/javascript">
  81. <!--//
  82. function registerCommentBox(){
  83. BlogEngine.comments.flagImage = BlogEngine.$("<%= imgFlag.ClientID %>");
  84. BlogEngine.comments.contentBox = BlogEngine.$("<%=txtContent.ClientID %>");
  85. BlogEngine.comments.moderation = <%=BlogSettings.Instance.EnableCommentsModeration.ToString().ToLowerInvariant() %>;
  86. BlogEngine.comments.checkName = <%=(!Security.IsAuthenticated).ToString().ToLowerInvariant() %>;
  87. BlogEngine.comments.postAuthor = "<%=Post.Author %>";
  88. BlogEngine.comments.nameBox = BlogEngine.$("<%= this.NameInputId %>");
  89. BlogEngine.comments.emailBox = BlogEngine.$("<%=txtEmail.ClientID %>");
  90. BlogEngine.comments.websiteBox = BlogEngine.$("<%=txtWebsite.ClientID %>");
  91. BlogEngine.comments.countryDropDown = BlogEngine.$("<%=ddlCountry.ClientID %>");
  92. BlogEngine.comments.captchaField = BlogEngine.$('<%=hfCaptcha.ClientID %>');
  93. BlogEngine.comments.controlId = '<%=this.UniqueID %>';
  94. BlogEngine.comments.replyToId = BlogEngine.$("<%=hiddenReplyTo.ClientID %>");
  95. }
  96. //-->
  97. </script>
  98. <% if (BlogSettings.Instance.IsCoCommentEnabled){ %>
  99. <script type="text/javascript">
  100. // this ensures coComment gets the correct values
  101. coco =
  102. {
  103. tool: "BlogEngine",
  104. siteurl: "<%=Utils.AbsoluteWebRoot %>",
  105. sitetitle: "<%=BlogSettings.Instance.Name %>",
  106. pageurl: location.href,
  107. pagetitle: "<%=this.Post.Title %>",
  108. author: "<%=this.Post.Title %>",
  109. formID: "<%=Page.Form.ClientID %>",
  110. textareaID: "<%=txtContent.UniqueID %>",
  111. buttonID: "btnSaveAjax"
  112. }
  113. </script>
  114. <script id="cocomment-fetchlet" src="http://www.cocomment.com/js/enabler.js" type="text/javascript"></script>
  115. <%} %>
  116. </asp:PlaceHolder>
  117. <script type="text/javascript">
  118. function toggle_visibility(id, id2) {
  119. var e = document.getElementById(id);
  120. var h = document.getElementById(id2);
  121. if (e.style.display == 'block') {
  122. e.style.display = 'none';
  123. h.innerHTML = "+";
  124. }
  125. else {
  126. e.style.display = 'block';
  127. h.innerHTML = "-";
  128. }
  129. }
  130. </script>
  131. <asp:label runat="server" id="lbCommentsDisabled" visible="false"><%=Resources.labels.commentsAreClosed %></asp:label>