From b0f77440d971be4f1174b43c0353a8ae402f5e62 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 21 Jan 2015 22:41:39 +0100 Subject: [PATCH] Update email list in the new config menu --- public/js/vroom.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/public/js/vroom.js b/public/js/vroom.js index c566ff2..a3bda50 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -546,9 +546,12 @@ function initVroom(room) { if (countPeers() > 1){ $('.threePeersEl').show(500); } + $('.email-list').find('.email-entry:not(:first)').remove(); $.each(data.notif, function(index, obj){ addNotifiedEmail(obj.email); + addEmailInputField(obj.email); }); + $('.email-list').find('.email-entry:first').remove(); } // We're are not owner of the room else{ @@ -2028,18 +2031,20 @@ function initVroom(room) { $('#ownerPassFields').hide(200); } }); - // Add emails input fields - $(document).on('click','button.btn-add-email',function(e){ - e.preventDefault(); + function addEmailInputField(val){ var parentEl = $('.email-list'), - currentEntry = $(this).parents('.email-entry:first'), + currentEntry = parentEl.find('.email-entry:last'), newEntry = $(currentEntry.clone()).appendTo(parentEl); - // Clear the value of the new input field - newEntry.find('input').val(''); + newEntry.find('input').val(val); parentEl.find('.email-entry:not(:last) .btn-add-email') .removeClass('btn-primary').removeClass('btn-add-email') .addClass('btn-danger').addClass('btn-remove-email') .html(''); + } + // Add emails input fields + $(document).on('click','button.btn-add-email',function(e){ + e.preventDefault(); + addEmailInputField(''); }); $(document).on('click','button.btn-remove-email',function(e){ e.preventDefault();