hide child comments button

This commit is contained in:
Ryan Stafford 2023-07-05 15:26:26 -04:00
parent 2b5349466a
commit 88457d0818
6 changed files with 57 additions and 8 deletions

View file

@ -389,9 +389,10 @@ form.nsfw div {
.buttons a, .buttons form input, .comment .buttons form input { .buttons a, .buttons form input, .comment .buttons form input {
text-decoration: none; text-decoration: none;
color: #888; color: #888;
padding-right: 4px; display: inline-block;
margin-right: 8px !important;
} }
.buttons a:hover, .title a:hover, .buttons input:hover { .buttons a:hover, .title a:hover, .buttons form input:hover, .comment .buttons form input:hover {
text-decoration: underline; text-decoration: underline;
} }
.entry { .entry {
@ -431,7 +432,16 @@ form.nsfw div {
.expando-button:hover{ .expando-button:hover{
background-color: #466599; background-color: #466599;
} }
.expando-button.hidden { .expando-button.hidden, .children.hidden {
display: none;
}
.hidechildren .show {
display: none;
}
.hidechildren.hidden .show {
display: inline;
}
.hidechildren.hidden .hide {
display: none; display: none;
} }
.expando { .expando {

View file

@ -64,6 +64,20 @@ function commentClick(e) {
} }
return false return false
} }
if (e.target.className.indexOf("hidechildren") != -1) {
if (e.target.getAttribute("for") != targ.id) { return }
e.preventDefault()
var btn = targ.getElementsByClassName("hidechildren")[0]
var children = targ.getElementsByClassName("children")[0]
if (children.className.indexOf("hidden") == -1) {
children.className = "children hidden"
btn.className = "hidechildren hidden"
} else {
children.className = "children"
btn.className = "hidechildren"
}
return false
}
if ((e.target.className.indexOf("loadmore") != -1) || if ((e.target.className.indexOf("loadmore") != -1) ||
(e.target.className.indexOf("edit") != -1) || (e.target.className.indexOf("edit") != -1) ||
(e.target.className.indexOf("source") != -1) || (e.target.className.indexOf("source") != -1) ||
@ -77,6 +91,26 @@ function commentClick(e) {
return false return false
} }
} }
function hideAllChildComments(e) {
e.preventDefault()
var comments = document.getElementsByClassName("comment")
for (var i = 0; i < comments.length; i++) {
var comment = comments[i]
var btn = comment.getElementsByClassName("hidechildren")
if (!btn.length) { continue }
btn = btn[0]
if (btn.getAttribute("for") != comment.id) { continue }
var children = comment.getElementsByClassName("children")[0]
if (children.className.indexOf("hidden") == -1) {
children.className = "children hidden"
btn.className = "hidechildren hidden"
} else {
children.className = "children"
btn.className = "hidechildren"
}
}
return false
}
function formSubmit(e) { function formSubmit(e) {
e = e || window.event; e = e || window.event;
var targ = e.currentTarget || e.srcElement || e; var targ = e.currentTarget || e.srcElement || e;

View file

@ -79,6 +79,9 @@
</a> </a>
</li> </li>
{{ end }} {{ end }}
{{ end }}
{{ if gt .ChildCount 0 }}
<li><a class="hidechildren" for="c{{.P.Comment.ID}}" href=""><span class="hide">hide</span><span class="show">show {{ .ChildCount }}</span> child comments</a></li>
{{ end }} {{ end }}
</ul> </ul>
<div class="children"> <div class="children">

View file

@ -8,10 +8,9 @@
<body{{ if .Dark }} class="dark"{{end}}> <body{{ if .Dark }} class="dark"{{end}}>
<noscript> <noscript>
<style> <style>
.expando-button { .expando-button,
display: none; .minimize,
} .hidechildren {
.comment .meta a.minimize {
display: none; display: none;
} }
</style> </style>

View file

@ -66,6 +66,9 @@
{{ end }} {{ end }}
</form> </form>
{{end}} {{end}}
{{ if .State.PostID }}
<a class="hidechildren" onclick="hideAllChildComments(event)" href="">hide all child comments</a>
{{ end }}
</div> </div>
<div class="expando {{ if eq .Rank 0 }}open{{ end}}"> <div class="expando {{ if eq .Rank 0 }}open{{ end}}">
{{ if (and .Post.Body.IsValid (ne .Post.Body.String "")) }} {{ if (and .Post.Body.IsValid (ne .Post.Body.String "")) }}

View file

@ -66,7 +66,7 @@
{{ printer .Site.SiteView.Counts.Users }} readers <br> {{ printer .Site.SiteView.Counts.Users }} readers <br>
<span class="green" title="Users active in the last day"></span> <span class="green" title="Users active in the last day"></span>
{{ printer .Site.SiteView.Counts.UsersActiveDay }} users here now {{ printer .Site.SiteView.Counts.UsersActiveDay }} users here now
<p>{{ markdown .Host .Site.SiteView.Site.Sidebar.String }}</p> {{ markdown .Host .Site.SiteView.Site.Sidebar.String }}
<div class="age" title="{{ .Site.SiteView.Site.Published.Time}}">founded {{ humanize .Site.SiteView.Site.Published.Time }}</div> <div class="age" title="{{ .Site.SiteView.Site.Published.Time}}">founded {{ humanize .Site.SiteView.Site.Published.Time }}</div>
{{ if .Site.Admins }} {{ if .Site.Admins }}
ADMINS ADMINS