From 3c1e355bdf068aaaaf7594897e1b78caf732d4d2 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Sat, 3 Aug 2013 16:04:35 +0200 Subject: Fix attachments widget on replies --- hyperkitty/static/hyperkitty/js/hyperkitty-common.js | 9 ++++++--- hyperkitty/static/hyperkitty/js/hyperkitty-thread.js | 6 ++++++ hyperkitty/views/forms.py | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hyperkitty/static/hyperkitty/js/hyperkitty-common.js b/hyperkitty/static/hyperkitty/js/hyperkitty-common.js index b9fc897..1fb1eb3 100644 --- a/hyperkitty/static/hyperkitty/js/hyperkitty-common.js +++ b/hyperkitty/static/hyperkitty/js/hyperkitty-common.js @@ -77,7 +77,10 @@ function setup_vote(baseElem) { * New messages (or replies) */ -function setup_attachments() { +function setup_attachments(baseElem) { + if (!baseElem) { + baseElem = document; + } function add_attach_form (e) { e.preventDefault(); var form = $(this).parents("form").first(); @@ -95,8 +98,8 @@ function setup_attachments() { form.find(".attach-files-first").hide(); form.find(".attach-files-add").show(); } - $(".attach-files-add").click(add_attach_form); - $(".attach-files-first").click(add_attach_form); + $(baseElem).find(".attach-files-add").click(add_attach_form); + $(baseElem).find(".attach-files-first").click(add_attach_form); } diff --git a/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js b/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js index e6c726f..c7b69a5 100644 --- a/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js +++ b/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js @@ -145,6 +145,7 @@ function setup_favorites() { } + /* * Replies */ @@ -297,9 +298,13 @@ function setup_unreadnavbar(element) { } + /* * Thread replies list + * Updates the list of replies in a thread chunk-by-chunk to avoid blocking the + * UI */ + function update_thread_replies(url) { function load_more(current_url) { $.ajax({ @@ -315,6 +320,7 @@ function update_thread_replies(url) { fold_quotes(newcontent); setup_disabled_tooltips(newcontent); setup_vote(newcontent); + setup_attachments(newcontent); // load the rest if applicable if (data.more_pending) { load_more(url+"&offset="+data.next_offset); diff --git a/hyperkitty/views/forms.py b/hyperkitty/views/forms.py index 19bba26..648f43e 100644 --- a/hyperkitty/views/forms.py +++ b/hyperkitty/views/forms.py @@ -109,8 +109,8 @@ class AttachmentFileInput(forms.FileInput): %(input)s (-) -%(attach_first_text)s -%(attach_another_text)s +%(attach_first_text)s +%(attach_another_text)s """ def render(self, name, value, attrs=None): -- cgit