Reformat JS
This commit is contained in:
@@ -67,57 +67,51 @@
|
|||||||
|
|
||||||
<%block name="jsextra">
|
<%block name="jsextra">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var $newUserForm;
|
|
||||||
var addUserPostbackUrl = "${add_user_postback_url}";
|
var addUserPostbackUrl = "${add_user_postback_url}";
|
||||||
var removeUserPostbackUrl = "${remove_user_postback_url}";
|
var removeUserPostbackUrl = "${remove_user_postback_url}";
|
||||||
|
|
||||||
function showNewUserForm(e) {
|
$(document).ready(function() {
|
||||||
e.preventDefault();
|
var $newUserForm = $('.new-user-form');
|
||||||
$newUserForm.slideDown(150);
|
$newUserForm.bind('submit', function(e) {
|
||||||
$newUserForm.find('.email-input').focus();
|
e.preventDefault();
|
||||||
}
|
$.ajax({
|
||||||
|
url: addUserPostbackUrl,
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: {
|
||||||
|
email: $('#email').val()
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
notifyOnError: false,
|
||||||
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
|
data = JSON.parse(jqXHR.responseText);
|
||||||
|
$('#result').show().empty().append(data.ErrMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function hideNewUserForm(e) {
|
var $cancelButton = $newUserForm.find('.cancel-button');
|
||||||
e.preventDefault();
|
$cancelButton.bind('click', function(e) {
|
||||||
$newUserForm.slideUp(150);
|
e.preventDefault();
|
||||||
$('#result').hide();
|
$newUserForm.slideUp(150);
|
||||||
$('#email').val('');
|
$('#result').hide();
|
||||||
}
|
$('#email').val('');
|
||||||
|
});
|
||||||
|
|
||||||
function checkForCancel(e) {
|
$('.new-user-button').bind('click', function(e) {
|
||||||
if(e.which == 27) {
|
e.preventDefault();
|
||||||
e.data.$cancelButton.click();
|
$newUserForm.slideDown(150);
|
||||||
}
|
$newUserForm.find('.email-input').focus();
|
||||||
}
|
});
|
||||||
|
|
||||||
function addUser(e) {
|
$('body').bind('keyup', function(e) {
|
||||||
e.preventDefault();
|
if(e.which == 27) {
|
||||||
|
$cancelButton.click();
|
||||||
$.ajax({
|
|
||||||
url: addUserPostbackUrl,
|
|
||||||
type: 'POST',
|
|
||||||
dataType: 'json',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify({ 'email': $('#email').val()}),
|
|
||||||
success: function(data) {
|
|
||||||
location.reload();
|
|
||||||
},
|
|
||||||
notifyOnError: false,
|
|
||||||
error: function(jqXHR, textStatus, errorThrown) {
|
|
||||||
data = JSON.parse(jqXHR.responseText);
|
|
||||||
$('#result').show().empty().append(data.ErrMsg);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
$newUserForm = $('.new-user-form');
|
|
||||||
var $cancelButton = $newUserForm.find('.cancel-button');
|
|
||||||
$newUserForm.bind('submit', addUser);
|
|
||||||
$cancelButton.bind('click', hideNewUserForm);
|
|
||||||
|
|
||||||
$('.new-user-button').bind('click', showNewUserForm);
|
|
||||||
$('body').bind('keyup', { $cancelButton: $cancelButton }, checkForCancel);
|
|
||||||
|
|
||||||
$('.remove-user').click(function() {
|
$('.remove-user').click(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -125,10 +119,13 @@
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data:JSON.stringify({ 'email': $(this).data('id')}),
|
data: {
|
||||||
}).done(function() {
|
email: $(this).data('id')
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
})
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user