dd5e46ab69
Add ESLint ## What does this MR do? - create `package.json` - add ESLint dependencies to `package.json` - add JavaScript linting to CI - add Rake task `lint:javascript`as alias for `eslint` (which itself is an alias for `npm run eslint`) ## Are there points in the code the reviewer needs to double check? Probably not. ## Why was this MR needed? My hovercraft was full of eels. ## What are the relevant issue numbers? - https://gitlab.com/gitlab-org/gitlab-ce/issues/13224#note_12537431 - https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5006#note_13255658 See merge request !5445
109 lines
3.6 KiB
JavaScript
109 lines
3.6 KiB
JavaScript
/* eslint-disable */
|
|
(function() {
|
|
this.Project = (function() {
|
|
function Project() {
|
|
$('ul.clone-options-dropdown a').click(function() {
|
|
var url;
|
|
if ($(this).hasClass('active')) {
|
|
return;
|
|
}
|
|
$('.active').not($(this)).removeClass('active');
|
|
$(this).toggleClass('active');
|
|
url = $("#project_clone").val();
|
|
$('#project_clone').val(url);
|
|
return $('.clone').text(url);
|
|
// Git protocol switcher
|
|
// Remove the active class for all buttons (ssh, http, kerberos if shown)
|
|
// Add the active class for the clicked button
|
|
// Update the input field
|
|
// Update the command line instructions
|
|
});
|
|
// Ref switcher
|
|
this.initRefSwitcher();
|
|
$('.project-refs-select').on('change', function() {
|
|
return $(this).parents('form').submit();
|
|
});
|
|
$('.hide-no-ssh-message').on('click', function(e) {
|
|
Cookies.set('hide_no_ssh_message', 'false');
|
|
$(this).parents('.no-ssh-key-message').remove();
|
|
return e.preventDefault();
|
|
});
|
|
$('.hide-no-password-message').on('click', function(e) {
|
|
Cookies.set('hide_no_password_message', 'false');
|
|
$(this).parents('.no-password-message').remove();
|
|
return e.preventDefault();
|
|
});
|
|
this.projectSelectDropdown();
|
|
}
|
|
|
|
Project.prototype.projectSelectDropdown = function() {
|
|
new ProjectSelect();
|
|
$('.project-item-select').on('click', (function(_this) {
|
|
return function(e) {
|
|
return _this.changeProject($(e.currentTarget).val());
|
|
};
|
|
})(this));
|
|
return $('.js-projects-dropdown-toggle').on('click', function(e) {
|
|
e.preventDefault();
|
|
return $('.js-projects-dropdown').select2('open');
|
|
});
|
|
};
|
|
|
|
Project.prototype.changeProject = function(url) {
|
|
return window.location = url;
|
|
};
|
|
|
|
Project.prototype.initRefSwitcher = function() {
|
|
return $('.js-project-refs-dropdown').each(function() {
|
|
var $dropdown, selected;
|
|
$dropdown = $(this);
|
|
selected = $dropdown.data('selected');
|
|
return $dropdown.glDropdown({
|
|
data: function(term, callback) {
|
|
return $.ajax({
|
|
url: $dropdown.data('refs-url'),
|
|
data: {
|
|
ref: $dropdown.data('ref')
|
|
},
|
|
dataType: "json"
|
|
}).done(function(refs) {
|
|
return callback(refs);
|
|
});
|
|
},
|
|
selectable: true,
|
|
filterable: true,
|
|
filterByText: true,
|
|
fieldName: $dropdown.data('field-name'),
|
|
renderRow: function(ref) {
|
|
var link;
|
|
if (ref.header != null) {
|
|
return $('<li />').addClass('dropdown-header').text(ref.header);
|
|
} else {
|
|
link = $('<a />').attr('href', '#').addClass(ref === selected ? 'is-active' : '').text(ref).attr('data-ref', ref);
|
|
return $('<li />').append(link);
|
|
}
|
|
},
|
|
id: function(obj, $el) {
|
|
return $el.attr('data-ref');
|
|
},
|
|
toggleLabel: function(obj, $el) {
|
|
return $el.text().trim();
|
|
},
|
|
clicked: function(selected, $el, e) {
|
|
e.preventDefault()
|
|
if ($('input[name="ref"]').length) {
|
|
var $form = $dropdown.closest('form'),
|
|
action = $form.attr('action'),
|
|
divider = action.indexOf('?') < 0 ? '?' : '&';
|
|
Turbolinks.visit(action + '' + divider + '' + $form.serialize());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
return Project;
|
|
|
|
})();
|
|
|
|
}).call(this);
|