From f2950f4b226b5a7d388c4eb2fb6c383e72ac6d54 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Mon, 8 Jul 2013 12:49:49 +0200 Subject: Make a widget to add multiple attachments --- hyperkitty/static/js/hyperkitty-common.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'hyperkitty/static/js') diff --git a/hyperkitty/static/js/hyperkitty-common.js b/hyperkitty/static/js/hyperkitty-common.js index 2d2ff16..b9fc897 100644 --- a/hyperkitty/static/js/hyperkitty-common.js +++ b/hyperkitty/static/js/hyperkitty-common.js @@ -73,6 +73,33 @@ function setup_vote(baseElem) { } +/* + * New messages (or replies) + */ + +function setup_attachments() { + function add_attach_form (e) { + e.preventDefault(); + var form = $(this).parents("form").first(); + form.find(".attach-files-template") + .clone().removeClass("attach-files-template") + .appendTo(form.find(".attach-files")); + form.find(".attach-files span a").click(function (e) { + e.preventDefault(); + $(this).parent().remove(); + if (form.find(".attach-files input").length === 0) { + form.find(".attach-files-add").hide(); + form.find(".attach-files-first").show(); + }; + }); + 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); +} + + /* * Misc. */ @@ -110,4 +137,5 @@ $(document).ready(function() { setup_months_list(); setup_disabled_tooltips(); setup_flash_messages(); + setup_attachments(); }); -- cgit