mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-25 14:50:29 +00:00
Add repo create related js to sigle file
This commit is contained in:
@@ -254,6 +254,6 @@ $('#user-profile').hover(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
{% include 'group/msg_reply_js.html' %}
|
{% include 'group/msg_reply_js.html' %}
|
||||||
{% include 'group/create_group_repo_js.html' %}
|
{% include 'snippets/repo_create_js.html' %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -257,6 +257,7 @@ def render_group_info(request, group_id, form):
|
|||||||
'next_page': current_page+1,
|
'next_page': current_page+1,
|
||||||
'per_page': per_page,
|
'per_page': per_page,
|
||||||
'page_next': page_next,
|
'page_next': page_next,
|
||||||
|
'url': reverse('create_group_repo', args=[group_id]),
|
||||||
}, context_instance=RequestContext(request));
|
}, context_instance=RequestContext(request));
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@@ -67,5 +67,6 @@
|
|||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{% include "snippets/myhome_extra_script.html" %}
|
{% include "snippets/myhome_extra_script.html" %}
|
||||||
|
{% include "snippets/repo_create_js.html" %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -135,5 +135,6 @@
|
|||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{% include "snippets/myhome_extra_script.html" %}
|
{% include "snippets/myhome_extra_script.html" %}
|
||||||
|
{% include "snippets/repo_create_js.html" %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -42,89 +42,3 @@ $(function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
//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"]');
|
|
||||||
|
|
||||||
if (!$('#repo-name').val()) {
|
|
||||||
apply_form_error('repo-create-form', '目录名不能为空。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!$('#repo-desc').val()) {
|
|
||||||
apply_form_error('repo-create-form', '描述不能为空。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($('#encrypt-switch').attr('checked')) {
|
|
||||||
if (!passwd.val()) {
|
|
||||||
apply_form_error('repo-create-form', '密码不能为空。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!passwd_again.val()) {
|
|
||||||
apply_form_error('repo-create-form', '请确认密码。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (passwd.val().length < 3) {
|
|
||||||
apply_form_error('repo-create-form', '密码太短。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (passwd.val().length > 15) {
|
|
||||||
apply_form_error('repo-create-form', '密码太长。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (passwd.val() != passwd_again.val()) {
|
|
||||||
apply_form_error('repo-create-form', '两次输入的密码不一致。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$.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) {
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
@@ -22,39 +22,8 @@ $('#repo-create-submit').click(function() {
|
|||||||
var passwd = $('#repo-create-form input[name="passwd"]'),
|
var passwd = $('#repo-create-form input[name="passwd"]'),
|
||||||
passwd_again = $('#repo-create-form input[name="passwd_again"]');
|
passwd_again = $('#repo-create-form input[name="passwd_again"]');
|
||||||
|
|
||||||
if (!$('#repo-name').val()) {
|
|
||||||
apply_form_error('repo-create-form', '目录名不能为空。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!$('#repo-desc').val()) {
|
|
||||||
apply_form_error('repo-create-form', '描述不能为空。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($('#encrypt-switch').attr('checked')) {
|
|
||||||
if (!passwd.val()) {
|
|
||||||
apply_form_error('repo-create-form', '密码不能为空。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!passwd_again.val()) {
|
|
||||||
apply_form_error('repo-create-form', '请确认密码。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (passwd.val().length < 3) {
|
|
||||||
apply_form_error('repo-create-form', '密码太短。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (passwd.val().length > 15) {
|
|
||||||
apply_form_error('repo-create-form', '密码太长。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (passwd.val() != passwd_again.val()) {
|
|
||||||
apply_form_error('repo-create-form', '两次输入的密码不一致。');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ SITE_ROOT }}group/{{group_id}}/create-repo/',
|
url: '{{ url }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: 'false',
|
cache: 'false',
|
Reference in New Issue
Block a user