project_new.js 1.3 KB
Newer Older
F
Fatih Acet 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
(function() {
  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() {
18 19
      this._showOrHide('#project_project_feature_attributes_builds_access_level', '.builds-feature');
      this._showOrHide('#project_project_feature_attributes_merge_requests_access_level', '.merge-requests-feature');
F
Fatih Acet 已提交
20 21 22
    };

    ProjectNew.prototype.toggleSettingsOnclick = function() {
23
      $('#project_project_feature_attributes_builds_access_level, #project_project_feature_attributes_merge_requests_access_level').on('change', this.toggleSettings);
F
Fatih Acet 已提交
24 25 26 27 28
    };

    ProjectNew.prototype._showOrHide = function(checkElement, container) {
      var $container;
      $container = $(container);
29
      if ($(checkElement).val() !== '0') {
F
Fatih Acet 已提交
30 31 32 33 34 35 36 37 38 39 40
        return $container.show();
      } else {
        return $container.hide();
      }
    };

    return ProjectNew;

  })();

}).call(this);