Add thread indicator for flat comments (#134)

This commit is contained in:
Ben Halpern 2018-03-23 14:38:06 -04:00 committed by GitHub
parent eadfb3830b
commit cc0ffe1c5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 20 deletions

View file

@ -97,27 +97,31 @@ function initializeCommentsPage() {
var butt = replyButts[i];
butt.onclick = function(event) {
event.preventDefault();
var userStatus = document.getElementsByTagName('body')[0].getAttribute('data-user-status');
if (userStatus == 'logged-out') {
showModal('reply-to-comment');
return;
}
var actionNode = event.target.parentNode;
var parentId = actionNode.dataset.commentId;
document.getElementById("button-for-comment-"+actionNode.dataset.commentId).style.zIndex = "5";
var waitingOnCSRF = setInterval(function () {
var metaTag = document.querySelector("meta[name='csrf-token']");
if (metaTag) {
clearInterval(waitingOnCSRF);
actionNode.innerHTML = buildCommentFormHTML(commentableId, commentableType, parentId);
setTimeout(function () {
actionNode.getElementsByTagName('textarea')[0].focus();
}, 30);
if (event.target.classList.contains("thread-indication")){
return false;
} else {
var userStatus = document.getElementsByTagName('body')[0].getAttribute('data-user-status');
if (userStatus == 'logged-out') {
showModal('reply-to-comment');
return;
}
}, 1);
// document.getElementById('textarea-for-'+parentId).focus();
var actionNode = event.target.parentNode;
var parentId = actionNode.dataset.commentId;
document.getElementById("button-for-comment-"+actionNode.dataset.commentId).style.zIndex = "5";
var waitingOnCSRF = setInterval(function () {
var metaTag = document.querySelector("meta[name='csrf-token']");
if (metaTag) {
clearInterval(waitingOnCSRF);
actionNode.innerHTML = buildCommentFormHTML(commentableId, commentableType, parentId);
setTimeout(function () {
actionNode.getElementsByTagName('textarea')[0].focus();
}, 30);
}
}, 1);
// document.getElementById('textarea-for-'+parentId).focus();
};
return false;
};
}
}
var editButts = document.getElementsByClassName('edit-butt');
for (var i = 0; i < editButts.length; i++) {

View file

@ -367,6 +367,7 @@ a.header-link{
}
}
.comment-deep-3{
margin-top: -5px;
padding:2px 0px 2px calc(0.9vw + 7px);
button{
margin-bottom:3px;
@ -702,6 +703,14 @@ a.header-link{
font-stretch:condensed;
width: calc(100% - 74px);
margin-left: 58px;
a.thread-indication{
color: lighten($medium-gray, 22%);
font-size: 0.8em;
cursor: default;
&:hover{
opacity:1;
}
}
.current-user-actions{
.hidden{
display:none;

View file

@ -180,9 +180,9 @@ class Onboarding extends Component {
}
closeOnboarding() {
document.getElementsByTagName('body')[0].classList.remove('modal-open');
this.handleBulkFollowUsers(this.state.checkedUsers);
const csrfToken = document.querySelector("meta[name='csrf-token']").content;
document.getElementsByTagName('body')[0].classList.remove('modal-open');
const formData = new FormData();
formData.append('saw_onboarding', true);

View file

@ -61,6 +61,8 @@
<% end %>
<% if comment.depth < 2 || comment.is_childless? %>
<a href="#<%=commentable.path%>/comments/new/<%= comment.id_code_generated %>" class="toggle-reply-form" rel="nofollow">REPLY</a>
<% else %>
<a href="#<%=commentable.path%>/comments/new/<%= comment.id_code_generated %>" class="toggle-reply-form thread-indication" rel="nofollow">THREAD</a>
<% end %>
</div>
</div>