Commit 8f29c332 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Wrap classes with IIFE and define it inside gl namespace

parent 45454c3c
...@@ -173,8 +173,8 @@ ...@@ -173,8 +173,8 @@
new Search(); new Search();
break; break;
case 'projects:protected_branches:index': case 'projects:protected_branches:index':
new ProtectedBranchCreate(); new gl.ProtectedBranchCreate();
new ProtectedBranchEditList(); new gl.ProtectedBranchEditList();
break; break;
} }
switch (path.first()) { switch (path.first()) {
......
class ProtectedBranchAccessDropdown { (global => {
global.gl = global.gl || {};
gl.ProtectedBranchAccessDropdown = class {
constructor(options) { constructor(options) {
const { $dropdown, data, onSelect } = options; const { $dropdown, data, onSelect } = options;
...@@ -15,4 +18,6 @@ class ProtectedBranchAccessDropdown { ...@@ -15,4 +18,6 @@ class ProtectedBranchAccessDropdown {
} }
}); });
} }
} }
})(window);
class ProtectedBranchCreate { (global => {
global.gl = global.gl || {};
gl.ProtectedBranchCreate = class {
constructor() { constructor() {
this.$wrap = this.$form = $('#new_protected_branch'); this.$wrap = this.$form = $('#new_protected_branch');
this.buildDropdowns(); this.buildDropdowns();
...@@ -9,7 +12,7 @@ class ProtectedBranchCreate { ...@@ -9,7 +12,7 @@ class ProtectedBranchCreate {
const $allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge'); const $allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
const $allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push'); const $allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
new ProtectedBranchAccessDropdown({ new gl.ProtectedBranchAccessDropdown({
$dropdown: $allowedToMergeDropdown, $dropdown: $allowedToMergeDropdown,
data: gon.merge_access_levels, data: gon.merge_access_levels,
onSelect: this.onSelect.bind(this) onSelect: this.onSelect.bind(this)
...@@ -19,7 +22,7 @@ class ProtectedBranchCreate { ...@@ -19,7 +22,7 @@ class ProtectedBranchCreate {
$allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0); $allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
// Allowed to Push dropdown // Allowed to Push dropdown
new ProtectedBranchAccessDropdown({ new gl.ProtectedBranchAccessDropdown({
$dropdown: $allowedToPushDropdown, $dropdown: $allowedToPushDropdown,
data: gon.push_access_levels, data: gon.push_access_levels,
onSelect: this.onSelect.bind(this) onSelect: this.onSelect.bind(this)
...@@ -46,4 +49,6 @@ class ProtectedBranchCreate { ...@@ -46,4 +49,6 @@ class ProtectedBranchCreate {
this.$form.find('[type="submit"]').removeAttr('disabled'); this.$form.find('[type="submit"]').removeAttr('disabled');
} }
} }
} }
})(window);
class ProtectedBranchEdit { (global => {
global.gl = global.gl || {};
gl.ProtectedBranchEdit = class {
constructor(options) { constructor(options) {
this.$wrap = options.$wrap; this.$wrap = options.$wrap;
this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge'); this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
...@@ -10,14 +13,14 @@ class ProtectedBranchEdit { ...@@ -10,14 +13,14 @@ class ProtectedBranchEdit {
buildDropdowns() { buildDropdowns() {
// Allowed to merge dropdown // Allowed to merge dropdown
new ProtectedBranchAccessDropdown({ new gl.ProtectedBranchAccessDropdown({
$dropdown: this.$allowedToMergeDropdown, $dropdown: this.$allowedToMergeDropdown,
data: gon.merge_access_levels, data: gon.merge_access_levels,
onSelect: this.onSelect.bind(this) onSelect: this.onSelect.bind(this)
}); });
// Allowed to push dropdown // Allowed to push dropdown
new ProtectedBranchAccessDropdown({ new gl.ProtectedBranchAccessDropdown({
$dropdown: this.$allowedToPushDropdown, $dropdown: this.$allowedToPushDropdown,
data: gon.push_access_levels, data: gon.push_access_levels,
onSelect: this.onSelect.bind(this) onSelect: this.onSelect.bind(this)
...@@ -53,4 +56,6 @@ class ProtectedBranchEdit { ...@@ -53,4 +56,6 @@ class ProtectedBranchEdit {
} }
}); });
} }
} }
})(window);
class ProtectedBranchEditList { (global => {
global.gl = global.gl || {};
gl.ProtectedBranchEditList = class {
constructor() { constructor() {
this.$wrap = $('.protected-branches-list'); this.$wrap = $('.protected-branches-list');
// Build edit forms // Build edit forms
this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => { this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => {
new ProtectedBranchEdit({ new gl.ProtectedBranchEdit({
$wrap: $(el) $wrap: $(el)
}); });
}); });
} }
} }
})(window);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment