more comment fixes

This commit is contained in:
flash 2016-12-06 20:27:58 +01:00
parent ff422ab7e2
commit aba08bd03f
3 changed files with 15 additions and 17 deletions

View file

@ -1,5 +1,9 @@
.comment-container { .comment-container {
list-style: none; list-style: none;
&--reply {
margin-left: 40px;
}
} }
.comments { .comments {
@ -51,7 +55,6 @@
&__content { &__content {
border-radius: 5px; border-radius: 5px;
border: 0; border: 0;
min-height: 50px;
flex-grow: 2; flex-grow: 2;
padding: 5px; padding: 5px;
margin: 2px; margin: 2px;
@ -116,8 +119,4 @@
background: linear-gradient(90deg, #f6f6f6 0%, #b6b6b6 100%); background: linear-gradient(90deg, #f6f6f6 0%, #b6b6b6 100%);
} }
} }
&__replies {
margin-left: 40px;
}
} }

View file

@ -1,4 +1,4 @@
<li id="comment-{{ comment.id }}" class="comment-container"> <li id="comment-{{ comment.id }}" class="comment-container{% if comment_depth > 0 and comment_depth < 6 %} comment-container--reply{% endif %}">
<div class="comment"> <div class="comment">
<a class="avatar avatar--border comment__avatar{% if comment_depth == 0 %} comment__avatar--big{% endif %}" href="{{ route('user.profile', comment.userData.id) }}" style="background-image: url('{{ route('user.avatar', comment.userData.id) }}');"> <a class="avatar avatar--border comment__avatar{% if comment_depth == 0 %} comment__avatar--big{% endif %}" href="{{ route('user.profile', comment.userData.id) }}" style="background-image: url('{{ route('user.avatar', comment.userData.id) }}');">
<span class="comment__username" style="color: {{ comment.userData.colour }};"> <span class="comment__username" style="color: {{ comment.userData.colour }};">

View file

@ -8,7 +8,7 @@
</span> </span>
</div> </div>
<div class="comment__pointer"></div> <div class="comment__pointer"></div>
<textarea class="comment__content comment__content--create" name="text" placeholder="Join the conversation..."></textarea> <textarea class="comment__content comment__content--create comment__content--parent" name="text" placeholder="Join the conversation..."></textarea>
<button <button
class="comment__submit comment__submit--new" class="comment__submit comment__submit--new"
name="session" name="session"
@ -155,7 +155,7 @@
var discussion = document.getElementById('comments').querySelector('.comments__list'); var discussion = document.getElementById('comments').querySelector('.comments__list');
if (obj.reply) { if (obj.reply) {
discussion = document.getElementById('comment-' + obj.reply).querySelector('.comment-replies'); discussion = document.getElementById('comment-' + obj.reply).querySelector('.comment__replies');
} }
if (discussion.children.length > 0) { if (discussion.children.length > 0) {
@ -183,13 +183,14 @@
// Remove it if it already exists // Remove it if it already exists
if (replyBox) { if (replyBox) {
Sakura.DOM.Remove('comment-reply-container-' + id); Sakura.DOM.Remove(replyBox);
return; return;
} }
// Container // Container
var replyContainer = document.createElement('li'); var replyContainer = document.createElement('li');
replyContainer.id = 'comment-reply-container-' + id; replyContainer.id = 'comment-reply-container-' + id;
replyContainer.className = 'comment-container';
// Comment container // Comment container
var replyDiv = document.createElement('div'); var replyDiv = document.createElement('div');
@ -198,24 +199,25 @@
// Avatar // Avatar
var replyAvatar = document.createElement('div'); var replyAvatar = document.createElement('div');
replyAvatar.className = 'comment-avatar'; replyAvatar.className = 'avatar avatar--border comment__avatar';
replyAvatar.style.backgroundImage = 'url(' + avatar + ')'; replyAvatar.style.backgroundImage = 'url(' + avatar + ')';
replyDiv.appendChild(replyAvatar); replyDiv.appendChild(replyAvatar);
// Pointer // Pointer
var replyPoint = document.createElement('div'); var replyPoint = document.createElement('div');
replyPoint.className = 'comment-pointer'; replyPoint.className = 'comment__pointer';
replyDiv.appendChild(replyPoint); replyDiv.appendChild(replyPoint);
// Textarea // Textarea
var replyText = document.createElement('textarea'); var replyText = document.createElement('textarea');
replyText.className = 'comment-content'; replyText.className = 'comment__content comment__content--create';
replyText.placeholder = 'Type your reply here...';
replyText.name = 'text'; replyText.name = 'text';
replyDiv.appendChild(replyText); replyDiv.appendChild(replyText);
// Submit // Submit
var replySubmit = document.createElement('button'); var replySubmit = document.createElement('button');
replySubmit.className = 'comment-submit'; replySubmit.className = 'comment__submit';
replySubmit.name = 'session'; replySubmit.name = 'session';
replySubmit.value = session; replySubmit.value = session;
replySubmit.setAttribute('onclick', 'commentPost(this.parentNode, "' + url + '"); commentReply(' + id + ');'); replySubmit.setAttribute('onclick', 'commentPost(this.parentNode, "' + url + '"); commentReply(' + id + ');');
@ -237,14 +239,13 @@
var url = "{{ route('comments.comment.delete', 1) }}".replace(1, id); var url = "{{ route('comments.comment.delete', 1) }}".replace(1, id);
commentClient.SetUrl(url); commentClient.SetUrl(url);
commentClient.AddCallback(200, function () { commentClient.AddCallback(200, function () {
var resp = JSON.parse(commentClient.Response()); var resp = JSON.parse(commentClient.Response());
if (resp.error) { if (resp.error) {
Yuuno.Busy.Show(Yuuno.BusyMode.FAIL, resp.error, 1500); Yuuno.Busy.Show(Yuuno.BusyMode.FAIL, resp.error, 1500);
} else { } else {
Sakura.DOM.Remove('comment-' + id); Sakura.DOM.Remove(Sakura.DOM.ID('comment-' + id));
} }
}); });
@ -257,9 +258,7 @@
downvotes = document.getElementById("comment-" + id + "-dislikes"); downvotes = document.getElementById("comment-" + id + "-dislikes");
commentClient.SetSend({"vote":vote}); commentClient.SetSend({"vote":vote});
commentClient.SetUrl(url); commentClient.SetUrl(url);
commentClient.AddCallback(200, function () { commentClient.AddCallback(200, function () {
var resp = JSON.parse(commentClient.Response()); var resp = JSON.parse(commentClient.Response());