aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js/admin/dialogs/project-edit.js
blob: 8df9364f79a10bd3c10bb353252b8771537e0420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
jQuery(function($) {
  "use strict";

  var p = '#project-edit-';

  $(p + 'dialog').on('guff.loaded', function(ev) {
    var r = ev.post_data;

    $(p + 'repo').val(r.repo_url);
  });

  $(p + 'confirm').click(function() {
    $(p + 'dialog').trigger({
      type: 'guff.save',

      post_data: {
        repo_url: $(p + 'repo').val(),
      },
    });

    // stop event
    return false;
  });

  $('#project-edit-generate-secret').click(function() {
    var me = $(this);

    // disable button
    me.toggleClass('disabled').find('.fa').toggleClass('fa-spin');
    send('project/generate_secret').always(function() {
      // enable button
      me.toggleClass('disabled').find('.fa').toggleClass('fa-spin');
    }).fail(function(r) {
      gripe(r, 'generate secret');
    }).done(function(r) {
      // update secret
      $('#project-edit-secret').val(r.secret);
    });
  });
});