mirror of
https://github.com/haiwen/seahub.git
synced 2025-06-30 00:42:53 +00:00
55 lines
1.7 KiB
HTML
55 lines
1.7 KiB
HTML
//repo-create-form
|
|
$('#repo-create')
|
|
.click(function() {
|
|
$('#repo-create-form').modal({appendTo: '#main', autoResize: true});
|
|
})
|
|
.hover(
|
|
function() {
|
|
$(this).css({'background-color': '#fff', 'cursor': 'pointer'});
|
|
},
|
|
function() {
|
|
$(this).css('background-color', '#f5f5f5');
|
|
}
|
|
);
|
|
$('#encrypt-switch').click(function () {
|
|
if ($(this).attr('checked')) {
|
|
$('#repo-create-form input[type="password"]').attr('disabled', false).removeClass('input-disabled');
|
|
} else {
|
|
$('#repo-create-form input[type="password"]').attr('disabled', true).addClass('input-disabled');
|
|
}
|
|
});
|
|
$('#repo-create-submit').click(function() {
|
|
var passwd = $('#repo-create-form input[name="passwd"]'),
|
|
passwd_again = $('#repo-create-form input[name="passwd_again"]');
|
|
|
|
$.ajax({
|
|
url: '{{ post_url }}',
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
cache: 'false',
|
|
beforeSend: prepareCSRFToken,
|
|
data: {
|
|
'repo_name': $('#repo-name').val(),
|
|
'repo_desc': $('#repo-desc').val(),
|
|
'encryption': $('#encrypt-switch').attr('checked') ? 1 : 0,
|
|
'passwd': passwd.val(),
|
|
'passwd_again': passwd_again.val()
|
|
},
|
|
success: function(data) {
|
|
if (data['success']) {
|
|
location.reload(true);
|
|
} else {
|
|
apply_form_error('repo-create-form', data['error']);
|
|
}
|
|
},
|
|
error: function(data, textStatus, jqXHR) {
|
|
var errors = $.parseJSON(data.responseText);
|
|
$.each(errors, function(index, value) {
|
|
apply_form_error('repo-create-form', value[0]);
|
|
});
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|