|
|
@ -175,22 +175,22 @@ function maxHeight(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Create a new input field
|
|
|
|
// Create a new input field
|
|
|
|
function addEmailInputField(val){ |
|
|
|
function addEmailInputField(form, val){ |
|
|
|
var parentEl = $('.email-list'), |
|
|
|
var parentEl = $('#' + form), |
|
|
|
currentEntry = parentEl.find('.email-entry:last'), |
|
|
|
currentEntry = parentEl.find('.email-entry:last'), |
|
|
|
newEntry = $(currentEntry.clone()).css('display', 'none').appendTo(parentEl); |
|
|
|
newEntry = $(currentEntry.clone()).css('display', 'none').appendTo(parentEl); |
|
|
|
newEntry.find('input').val(val); |
|
|
|
newEntry.find('input').val(val); |
|
|
|
newEntry.removeClass('has-error'); |
|
|
|
newEntry.removeClass('has-error'); |
|
|
|
adjustAddRemoveEmailButtons(); |
|
|
|
adjustAddRemoveEmailButtons(form); |
|
|
|
newEntry.show(100); |
|
|
|
newEntry.show(100); |
|
|
|
} |
|
|
|
} |
|
|
|
// Adjust add and remove buttons foir email notifications
|
|
|
|
// Adjust add and remove buttons foir email notifications
|
|
|
|
function adjustAddRemoveEmailButtons(){ |
|
|
|
function adjustAddRemoveEmailButtons(form){ |
|
|
|
$('.email-list').find('.email-entry:not(:last) .btn-add-email') |
|
|
|
$('#' + form).find('.email-entry:not(:last) .btn-add-email') |
|
|
|
.removeClass('btn-primary').removeClass('btn-add-email') |
|
|
|
.removeClass('btn-primary').removeClass('btn-add-email') |
|
|
|
.addClass('btn-danger').addClass('btn-remove-email') |
|
|
|
.addClass('btn-danger').addClass('btn-remove-email') |
|
|
|
.html('<span class="glyphicon glyphicon-minus"></span>'); |
|
|
|
.html('<span class="glyphicon glyphicon-minus"></span>'); |
|
|
|
$('.email-list').find('.email-entry:last .btn-remove-email') |
|
|
|
$('#' + form).find('.email-entry:last .btn-remove-email') |
|
|
|
.removeClass('btn-danger').removeClass('btn-remove-email') |
|
|
|
.removeClass('btn-danger').removeClass('btn-remove-email') |
|
|
|
.addClass('btn-primary').addClass('btn-add-email') |
|
|
|
.addClass('btn-primary').addClass('btn-add-email') |
|
|
|
.html('<span class="glyphicon glyphicon-plus"></span>'); |
|
|
|
.html('<span class="glyphicon glyphicon-plus"></span>'); |
|
|
@ -198,7 +198,7 @@ function adjustAddRemoveEmailButtons(){ |
|
|
|
// Add emails input fields
|
|
|
|
// Add emails input fields
|
|
|
|
$(document).on('click','button.btn-add-email',function(e){ |
|
|
|
$(document).on('click','button.btn-add-email',function(e){ |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
addEmailInputField(''); |
|
|
|
addEmailInputField($(this).parents('.email-list:first').attr('id'), ''); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$(document).on('click','button.btn-remove-email',function(e){ |
|
|
|
$(document).on('click','button.btn-remove-email',function(e){ |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
@ -506,7 +506,7 @@ function initAdmin(){ |
|
|
|
// We keep it so we can clone it again
|
|
|
|
// We keep it so we can clone it again
|
|
|
|
$('.email-list').find('.email-entry:not(:first)').remove(); |
|
|
|
$('.email-list').find('.email-entry:not(:first)').remove(); |
|
|
|
$.each(data.notif, function(index, obj){ |
|
|
|
$.each(data.notif, function(index, obj){ |
|
|
|
addEmailInputField(obj.email); |
|
|
|
addEmailInputField('email-list-notification', obj.email); |
|
|
|
}); |
|
|
|
}); |
|
|
|
// Now, remove the first one if the list is not empty
|
|
|
|
// Now, remove the first one if the list is not empty
|
|
|
|
if (Object.keys(data.notif).length > 0){ |
|
|
|
if (Object.keys(data.notif).length > 0){ |
|
|
@ -652,7 +652,7 @@ function initVroom(room) { |
|
|
|
// We keep it so we can clone it again
|
|
|
|
// We keep it so we can clone it again
|
|
|
|
$('.email-list').find('.email-entry:not(:first)').remove(); |
|
|
|
$('.email-list').find('.email-entry:not(:first)').remove(); |
|
|
|
$.each(data.notif, function(index, obj){ |
|
|
|
$.each(data.notif, function(index, obj){ |
|
|
|
addEmailInputField(obj.email); |
|
|
|
addEmailInputField('email-list-notification', obj.email); |
|
|
|
}); |
|
|
|
}); |
|
|
|
// Now, remove the first one if the list is not empty
|
|
|
|
// Now, remove the first one if the list is not empty
|
|
|
|
if (Object.keys(data.notif).length > 0){ |
|
|
|
if (Object.keys(data.notif).length > 0){ |
|
|
@ -1597,20 +1597,35 @@ function initVroom(room) { |
|
|
|
// Handle Email Invitation
|
|
|
|
// Handle Email Invitation
|
|
|
|
$('#inviteEmail').submit(function(event) { |
|
|
|
$('#inviteEmail').submit(function(event) { |
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault(); |
|
|
|
var rcpt = $('#recipient').val(); |
|
|
|
var rcpts = [], |
|
|
|
message = $('#message').val(); |
|
|
|
message = $('#message').val(); |
|
|
|
|
|
|
|
$('input[name="invitation-recipients[]"]').each(function(){ |
|
|
|
|
|
|
|
rcpts.push($(this).val()); |
|
|
|
|
|
|
|
}); |
|
|
|
// Simple email address verification
|
|
|
|
// Simple email address verification
|
|
|
|
// not fullproof, but email validation is a real nightmare
|
|
|
|
// not fullproof, but email validation is a real nightmare
|
|
|
|
if (!rcpt.match(/\S+@\S+\.\S+/)){ |
|
|
|
var validEmail = true; |
|
|
|
$.notify(locale.ERROR_MAIL_INVALID, 'error'); |
|
|
|
$('.email-list').find('input').each(function(index, input){ |
|
|
|
return; |
|
|
|
if (!$(input).val().match(/\S+@\S+\.\S+/) && $(input).val() !== ''){ |
|
|
|
|
|
|
|
$(input).parent().addClass('has-error'); |
|
|
|
|
|
|
|
//$(input).parent().notify(locale.ERROR_MAIL_INVALID, 'error');
|
|
|
|
|
|
|
|
validEmail = false; |
|
|
|
|
|
|
|
// Break the each loop
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
$(input).parent().removeClass('has-error'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (!validEmail){ |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
req: JSON.stringify({ |
|
|
|
req: JSON.stringify({ |
|
|
|
action: 'invite_email', |
|
|
|
action: 'invite_email', |
|
|
|
param: { |
|
|
|
param: { |
|
|
|
rcpt: rcpt, |
|
|
|
rcpts: rcpts, |
|
|
|
message: message, |
|
|
|
message: message, |
|
|
|
room: roomName |
|
|
|
room: roomName |
|
|
|
} |
|
|
|
} |
|
|
|