mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-24 21:07:17 +00:00
Add repo create related js to sigle file
This commit is contained in:
55
templates/snippets/repo_create_js.html
Normal file
55
templates/snippets/repo_create_js.html
Normal file
@@ -0,0 +1,55 @@
|
||||
//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: '{{ 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) {
|
||||
console.log(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;
|
||||
});
|
Reference in New Issue
Block a user