summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/admin.js
blob: aaed74d6073d6df857c88dfa47618e9d7ead0240 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, no-unused-vars, no-else-return, prefer-arrow-callback, camelcase, quotes, comma-dangle, max-len */

(function() {
  this.Admin = (function() {
    function Admin() {
      var modal, showBlacklistType;
      $('input#user_force_random_password').on('change', function(elem) {
        var elems;
        elems = $('#user_password, #user_password_confirmation');
        if ($(this).attr('checked')) {
          return elems.val('').attr('disabled', true);
        } else {
          return elems.removeAttr('disabled');
        }
      });
      $('body').on('click', '.js-toggle-colors-link', function(e) {
        e.preventDefault();
        return $('.js-toggle-colors-container').toggle();
      });
      $('.log-tabs a').click(function(e) {
        e.preventDefault();
        return $(this).tab('show');
      });
      $('.log-bottom').click(function(e) {
        var visible_log;
        e.preventDefault();
        visible_log = $(".file-content:visible");
        return visible_log.animate({
          scrollTop: visible_log.find('ol').height()
        }, "fast");
      });
      modal = $('.change-owner-holder');
      $('.change-owner-link').bind("click", function(e) {
        e.preventDefault();
        $(this).hide();
        return modal.show();
      });
      $('.change-owner-cancel-link').bind("click", function(e) {
        e.preventDefault();
        modal.hide();
        return $('.change-owner-link').show();
      });
      $('li.project_member').bind('ajax:success', function() {
        return gl.utils.refreshCurrentPage();
      });
      $('li.group_member').bind('ajax:success', function() {
        return gl.utils.refreshCurrentPage();
      });
      showBlacklistType = function() {
        if ($("input[name='blacklist_type']:checked").val() === 'file') {
          $('.blacklist-file').show();
          return $('.blacklist-raw').hide();
        } else {
          $('.blacklist-file').hide();
          return $('.blacklist-raw').show();
        }
      };
      $("input[name='blacklist_type']").click(showBlacklistType);
      showBlacklistType();
    }

    return Admin;
  })();
}).call(window);