1 $(document).on('shown.bs.modal', '#add-repository-modal', function(event) {
2 $('input[type=text]', event.target).val('');
3 $('#add-repository-error', event.target).hide();
4 }).on('submit', '#add-repository-form', function(event) {
5 var $form = $(event.target),
6 $submit = $(':submit', $form),
7 $error = $('#add-repository-error', $form),
8 repo_owner_uuid = $('input[name="add_repo_owner_uuid"]', $form).val(),
9 repo_prefix = $('input[name="add_repo_prefix"]', $form).val(),
10 repo_basename = $('input[name="add_repo_basename"]', $form).val();
12 $submit.prop('disabled', true);
14 $.ajax('/repositories',
17 data: {repository: {owner_uuid: repo_owner_uuid,
18 name: repo_prefix + repo_basename}},
20 done(function(data, status, jqxhr) {
23 fail(function(jqxhr, status, error) {
24 var errlist = jqxhr.responseJSON.errors;
26 if (Array.isArray(errlist)) {
27 errmsg = errlist.join();
29 errmsg = ("The server returned an error when making " +
30 "this repository (status " + jqxhr.status +
31 ": " + errlist + ").");
35 $submit.prop('disabled', false);