summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/project_new.js
blob: 4f33a564cbdc3048d8c75077f13a85a0122d7570 (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
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

this.ProjectNew = (function() {
  function ProjectNew() {
    this.toggleSettings = bind(this.toggleSettings, this);
    $('.project-edit-container').on('ajax:before', (function(_this) {
      return function() {
        $('.project-edit-container').hide();
        return $('.save-project-loader').show();
      };
    })(this));
    this.toggleSettings();
    this.toggleSettingsOnclick();
  }

  ProjectNew.prototype.toggleSettings = function() {
    this._showOrHide('#project_builds_enabled', '.builds-feature');
    return this._showOrHide('#project_merge_requests_enabled', '.merge-requests-feature');
  };

  ProjectNew.prototype.toggleSettingsOnclick = function() {
    return $('#project_builds_enabled, #project_merge_requests_enabled').on('click', this.toggleSettings);
  };

  ProjectNew.prototype._showOrHide = function(checkElement, container) {
    var $container;
    $container = $(container);
    if ($(checkElement).prop('checked')) {
      return $container.show();
    } else {
      return $container.hide();
    }
  };

  return ProjectNew;

})();