threaded comments :>

This commit is contained in:
posativ 2012-10-21 22:26:05 +02:00
parent eee2e43588
commit d6e4312e47
2 changed files with 21 additions and 10 deletions

View File

@ -61,7 +61,8 @@
text: text, text: text,
author: $('input[id="author"]').val() || null, author: $('input[id="author"]').val() || null,
email: $('input[id="email"]').val() || null, email: $('input[id="email"]').val() || null,
website: $('input[id="website"]').val() || null website: $('input[id="website"]').val() || null,
parent: id
}), }),
error: function(resp) { error: function(resp) {
alert("Mööp."); alert("Mööp.");
@ -114,22 +115,27 @@
author = '<a href="' + post['website'] + '" rel="nofollow">' + author + '</a>'; author = '<a href="' + post['website'] + '" rel="nofollow">' + author + '</a>';
} }
var date = new Date(parseInt(post['created']) * 1000); var date = new Date(parseInt(post['created']) * 1000);
$('#isso_thread ul').append( // create <ul /> for parent, if used
'<article class="isso">' + if (post['parent']) {
' <header><span class="author">' + author + '</span> schrieb am' + $('#isso_' + post['parent']).append('<ul></ul>');
' <span class="date">' + format(date, 'de', '%d. %B %Y um %H:%M') + ':' + }
' </span>' +
$(post['parent'] ? '#isso_' + post['parent'] + ' ul' : '#isso_thread ul').append(
'<article class="isso" id="isso_' + post['id'] + '">' +
' <header><span class="author">' + author + '</span>' +
' </header>' + post['text'] + ' </header>' + post['text'] +
' <footer>' + ' <footer>' +
' <a href="#" id="isso_' + post['id'] + '">Antworten</a>' + ' <a href="#">Antworten</a>' +
' <a href="#isso_' + post['id'] + '">#' + post['id'] + '</a>' +
' <span class="date">' + format(date, 'de', '%d.%m.%Y um %H:%M') +
' </span>' +
' </footer>' + ' </footer>' +
'</article>'); '</article>');
// ability to answer directly to a comment // ability to answer directly to a comment
$('#isso_' + post['id']).on('click', function(event) { $('footer > a:first-child', '#isso_' + post['id']).on('click', function(event) {
if ($('#issoform_' + post['id']).length == 0) { if ($('#issoform_' + post['id']).length == 0) {
createForm(post['id'], function(html) {$('#isso_' + post['id']).after(html)}); createForm(post['id'], function(html) {$('#isso_' + post['id']).after(html)});

View File

@ -13,13 +13,18 @@
} }
.isso .date { .isso .date {
color: gray; color: lightgray;
padding-left: 12px;
} }
.isso header { .isso header {
border-bottom: solid 1px lightgray; border-bottom: solid 1px lightgray;
} }
.isso + .issoform {
margin-left: 20px;
}
.issoform input, .issoform textarea { .issoform input, .issoform textarea {
border: 4px solid rgba(0,0,0,0.1); border: 4px solid rgba(0,0,0,0.1);
padding: 8px 10px; padding: 8px 10px;