# HG changeset patch # User Brian Neal # Date 1503262554 18000 # Node ID 130ac1e98cf48675e051e24a44ae2947f32a5912 # Parent 3d17714c9a26e708c9e43bb12b1335eee6114eaa More V3 forums tweaking. Adding attachments is working now. Adding a post via ajax is working. Still need to display attachments on posts. diff -r 3d17714c9a26 -r 130ac1e98cf4 forums/static/js/forums.js --- a/forums/static/js/forums.js Tue Apr 18 20:13:59 2017 -0500 +++ b/forums/static/js/forums.js Sun Aug 20 15:55:54 2017 -0500 @@ -21,13 +21,24 @@ dataType: 'html', success: function (data, textStatus) { postText.val(''); - var lastTr = $('#forum-topic tr:last'); - var newClass = lastTr.hasClass('odd') ? 'even' : 'odd'; - lastTr.after(data); - lastTr = $('#forum-topic tr:last'); - lastTr.addClass(newClass); - lastTr.hide(); - lastTr.fadeIn(3000); + var lastPost = $('#forum-topic-post-container > div:last-child'); + var firstCard = lastPost.find('div > div').first(); + var newCardClass = firstCard.hasClass('sg101-card1') ? 'sg101-card2' : 'sg101-card1'; + var newDividerClass = newCardClass == 'sg101-card1' ? 'sg101-card-divider1' : 'sg101-card-divider2'; + lastPost.after(data); + + lastPost = $('#forum-topic-post-container > div:last-child'); + var firstCard = lastPost.find('> div > div').first(); + firstCard.addClass(newCardClass); + var firstDivider = firstCard.find('> div').first(); + firstDivider.addClass(newDividerClass); + var lastCard = lastPost.find('> div:last-child > div').first(); + lastCard.addClass(newCardClass); + var lastDivider = lastCard.find('> div').first(); + lastDivider.addClass(newDividerClass); + + lastPost.hide(); + lastPost.fadeIn(3000); postButton.removeAttr('disabled').val('Submit Reply'); initAttachments(); }, @@ -179,10 +190,12 @@ { vid = 0; var s = '
' + - 'Add ' + - 'Attach Video
'; + '' + + ''; vidDiv.prepend(s); - $('#attachment a').click(function () { + $('#attachment button').click(function () { $('#init-add').remove(); addVideo(); return false; @@ -208,10 +221,21 @@ { var id = "video-" + vid; - var fakeForm = '
' + - 'Attach ' + - ' ' + - 'Remove
'; + var fakeForm = + '
' + + '
' + + '
' + + '' + + '' + + '
' + + '' + + '
' + + '
' + + '
' + + '
' + + 'Remove' + + '
' + + '
'; var n = $('#attachment div').length; @@ -229,7 +253,7 @@ } else { - $('#attachment div:last').after(fakeForm); + $('#attachment div.row:last').after(fakeForm); } $('#' + id + ' a').click(function() { @@ -253,12 +277,13 @@ success: function (data, textStatus) { $('#' + id + " .r").remove(); var myDiv = $('#' + id); - var html = '' + - 'Remove ' + - 'Remove' + - ''; + var html = + '
' + + data.embed + + '

Remove ' + + '

' + + '
'; myDiv.prepend(html); - myDiv.prepend(data.embed); $('#' + id + ' a').click(function() { myDiv.remove(); relabelAttachLink(); diff -r 3d17714c9a26 -r 130ac1e98cf4 forums/views/main.py --- a/forums/views/main.py Tue Apr 18 20:13:59 2017 -0500 +++ b/forums/views/main.py Sun Aug 20 15:55:54 2017 -0500 @@ -341,7 +341,7 @@ _bump_post_count(request.user) _update_last_visit(request.user, form.topic, datetime.datetime.now()) - return render(request, 'forums/display_post.html', { + return render(request, 'forums/display_post_v3.html', { 'post': post, 'can_moderate': perms.can_moderate(form.topic.forum, request.user), 'can_reply': True, diff -r 3d17714c9a26 -r 130ac1e98cf4 sg101/templates/forums/topic.html --- a/sg101/templates/forums/topic.html Tue Apr 18 20:13:59 2017 -0500 +++ b/sg101/templates/forums/topic.html Sun Aug 20 15:55:54 2017 -0500 @@ -31,11 +31,13 @@ New Topic {% include 'core/v3/pagination.html' %} +
{% for post in page.object_list %} {% cycle 'sg101-card1' 'sg101-card2' as card_class silent %} {% cycle 'sg101-card-divider1' 'sg101-card-divider2' as card_divider_class silent %} {% include 'forums/display_post_v3.html' %} {% endfor %} +
{% include 'core/v3/pagination.html' %} @@ -43,7 +45,8 @@ {% if last_page and can_reply %} -{% show_form "Reply to Topic" form "Submit Reply" 1 %} +{# show_form "Reply to Topic" form "Submit Reply" 1 #} +{% include 'forums/new_post_form.html' %} {% endif %} {% if user.is_authenticated %} @@ -116,8 +119,9 @@ {% endblock %} {% block custom_js %} - {% script_tags 'jquery-ui' %} + {% js_tags 'jquery-ui' %} + {% include "forums/jump_box.js" %} {% endblock %}