From 4e492de55a60af104d48f9bc1c8227234bc1445b Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 4 Feb 2015 21:58:55 +0100 Subject: [PATCH] Fix email input field handling --- 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 1b1c945..8fe817e 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -178,11 +178,10 @@ function maxHeight(){ function addEmailInputField(form, val){ var parentEl = $('#' + form), currentEntry = parentEl.find('.email-entry:last'), - newEntry = $(currentEntry.clone()).css('display', 'none').appendTo(parentEl); + newEntry = $(currentEntry.clone()).appendTo(parentEl); newEntry.find('input').val(val); newEntry.removeClass('has-error'); adjustAddRemoveEmailButtons(form); - newEntry.show(100); } // Adjust add and remove buttons foir email notifications function adjustAddRemoveEmailButtons(form){ @@ -503,9 +502,9 @@ function initAdmin(){ $.notify(locale.ERROR_OCCURRED, 'error'); }, success: function(data){ - // Reset the list of email displayed, so first remove evry input field but the first one + // Reset the list of email displayed, so first remove evry input field but the last one // We keep it so we can clone it again - $('.email-list').find('.email-entry:not(:first)').remove(); + $('.email-list').find('.email-entry:not(:last)').remove(); $.each(data.notif, function(index, obj){ addEmailInputField('email-list-notification', obj.email); }); @@ -513,6 +512,9 @@ function initAdmin(){ if (Object.keys(data.notif).length > 0){ $('.email-list').find('.email-entry:first').remove(); } + else{ + $('.email-list').find('.email-entry:first').find('input:first').val(''); + } adjustAddRemoveEmailButtons(); // Update config switches $('#lockedSet').bootstrapSwitch('state', data.locked == 'yes'); @@ -649,9 +651,9 @@ function initVroom(room) { if (data.role == 'owner'){ $('.unauthEl').hide(500); $('.ownerEl').show(500); - // Reset the list of email displayed, so first remove evry input field but the first one + // Reset the list of email displayed, so first remove evry input field but the last one // We keep it so we can clone it again - $('.email-list').find('.email-entry:not(:first)').remove(); + $('.email-list').find('.email-entry:not(:last)').remove(); $.each(data.notif, function(index, obj){ addEmailInputField('email-list-notification', obj.email); }); @@ -659,6 +661,9 @@ function initVroom(room) { if (Object.keys(data.notif).length > 0){ $('.email-list').find('.email-entry:first').remove(); } + else{ + $('.email-list').find('.email-entry:first').find('input:first').val(''); + } adjustAddRemoveEmailButtons(); } // We're are not owner of the room