diff options
author | Phil Hughes <me@iamphill.com> | 2016-09-02 14:51:36 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-09-02 14:51:36 +0100 |
commit | f8513d768242dffbd0fd0230e0bbeca972bcf0ec (patch) | |
tree | c15559c8789173d2dbbb631efeb96ea135892b4f /app/assets/javascripts | |
parent | 4da474ca928fff916a1e8ac3bb42d81df2364431 (diff) | |
download | gitlab-ce-f8513d768242dffbd0fd0230e0bbeca972bcf0ec.tar.gz |
Refactored code to rely less on IDs that could changeproject-edit-features-hide
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/project_new.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/app/assets/javascripts/project_new.js b/app/assets/javascripts/project_new.js index 06034574c8a..a787b11f2a9 100644 --- a/app/assets/javascripts/project_new.js +++ b/app/assets/javascripts/project_new.js @@ -4,6 +4,8 @@ this.ProjectNew = (function() { function ProjectNew() { this.toggleSettings = bind(this.toggleSettings, this); + this.$selects = $('.features select'); + $('.project-edit-container').on('ajax:before', (function(_this) { return function() { $('.project-edit-container').hide(); @@ -15,17 +17,23 @@ } ProjectNew.prototype.toggleSettings = function() { - this._showOrHide('#project_project_feature_attributes_builds_access_level', '.builds-feature'); - this._showOrHide('#project_project_feature_attributes_merge_requests_access_level', '.merge-requests-feature'); + var self = this; + + this.$selects.each(function () { + var $select = $(this), + className = $select.data('field').replace(/_/g, '-') + .replace('access-level', 'feature'); + self._showOrHide($select, '.' + className); + }); }; ProjectNew.prototype.toggleSettingsOnclick = function() { - $('#project_project_feature_attributes_builds_access_level, #project_project_feature_attributes_merge_requests_access_level').on('change', this.toggleSettings); + this.$selects.on('change', this.toggleSettings); }; ProjectNew.prototype._showOrHide = function(checkElement, container) { - var $container; - $container = $(container); + var $container = $(container); + if ($(checkElement).val() !== '0') { return $container.show(); } else { |