Commit afa1aa59 authored by Mike Greiling's avatar Mike Greiling

remove IIFEs in preparation for ES module refactor

parent 2df84af0
/* eslint-disable no-param-reassign */ const MAX_MESSAGE_LENGTH = 500;
const MESSAGE_CELL_SELECTOR = '.abuse-reports .message';
((global) => { class AbuseReports {
const MAX_MESSAGE_LENGTH = 500; constructor() {
const MESSAGE_CELL_SELECTOR = '.abuse-reports .message'; $(MESSAGE_CELL_SELECTOR).each(this.truncateLongMessage);
$(document)
class AbuseReports { .off('click', MESSAGE_CELL_SELECTOR)
constructor() { .on('click', MESSAGE_CELL_SELECTOR, this.toggleMessageTruncation);
$(MESSAGE_CELL_SELECTOR).each(this.truncateLongMessage); }
$(document)
.off('click', MESSAGE_CELL_SELECTOR)
.on('click', MESSAGE_CELL_SELECTOR, this.toggleMessageTruncation);
}
truncateLongMessage() { truncateLongMessage() {
const $messageCellElement = $(this); const $messageCellElement = $(this);
const reportMessage = $messageCellElement.text(); const reportMessage = $messageCellElement.text();
if (reportMessage.length > MAX_MESSAGE_LENGTH) { if (reportMessage.length > MAX_MESSAGE_LENGTH) {
$messageCellElement.data('original-message', reportMessage); $messageCellElement.data('original-message', reportMessage);
$messageCellElement.data('message-truncated', 'true'); $messageCellElement.data('message-truncated', 'true');
$messageCellElement.text(global.text.truncate(reportMessage, MAX_MESSAGE_LENGTH)); $messageCellElement.text(window.gl.text.truncate(reportMessage, MAX_MESSAGE_LENGTH));
}
} }
}
toggleMessageTruncation() { toggleMessageTruncation() {
const $messageCellElement = $(this); const $messageCellElement = $(this);
const originalMessage = $messageCellElement.data('original-message'); const originalMessage = $messageCellElement.data('original-message');
if (!originalMessage) return; if (!originalMessage) return;
if ($messageCellElement.data('message-truncated') === 'true') { if ($messageCellElement.data('message-truncated') === 'true') {
$messageCellElement.data('message-truncated', 'false'); $messageCellElement.data('message-truncated', 'false');
$messageCellElement.text(originalMessage); $messageCellElement.text(originalMessage);
} else { } else {
$messageCellElement.data('message-truncated', 'true'); $messageCellElement.data('message-truncated', 'true');
$messageCellElement.text(`${originalMessage.substr(0, (MAX_MESSAGE_LENGTH - 3))}...`); $messageCellElement.text(`${originalMessage.substr(0, (MAX_MESSAGE_LENGTH - 3))}...`);
}
} }
} }
}
global.AbuseReports = AbuseReports; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.AbuseReports = AbuseReports;
...@@ -2,36 +2,35 @@ ...@@ -2,36 +2,35 @@
/* global Pager */ /* global Pager */
/* global Cookies */ /* global Cookies */
((global) => { class Activities {
class Activities { constructor() {
constructor() { Pager.init(20, true, false, this.updateTooltips);
Pager.init(20, true, false, this.updateTooltips); $('.event-filter-link').on('click', (e) => {
$('.event-filter-link').on('click', (e) => { e.preventDefault();
e.preventDefault(); this.toggleFilter(e.currentTarget);
this.toggleFilter(e.currentTarget); this.reloadActivities();
this.reloadActivities(); });
}); }
}
updateTooltips() { updateTooltips() {
gl.utils.localTimeAgo($('.js-timeago', '.content_list')); gl.utils.localTimeAgo($('.js-timeago', '.content_list'));
} }
reloadActivities() { reloadActivities() {
$('.content_list').html(''); $('.content_list').html('');
Pager.init(20, true, false, this.updateTooltips); Pager.init(20, true, false, this.updateTooltips);
} }
toggleFilter(sender) { toggleFilter(sender) {
const $sender = $(sender); const $sender = $(sender);
const filter = $sender.attr('id').split('_')[0]; const filter = $sender.attr('id').split('_')[0];
$('.event-filter .active').removeClass('active'); $('.event-filter .active').removeClass('active');
Cookies.set('event_filter', filter); Cookies.set('event_filter', filter);
$sender.closest('li').toggleClass('active'); $sender.closest('li').toggleClass('active');
}
} }
}
global.Activities = Activities; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.Activities = Activities;
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, no-unused-vars, no-else-return, prefer-arrow-callback, camelcase, quotes, comma-dangle, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, no-unused-vars, no-else-return, prefer-arrow-callback, camelcase, quotes, comma-dangle, max-len */
(function() { window.Admin = (function() {
this.Admin = (function() { function Admin() {
function Admin() { var modal, showBlacklistType;
var modal, showBlacklistType; $('input#user_force_random_password').on('change', function(elem) {
$('input#user_force_random_password').on('change', function(elem) { var elems;
var elems; elems = $('#user_password, #user_password_confirmation');
elems = $('#user_password, #user_password_confirmation'); if ($(this).attr('checked')) {
if ($(this).attr('checked')) { return elems.val('').attr('disabled', true);
return elems.val('').attr('disabled', true); } else {
} else { return elems.removeAttr('disabled');
return elems.removeAttr('disabled'); }
} });
}); $('body').on('click', '.js-toggle-colors-link', function(e) {
$('body').on('click', '.js-toggle-colors-link', function(e) { e.preventDefault();
e.preventDefault(); return $('.js-toggle-colors-container').toggle();
return $('.js-toggle-colors-container').toggle(); });
}); $('.log-tabs a').click(function(e) {
$('.log-tabs a').click(function(e) { e.preventDefault();
e.preventDefault(); return $(this).tab('show');
return $(this).tab('show'); });
}); $('.log-bottom').click(function(e) {
$('.log-bottom').click(function(e) { var visible_log;
var visible_log; e.preventDefault();
e.preventDefault(); visible_log = $(".file-content:visible");
visible_log = $(".file-content:visible"); return visible_log.animate({
return visible_log.animate({ scrollTop: visible_log.find('ol').height()
scrollTop: visible_log.find('ol').height() }, "fast");
}, "fast"); });
}); modal = $('.change-owner-holder');
modal = $('.change-owner-holder'); $('.change-owner-link').bind("click", function(e) {
$('.change-owner-link').bind("click", function(e) { e.preventDefault();
e.preventDefault(); $(this).hide();
$(this).hide(); return modal.show();
return modal.show(); });
}); $('.change-owner-cancel-link').bind("click", function(e) {
$('.change-owner-cancel-link').bind("click", function(e) { e.preventDefault();
e.preventDefault(); modal.hide();
modal.hide(); return $('.change-owner-link').show();
return $('.change-owner-link').show(); });
}); $('li.project_member').bind('ajax:success', function() {
$('li.project_member').bind('ajax:success', function() { return gl.utils.refreshCurrentPage();
return gl.utils.refreshCurrentPage(); });
}); $('li.group_member').bind('ajax:success', function() {
$('li.group_member').bind('ajax:success', function() { return gl.utils.refreshCurrentPage();
return gl.utils.refreshCurrentPage(); });
}); showBlacklistType = function() {
showBlacklistType = function() { if ($("input[name='blacklist_type']:checked").val() === 'file') {
if ($("input[name='blacklist_type']:checked").val() === 'file') { $('.blacklist-file').show();
$('.blacklist-file').show(); return $('.blacklist-raw').hide();
return $('.blacklist-raw').hide(); } else {
} else { $('.blacklist-file').hide();
$('.blacklist-file').hide(); return $('.blacklist-raw').show();
return $('.blacklist-raw').show(); }
} };
}; $("input[name='blacklist_type']").click(showBlacklistType);
$("input[name='blacklist_type']").click(showBlacklistType); showBlacklistType();
showBlacklistType(); }
}
return Admin; return Admin;
})(); })();
}).call(window);
/* eslint-disable */ /* eslint-disable no-var, wrap-iife, func-names, space-before-function-paren, camelcase, no-unused-vars, quotes, object-shorthand, one-var, one-var-declaration-per-line, prefer-arrow-callback, comma-dangle, prefer-template, no-else-return, yoda, prefer-rest-params, prefer-spread, max-len */
(function() { /* global Api */
var slice = [].slice;
this.AdminEmailSelect = (function() { var slice = [].slice;
function AdminEmailSelect() {
$('.ajax-admin-email-select').each((function(_this) { window.AdminEmailSelect = (function() {
return function(i, select) { function AdminEmailSelect() {
var skip_ldap; $('.ajax-admin-email-select').each((function(_this) {
skip_ldap = $(select).hasClass('skip_ldap'); return function(i, select) {
return $(select).select2({ var skip_ldap;
placeholder: "Select group or project", skip_ldap = $(select).hasClass('skip_ldap');
multiple: $(select).hasClass('multiselect'), return $(select).select2({
minimumInputLength: 0, placeholder: "Select group or project",
query: function(query) { multiple: $(select).hasClass('multiselect'),
var group_result, project_result; minimumInputLength: 0,
group_result = Api.groups(query.term, {}, function(groups) { query: function(query) {
return groups; var group_result, project_result;
}); group_result = Api.groups(query.term, {}, function(groups) {
// Should be replaced with "Api.projects" when API v4 is frozen (9.1) return groups;
project_result = Api.allProjects(query.term, 'id', function(projects) { });
return projects; // Should be replaced with "Api.projects" when API v4 is frozen (9.1)
}); project_result = Api.allProjects(query.term, 'id', function(projects) {
return $.when(project_result, group_result).done(function(projects, groups) { return projects;
var all, data; });
all = { return $.when(project_result, group_result).done(function(projects, groups) {
id: "all" var all, data;
}; all = {
data = [all].concat(groups[0], projects[0]); id: "all"
return query.callback({ };
results: data data = [all].concat(groups[0], projects[0]);
}); return query.callback({
results: data
}); });
}, });
id: function(object) { },
if (object.path_with_namespace) { id: function(object) {
return "project-" + object.id; if (object.path_with_namespace) {
} else if (object.path) { return "project-" + object.id;
return "group-" + object.id; } else if (object.path) {
} else { return "group-" + object.id;
return "all"; } else {
} return "all";
},
formatResult: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatResult.apply(_this, args);
},
formatSelection: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatSelection.apply(_this, args);
},
dropdownCssClass: "ajax-admin-email-dropdown",
escapeMarkup: function(m) {
return m;
} }
}); },
}; formatResult: function() {
})(this)); var args;
} args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatResult.apply(_this, args);
},
formatSelection: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatSelection.apply(_this, args);
},
dropdownCssClass: "ajax-admin-email-dropdown",
escapeMarkup: function(m) {
return m;
}
});
};
})(this));
}
AdminEmailSelect.prototype.formatResult = function(object) { AdminEmailSelect.prototype.formatResult = function(object) {
if (object.path_with_namespace) { if (object.path_with_namespace) {
return "<div class='project-result'> <div class='project-name'>" + object.name + "</div> <div class='project-path'>" + object.path_with_namespace + "</div> </div>"; return "<div class='project-result'> <div class='project-name'>" + object.name + "</div> <div class='project-path'>" + object.path_with_namespace + "</div> </div>";
} else if (object.path) { } else if (object.path) {
return "<div class='group-result'> <div class='group-name'>" + object.name + "</div> <div class='group-path'>" + object.path + "</div> </div>"; return "<div class='group-result'> <div class='group-name'>" + object.name + "</div> <div class='group-path'>" + object.path + "</div> </div>";
} else { } else {
return "<div class='group-result'> <div class='group-name'>All</div> <div class='group-path'>All groups and projects</div> </div>"; return "<div class='group-result'> <div class='group-name'>All</div> <div class='group-path'>All groups and projects</div> </div>";
} }
}; };
AdminEmailSelect.prototype.formatSelection = function(object) {
if (object.path_with_namespace) {
return "Project: " + object.name;
} else if (object.path) {
return "Group: " + object.name;
} else {
return "All groups and projects";
}
};
return AdminEmailSelect;
})(); AdminEmailSelect.prototype.formatSelection = function(object) {
if (object.path_with_namespace) {
return "Project: " + object.name;
} else if (object.path) {
return "Group: " + object.name;
} else {
return "All groups and projects";
}
};
}).call(window); return AdminEmailSelect;
})();
This diff is collapsed.
/* eslint-disable */
(global => {
global.gl = global.gl || {};
gl.ApplicationSettings = function() { function ApplicationSettings() {
var usage_data_url = $('.usage-data').data('endpoint'); const usageDataUrl = $('.usage-data').data('endpoint');
$.ajax({ $.ajax({
type: "GET", type: 'GET',
url: usage_data_url, url: usageDataUrl,
dataType: "html", dataType: 'html',
success: function (html) { success(html) {
$(".usage-data").html(html); $('.usage-data').html(html);
} },
}); });
} }
})(window);
window.gl = window.gl || {};
window.gl.ApplicationSettings = ApplicationSettings;
/* eslint-disable */ /* eslint-disable func-names, prefer-arrow-callback, space-before-function-paren, quotes, no-var, comma-spacing, keyword-spacing, one-var, one-var-declaration-per-line, no-unused-vars, camelcase, prefer-template, max-len */
(function() {
$(function() {
$(".approver-list").on("click", ".unsaved-approvers.approver .btn-remove", function(ev) {
var removeElement = $(this).closest("li");
var approverId = parseInt(removeElement.attr("id").replace("user_",""), 10);
var approverIds = $("input#merge_request_approver_ids");
var skipUsers = approverIds.data("skip-users") || [];
var approverIndex = skipUsers.indexOf(approverId);
removeElement.remove(); $(function() {
$(".approver-list").on("click", ".unsaved-approvers.approver .btn-remove", function(ev) {
var removeElement = $(this).closest("li");
var approverId = parseInt(removeElement.attr("id").replace("user_",""), 10);
var approverIds = $("input#merge_request_approver_ids");
var skipUsers = approverIds.data("skip-users") || [];
var approverIndex = skipUsers.indexOf(approverId);
if(approverIndex > -1) { removeElement.remove();
approverIds.data("skip-users", skipUsers.splice(approverIndex, 1));
}
ev.preventDefault(); if(approverIndex > -1) {
}); approverIds.data("skip-users", skipUsers.splice(approverIndex, 1));
}
$(".approver-list").on("click", ".unsaved-approvers.approver-group .btn-remove", function(ev) { ev.preventDefault();
var removeElement = $(this).closest("li"); });
var approverGroupId = parseInt(removeElement.attr("id").replace("group_",""), 10);
var approverGroupIds = $("input#merge_request_approver_group_ids");
var skipGroups = approverGroupIds.data("skip-groups") || [];
var approverGroupIndex = skipGroups.indexOf(approverGroupId);
removeElement.remove(); $(".approver-list").on("click", ".unsaved-approvers.approver-group .btn-remove", function(ev) {
var removeElement = $(this).closest("li");
var approverGroupId = parseInt(removeElement.attr("id").replace("group_",""), 10);
var approverGroupIds = $("input#merge_request_approver_group_ids");
var skipGroups = approverGroupIds.data("skip-groups") || [];
var approverGroupIndex = skipGroups.indexOf(approverGroupId);
if(approverGroupIndex > -1) { removeElement.remove();
approverGroupIds.data("skip-groups", skipGroups.splice(approverGroupIndex, 1));
}
ev.preventDefault(); if(approverGroupIndex > -1) {
}); approverGroupIds.data("skip-groups", skipGroups.splice(approverGroupIndex, 1));
}
$("form.merge-request-form").submit(function() { ev.preventDefault();
var approverIds, approversInput, approverGroupIds, approverGroupsInput; });
if ($("input#merge_request_approver_ids").length) { $("form.merge-request-form").submit(function() {
approverIds = $.map($("li.unsaved-approvers.approver").not(".approver-template"), function(li, i) { var approverIds, approversInput, approverGroupIds, approverGroupsInput;
return li.id.replace("user_", "");
});
approversInput = $(this).find("input#merge_request_approver_ids");
approverIds = approverIds.concat(approversInput.val().split(","));
approversInput.val(_.compact(approverIds).join(","));
}
if ($("input#merge_request_approver_group_ids").length) { if ($("input#merge_request_approver_ids").length) {
approverGroupIds = $.map($("li.unsaved-approvers.approver-group"), function(li, i) { approverIds = $.map($("li.unsaved-approvers.approver").not(".approver-template"), function(li, i) {
return li.id.replace("group_", ""); return li.id.replace("user_", "");
}); });
approverGroupsInput = $(this).find("input#merge_request_approver_group_ids"); approversInput = $(this).find("input#merge_request_approver_ids");
approverGroupIds = approverGroupIds.concat(approverGroupsInput.val().split(",")); approverIds = approverIds.concat(approversInput.val().split(","));
approverGroupsInput.val(_.compact(approverGroupIds).join(",")); approversInput.val(_.compact(approverIds).join(","));
} }
});
return $(".suggested-approvers a").click(function() { if ($("input#merge_request_approver_group_ids").length) {
var approver_item_html, user_id, user_name; approverGroupIds = $.map($("li.unsaved-approvers.approver-group"), function(li, i) {
user_id = this.id.replace("user_", ""); return li.id.replace("group_", "");
user_name = this.text; });
if ($(".approver-list #user_" + user_id).length) { approverGroupsInput = $(this).find("input#merge_request_approver_group_ids");
return false; approverGroupIds = approverGroupIds.concat(approverGroupsInput.val().split(","));
} approverGroupsInput.val(_.compact(approverGroupIds).join(","));
approver_item_html = $(".unsaved-approvers.approver-template").clone().removeClass("hide approver-template")[0].outerHTML.replace(/\{approver_name\}/g, user_name).replace(/\{user_id\}/g, user_id); }
$(".no-approvers").remove();
$(".approver-list").append(approver_item_html);
return false;
});
}); });
}).call(window); return $(".suggested-approvers a").click(function() {
var approver_item_html, user_id, user_name;
user_id = this.id.replace("user_", "");
user_name = this.text;
if ($(".approver-list #user_" + user_id).length) {
return false;
}
approver_item_html = $(".unsaved-approvers.approver-template").clone().removeClass("hide approver-template")[0].outerHTML.replace(/\{approver_name\}/g, user_name).replace(/\{user_id\}/g, user_id);
$(".no-approvers").remove();
$(".approver-list").append(approver_item_html);
return false;
});
});
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, prefer-arrow-callback, no-var, one-var, one-var-declaration-per-line, no-else-return, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, prefer-arrow-callback, no-var, one-var, one-var-declaration-per-line, no-else-return, max-len */
(function() {
this.Aside = (function() {
function Aside() {
$(document).off("click", "a.show-aside");
$(document).on("click", 'a.show-aside', function(e) {
var btn, icon;
e.preventDefault();
btn = $(e.currentTarget);
icon = btn.find('i');
if (icon.hasClass('fa-angle-left')) {
btn.parent().find('section').hide();
btn.parent().find('aside').fadeIn();
return icon.removeClass('fa-angle-left').addClass('fa-angle-right');
} else {
btn.parent().find('aside').hide();
btn.parent().find('section').fadeIn();
return icon.removeClass('fa-angle-right').addClass('fa-angle-left');
}
});
}
return Aside; window.Aside = (function() {
})(); function Aside() {
}).call(window); $(document).off("click", "a.show-aside");
$(document).on("click", 'a.show-aside', function(e) {
var btn, icon;
e.preventDefault();
btn = $(e.currentTarget);
icon = btn.find('i');
if (icon.hasClass('fa-angle-left')) {
btn.parent().find('section').hide();
btn.parent().find('aside').fadeIn();
return icon.removeClass('fa-angle-left').addClass('fa-angle-right');
} else {
btn.parent().find('aside').hide();
btn.parent().find('section').fadeIn();
return icon.removeClass('fa-angle-right').addClass('fa-angle-left');
}
});
}
return Aside;
})();
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-param-reassign, quotes, prefer-template, no-var, one-var, no-unused-vars, one-var-declaration-per-line, no-void, consistent-return, no-empty, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-param-reassign, quotes, prefer-template, no-var, one-var, no-unused-vars, one-var-declaration-per-line, no-void, consistent-return, no-empty, max-len */
(function() {
this.Autosave = (function() {
function Autosave(field, key) {
this.field = field;
if (key.join != null) {
key = key.join("/");
}
this.key = "autosave/" + key;
this.field.data("autosave", this);
this.restore();
this.field.on("input", (function(_this) {
return function() {
return _this.save();
};
})(this));
}
Autosave.prototype.restore = function() { window.Autosave = (function() {
var e, text; function Autosave(field, key) {
if (window.localStorage == null) { this.field = field;
return; if (key.join != null) {
} key = key.join("/");
try { }
text = window.localStorage.getItem(this.key); this.key = "autosave/" + key;
} catch (error) { this.field.data("autosave", this);
e = error; this.restore();
return; this.field.on("input", (function(_this) {
} return function() {
if ((text != null ? text.length : void 0) > 0) { return _this.save();
this.field.val(text); };
} })(this));
return this.field.trigger("input"); }
};
Autosave.prototype.save = function() { Autosave.prototype.restore = function() {
var text; var e, text;
if (window.localStorage == null) { if (window.localStorage == null) {
return; return;
} }
text = this.field.val(); try {
if ((text != null ? text.length : void 0) > 0) { text = window.localStorage.getItem(this.key);
try { } catch (error) {
return window.localStorage.setItem(this.key, text); e = error;
} catch (error) {} return;
} else { }
return this.reset(); if ((text != null ? text.length : void 0) > 0) {
} this.field.val(text);
}; }
return this.field.trigger("input");
};
Autosave.prototype.reset = function() { Autosave.prototype.save = function() {
if (window.localStorage == null) { var text;
return; if (window.localStorage == null) {
} return;
}
text = this.field.val();
if ((text != null ? text.length : void 0) > 0) {
try { try {
return window.localStorage.removeItem(this.key); return window.localStorage.setItem(this.key, text);
} catch (error) {} } catch (error) {}
}; } else {
return this.reset();
}
};
Autosave.prototype.reset = function() {
if (window.localStorage == null) {
return;
}
try {
return window.localStorage.removeItem(this.key);
} catch (error) {}
};
return Autosave; return Autosave;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, quotes, no-shadow, prefer-arrow-callback, prefer-template, consistent-return, no-return-assign, new-parens, no-param-reassign, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, quotes, no-shadow, prefer-arrow-callback, prefer-template, consistent-return, no-return-assign, new-parens, no-param-reassign, max-len */
(function() { var Breakpoints = (function() {
var Breakpoints = (function() { var BreakpointInstance, instance;
var BreakpointInstance, instance;
function Breakpoints() {} function Breakpoints() {}
instance = null; instance = null;
BreakpointInstance = (function() { BreakpointInstance = (function() {
var BREAKPOINTS; var BREAKPOINTS;
BREAKPOINTS = ["xs", "sm", "md", "lg"]; BREAKPOINTS = ["xs", "sm", "md", "lg"];
function BreakpointInstance() { function BreakpointInstance() {
this.setup(); this.setup();
} }
BreakpointInstance.prototype.setup = function() {
var allDeviceSelector, els;
allDeviceSelector = BREAKPOINTS.map(function(breakpoint) {
return ".device-" + breakpoint;
});
if ($(allDeviceSelector.join(",")).length) {
return;
}
// Create all the elements
els = $.map(BREAKPOINTS, function(breakpoint) {
return "<div class='device-" + breakpoint + " visible-" + breakpoint + "'></div>";
});
return $("body").append(els.join(''));
};
BreakpointInstance.prototype.visibleDevice = function() { BreakpointInstance.prototype.setup = function() {
var allDeviceSelector; var allDeviceSelector, els;
allDeviceSelector = BREAKPOINTS.map(function(breakpoint) { allDeviceSelector = BREAKPOINTS.map(function(breakpoint) {
return ".device-" + breakpoint; return ".device-" + breakpoint;
}); });
return $(allDeviceSelector.join(",")).filter(":visible"); if ($(allDeviceSelector.join(",")).length) {
}; return;
}
BreakpointInstance.prototype.getBreakpointSize = function() { // Create all the elements
var $visibleDevice; els = $.map(BREAKPOINTS, function(breakpoint) {
$visibleDevice = this.visibleDevice; return "<div class='device-" + breakpoint + " visible-" + breakpoint + "'></div>";
// TODO: Consider refactoring in light of turbolinks removal. });
// the page refreshed via turbolinks return $("body").append(els.join(''));
if (!$visibleDevice().length) { };
this.setup();
}
$visibleDevice = this.visibleDevice();
return $visibleDevice.attr("class").split("visible-")[1];
};
return BreakpointInstance; BreakpointInstance.prototype.visibleDevice = function() {
})(); var allDeviceSelector;
allDeviceSelector = BREAKPOINTS.map(function(breakpoint) {
return ".device-" + breakpoint;
});
return $(allDeviceSelector.join(",")).filter(":visible");
};
Breakpoints.get = function() { BreakpointInstance.prototype.getBreakpointSize = function() {
return instance != null ? instance : instance = new BreakpointInstance; var $visibleDevice;
$visibleDevice = this.visibleDevice;
// TODO: Consider refactoring in light of turbolinks removal.
// the page refreshed via turbolinks
if (!$visibleDevice().length) {
this.setup();
}
$visibleDevice = this.visibleDevice();
return $visibleDevice.attr("class").split("visible-")[1];
}; };
return Breakpoints; return BreakpointInstance;
})(); })();
$((function(_this) { Breakpoints.get = function() {
return function() { return instance != null ? instance : instance = new BreakpointInstance;
return _this.bp = Breakpoints.get(); };
};
})(this)); return Breakpoints;
})();
$(() => { window.bp = Breakpoints.get(); });
window.Breakpoints = Breakpoints; window.Breakpoints = Breakpoints;
}).call(window);
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, no-else-return, object-shorthand, comma-dangle, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, no-else-return, object-shorthand, comma-dangle, max-len */
(function() {
$(function() { $(function() {
var previewPath; var previewPath;
$('input#broadcast_message_color').on('input', function() { $('input#broadcast_message_color').on('input', function() {
var previewColor; var previewColor;
previewColor = $(this).val(); previewColor = $(this).val();
return $('div.broadcast-message-preview').css('background-color', previewColor); return $('div.broadcast-message-preview').css('background-color', previewColor);
}); });
$('input#broadcast_message_font').on('input', function() { $('input#broadcast_message_font').on('input', function() {
var previewColor; var previewColor;
previewColor = $(this).val(); previewColor = $(this).val();
return $('div.broadcast-message-preview').css('color', previewColor); return $('div.broadcast-message-preview').css('color', previewColor);
}); });
previewPath = $('textarea#broadcast_message_message').data('preview-path'); previewPath = $('textarea#broadcast_message_message').data('preview-path');
return $('textarea#broadcast_message_message').on('input', function() { return $('textarea#broadcast_message_message').on('input', function() {
var message; var message;
message = $(this).val(); message = $(this).val();
if (message === '') { if (message === '') {
return $('.js-broadcast-message-preview').text("Your message here"); return $('.js-broadcast-message-preview').text("Your message here");
} else { } else {
return $.ajax({ return $.ajax({
url: previewPath, url: previewPath,
type: "POST", type: "POST",
data: { data: {
broadcast_message: { broadcast_message: {
message: message message: message
}
} }
}); }
} });
}); }
}); });
}).call(window); });
This diff is collapsed.
/* eslint-disable func-names, space-before-function-paren, wrap-iife, prefer-arrow-callback, no-unused-vars, no-return-assign, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, prefer-arrow-callback, no-unused-vars, no-return-assign, max-len */
(function() {
this.BuildArtifacts = (function() {
function BuildArtifacts() {
this.disablePropagation();
this.setupEntryClick();
}
BuildArtifacts.prototype.disablePropagation = function() { window.BuildArtifacts = (function() {
$('.top-block').on('click', '.download', function(e) { function BuildArtifacts() {
return e.stopPropagation(); this.disablePropagation();
}); this.setupEntryClick();
return $('.tree-holder').on('click', 'tr[data-link] a', function(e) { }
return e.stopImmediatePropagation();
});
};
BuildArtifacts.prototype.setupEntryClick = function() { BuildArtifacts.prototype.disablePropagation = function() {
return $('.tree-holder').on('click', 'tr[data-link]', function(e) { $('.top-block').on('click', '.download', function(e) {
return window.location = this.dataset.link; return e.stopPropagation();
}); });
}; return $('.tree-holder').on('click', 'tr[data-link] a', function(e) {
return e.stopImmediatePropagation();
});
};
return BuildArtifacts; BuildArtifacts.prototype.setupEntryClick = function() {
})(); return $('.tree-holder').on('click', 'tr[data-link]', function(e) {
}).call(window); return window.location = this.dataset.link;
});
};
return BuildArtifacts;
})();
(() => {
window.gl = window.gl || {};
class CILintEditor { window.gl = window.gl || {};
constructor() {
this.editor = window.ace.edit('ci-editor');
this.textarea = document.querySelector('#content');
this.editor.getSession().setMode('ace/mode/yaml'); class CILintEditor {
this.editor.on('input', () => { constructor() {
const content = this.editor.getSession().getValue(); this.editor = window.ace.edit('ci-editor');
this.textarea.value = content; this.textarea = document.querySelector('#content');
});
} this.editor.getSession().setMode('ace/mode/yaml');
this.editor.on('input', () => {
const content = this.editor.getSession().getValue();
this.textarea.value = content;
});
} }
}
gl.CILintEditor = CILintEditor; gl.CILintEditor = CILintEditor;
})();
/* eslint-disable func-names, space-before-function-paren, wrap-iife */ /* eslint-disable func-names, space-before-function-paren, wrap-iife */
/* global CommitFile */ /* global CommitFile */
(function() { window.Commit = (function() {
this.Commit = (function() { function Commit() {
function Commit() { $('.files .diff-file').each(function() {
$('.files .diff-file').each(function() { return new CommitFile(this);
return new CommitFile(this); });
}); }
}
return Commit; return Commit;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, consistent-return, no-return-assign, no-param-reassign, one-var, no-var, one-var-declaration-per-line, no-unused-vars, prefer-template, object-shorthand, comma-dangle, max-len, prefer-arrow-callback */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, consistent-return, no-return-assign, no-param-reassign, one-var, no-var, one-var-declaration-per-line, no-unused-vars, prefer-template, object-shorthand, comma-dangle, max-len, prefer-arrow-callback */
/* global Pager */ /* global Pager */
(function() { window.CommitsList = (function() {
this.CommitsList = (function() { var CommitsList = {};
var CommitsList = {};
CommitsList.timer = null; CommitsList.timer = null;
CommitsList.init = function(limit) { CommitsList.init = function(limit) {
$("body").on("click", ".day-commits-table li.commit", function(e) { $("body").on("click", ".day-commits-table li.commit", function(e) {
if (e.target.nodeName !== "A") { if (e.target.nodeName !== "A") {
location.href = $(this).attr("url"); location.href = $(this).attr("url");
e.stopPropagation(); e.stopPropagation();
return false; return false;
} }
}); });
Pager.init(limit, false, false, function() { Pager.init(limit, false, false, function() {
gl.utils.localTimeAgo($('.js-timeago')); gl.utils.localTimeAgo($('.js-timeago'));
}); });
this.content = $("#commits-list"); this.content = $("#commits-list");
this.searchField = $("#commits-search"); this.searchField = $("#commits-search");
this.lastSearch = this.searchField.val(); this.lastSearch = this.searchField.val();
return this.initSearch(); return this.initSearch();
}; };
CommitsList.initSearch = function() { CommitsList.initSearch = function() {
this.timer = null; this.timer = null;
return this.searchField.keyup((function(_this) { return this.searchField.keyup((function(_this) {
return function() { return function() {
clearTimeout(_this.timer); clearTimeout(_this.timer);
return _this.timer = setTimeout(_this.filterResults, 500); return _this.timer = setTimeout(_this.filterResults, 500);
}; };
})(this)); })(this));
}; };
CommitsList.filterResults = function() { CommitsList.filterResults = function() {
var commitsUrl, form, search; var commitsUrl, form, search;
form = $(".commits-search-form"); form = $(".commits-search-form");
search = CommitsList.searchField.val(); search = CommitsList.searchField.val();
if (search === CommitsList.lastSearch) return; if (search === CommitsList.lastSearch) return;
commitsUrl = form.attr("action") + '?' + form.serialize(); commitsUrl = form.attr("action") + '?' + form.serialize();
CommitsList.content.fadeTo('fast', 0.5); CommitsList.content.fadeTo('fast', 0.5);
return $.ajax({ return $.ajax({
type: "GET", type: "GET",
url: form.attr("action"), url: form.attr("action"),
data: form.serialize(), data: form.serialize(),
complete: function() { complete: function() {
return CommitsList.content.fadeTo('fast', 1.0); return CommitsList.content.fadeTo('fast', 1.0);
}, },
success: function(data) { success: function(data) {
CommitsList.lastSearch = search; CommitsList.lastSearch = search;
CommitsList.content.html(data.html); CommitsList.content.html(data.html);
return history.replaceState({ return history.replaceState({
page: commitsUrl page: commitsUrl
// Change url so if user reload a page - search results are saved // Change url so if user reload a page - search results are saved
}, document.title, commitsUrl); }, document.title, commitsUrl);
}, },
error: function() { error: function() {
CommitsList.lastSearch = null; CommitsList.lastSearch = null;
}, },
dataType: "json" dataType: "json"
}); });
}; };
return CommitsList; return CommitsList;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, object-shorthand, consistent-return, no-unused-vars, comma-dangle, vars-on-top, prefer-template, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, object-shorthand, consistent-return, no-unused-vars, comma-dangle, vars-on-top, prefer-template, max-len */
(function() {
this.Compare = (function() { window.Compare = (function() {
function Compare(opts) { function Compare(opts) {
this.opts = opts; this.opts = opts;
this.source_loading = $(".js-source-loading"); this.source_loading = $(".js-source-loading");
this.target_loading = $(".js-target-loading"); this.target_loading = $(".js-target-loading");
$('.js-compare-dropdown').each((function(_this) { $('.js-compare-dropdown').each((function(_this) {
return function(i, dropdown) { return function(i, dropdown) {
var $dropdown; var $dropdown;
$dropdown = $(dropdown); $dropdown = $(dropdown);
return $dropdown.glDropdown({ return $dropdown.glDropdown({
selectable: true, selectable: true,
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('field-name'),
filterable: true, filterable: true,
id: function(obj, $el) { id: function(obj, $el) {
return $el.data('id'); return $el.data('id');
}, },
toggleLabel: function(obj, $el) { toggleLabel: function(obj, $el) {
return $el.text().trim(); return $el.text().trim();
}, },
clicked: function(e, el) { clicked: function(e, el) {
if ($dropdown.is('.js-target-branch')) { if ($dropdown.is('.js-target-branch')) {
return _this.getTargetHtml(); return _this.getTargetHtml();
} else if ($dropdown.is('.js-source-branch')) { } else if ($dropdown.is('.js-source-branch')) {
return _this.getSourceHtml(); return _this.getSourceHtml();
} else if ($dropdown.is('.js-target-project')) { } else if ($dropdown.is('.js-target-project')) {
return _this.getTargetProject(); return _this.getTargetProject();
}
} }
}); }
}; });
})(this)); };
this.initialState(); })(this));
} this.initialState();
}
Compare.prototype.initialState = function() { Compare.prototype.initialState = function() {
this.getSourceHtml(); this.getSourceHtml();
return this.getTargetHtml(); return this.getTargetHtml();
}; };
Compare.prototype.getTargetProject = function() { Compare.prototype.getTargetProject = function() {
return $.ajax({ return $.ajax({
url: this.opts.targetProjectUrl, url: this.opts.targetProjectUrl,
data: { data: {
target_project_id: $("input[name='merge_request[target_project_id]']").val() target_project_id: $("input[name='merge_request[target_project_id]']").val()
}, },
beforeSend: function() { beforeSend: function() {
return $('.mr_target_commit').empty(); return $('.mr_target_commit').empty();
}, },
success: function(html) { success: function(html) {
return $('.js-target-branch-dropdown .dropdown-content').html(html); return $('.js-target-branch-dropdown .dropdown-content').html(html);
} }
}); });
}; };
Compare.prototype.getSourceHtml = function() { Compare.prototype.getSourceHtml = function() {
return this.sendAjax(this.opts.sourceBranchUrl, this.source_loading, '.mr_source_commit', { return this.sendAjax(this.opts.sourceBranchUrl, this.source_loading, '.mr_source_commit', {
ref: $("input[name='merge_request[source_branch]']").val() ref: $("input[name='merge_request[source_branch]']").val()
}); });
}; };
Compare.prototype.getTargetHtml = function() { Compare.prototype.getTargetHtml = function() {
return this.sendAjax(this.opts.targetBranchUrl, this.target_loading, '.mr_target_commit', { return this.sendAjax(this.opts.targetBranchUrl, this.target_loading, '.mr_target_commit', {
target_project_id: $("input[name='merge_request[target_project_id]']").val(), target_project_id: $("input[name='merge_request[target_project_id]']").val(),
ref: $("input[name='merge_request[target_branch]']").val() ref: $("input[name='merge_request[target_branch]']").val()
}); });
}; };
Compare.prototype.sendAjax = function(url, loading, target, data) { Compare.prototype.sendAjax = function(url, loading, target, data) {
var $target; var $target;
$target = $(target); $target = $(target);
return $.ajax({ return $.ajax({
url: url, url: url,
data: data, data: data,
beforeSend: function() { beforeSend: function() {
loading.show(); loading.show();
return $target.empty(); return $target.empty();
}, },
success: function(html) { success: function(html) {
loading.hide(); loading.hide();
$target.html(html); $target.html(html);
var className = '.' + $target[0].className.replace(' ', '.'); var className = '.' + $target[0].className.replace(' ', '.');
gl.utils.localTimeAgo($('.js-timeago', className)); gl.utils.localTimeAgo($('.js-timeago', className));
} }
}); });
}; };
return Compare; return Compare;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */ /* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */
(function() { window.CompareAutocomplete = (function() {
this.CompareAutocomplete = (function() { function CompareAutocomplete() {
function CompareAutocomplete() { this.initDropdown();
this.initDropdown(); }
}
CompareAutocomplete.prototype.initDropdown = function() { CompareAutocomplete.prototype.initDropdown = function() {
return $('.js-compare-dropdown').each(function() { return $('.js-compare-dropdown').each(function() {
var $dropdown, selected; var $dropdown, selected;
$dropdown = $(this); $dropdown = $(this);
selected = $dropdown.data('selected'); selected = $dropdown.data('selected');
const $dropdownContainer = $dropdown.closest('.dropdown'); const $dropdownContainer = $dropdown.closest('.dropdown');
const $fieldInput = $(`input[name="${$dropdown.data('field-name')}"]`, $dropdownContainer); const $fieldInput = $(`input[name="${$dropdown.data('field-name')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer); const $filterInput = $('input[type="search"]', $dropdownContainer);
$dropdown.glDropdown({ $dropdown.glDropdown({
data: function(term, callback) { data: function(term, callback) {
return $.ajax({ return $.ajax({
url: $dropdown.data('refs-url'), url: $dropdown.data('refs-url'),
data: { data: {
ref: $dropdown.data('ref') ref: $dropdown.data('ref')
}
}).done(function(refs) {
return callback(refs);
});
},
selectable: true,
filterable: true,
filterByText: true,
fieldName: $dropdown.data('field-name'),
filterInput: 'input[type="search"]',
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', escape(ref));
return $('<li />').append(link);
} }
}, }).done(function(refs) {
id: function(obj, $el) { return callback(refs);
return $el.attr('data-ref'); });
}, },
toggleLabel: function(obj, $el) { selectable: true,
return $el.text().trim(); filterable: true,
filterByText: true,
fieldName: $dropdown.data('field-name'),
filterInput: 'input[type="search"]',
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', escape(ref));
return $('<li />').append(link);
} }
}); },
$filterInput.on('keyup', (e) => { id: function(obj, $el) {
const keyCode = e.keyCode || e.which; return $el.attr('data-ref');
if (keyCode !== 13) return; },
const text = $filterInput.val(); toggleLabel: function(obj, $el) {
$fieldInput.val(text); return $el.text().trim();
$('.dropdown-toggle-text', $dropdown).text(text); }
$dropdownContainer.removeClass('open'); });
}); $filterInput.on('keyup', (e) => {
const keyCode = e.keyCode || e.which;
if (keyCode !== 13) return;
const text = $filterInput.val();
$fieldInput.val(text);
$('.dropdown-toggle-text', $dropdown).text(text);
$dropdownContainer.removeClass('open');
});
$dropdownContainer.on('click', '.dropdown-content a', (e) => { $dropdownContainer.on('click', '.dropdown-content a', (e) => {
$dropdown.prop('title', e.target.text.replace(/_+?/g, '-')); $dropdown.prop('title', e.target.text.replace(/_+?/g, '-'));
if ($dropdown.hasClass('has-tooltip')) { if ($dropdown.hasClass('has-tooltip')) {
$dropdown.tooltip('fixTitle'); $dropdown.tooltip('fixTitle');
} }
});
}); });
}; });
};
return CompareAutocomplete; return CompareAutocomplete;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, camelcase, one-var-declaration-per-line, no-else-return, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, camelcase, one-var-declaration-per-line, no-else-return, max-len */
(function() {
this.ConfirmDangerModal = (function() { window.ConfirmDangerModal = (function() {
function ConfirmDangerModal(form, text, arg) { function ConfirmDangerModal(form, text, arg) {
var project_path, submit, warningMessage; var project_path, submit, warningMessage;
warningMessage = (arg != null ? arg : {}).warningMessage; warningMessage = (arg != null ? arg : {}).warningMessage;
this.form = form; this.form = form;
$('.js-confirm-text').html(text || ''); $('.js-confirm-text').html(text || '');
if (warningMessage) { if (warningMessage) {
$('.js-warning-text').html(warningMessage); $('.js-warning-text').html(warningMessage);
}
$('.js-confirm-danger-input').val('');
$('#modal-confirm-danger').modal('show');
project_path = $('.js-confirm-danger-match').text();
submit = $('.js-confirm-danger-submit');
submit.disable();
$('.js-confirm-danger-input').off('input');
$('.js-confirm-danger-input').on('input', function() {
if (gl.utils.rstrip($(this).val()) === project_path) {
return submit.enable();
} else {
return submit.disable();
}
});
$('.js-confirm-danger-submit').off('click');
$('.js-confirm-danger-submit').on('click', (function(_this) {
return function() {
return _this.form.submit();
};
})(this));
} }
$('.js-confirm-danger-input').val('');
$('#modal-confirm-danger').modal('show');
project_path = $('.js-confirm-danger-match').text();
submit = $('.js-confirm-danger-submit');
submit.disable();
$('.js-confirm-danger-input').off('input');
$('.js-confirm-danger-input').on('input', function() {
if (gl.utils.rstrip($(this).val()) === project_path) {
return submit.enable();
} else {
return submit.disable();
}
});
$('.js-confirm-danger-submit').off('click');
$('.js-confirm-danger-submit').on('click', (function(_this) {
return function() {
return _this.form.submit();
};
})(this));
}
return ConfirmDangerModal; return ConfirmDangerModal;
})(); })();
}).call(window);
This diff is collapsed.
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, prefer-template, quotes, no-unused-vars, prefer-arrow-callback, max-len */ /* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, prefer-template, quotes, no-unused-vars, prefer-arrow-callback, max-len */
/* global Clipboard */
import Clipboard from 'vendor/clipboard';
window.Clipboard = require('vendor/clipboard');
var genericError, genericSuccess, showTooltip;
(function() {
var genericError, genericSuccess, showTooltip; genericSuccess = function(e) {
showTooltip(e.trigger, 'Copied');
genericSuccess = function(e) { // Clear the selection and blur the trigger so it loses its border
showTooltip(e.trigger, 'Copied'); e.clearSelection();
// Clear the selection and blur the trigger so it loses its border return $(e.trigger).blur();
e.clearSelection(); };
return $(e.trigger).blur();
}; // Safari doesn't support `execCommand`, so instead we inform the user to
// copy manually.
// Safari doesn't support `execCommand`, so instead we inform the user to //
// copy manually. // See http://clipboardjs.com/#browser-support
// genericError = function(e) {
// See http://clipboardjs.com/#browser-support var key;
genericError = function(e) { if (/Mac/i.test(navigator.userAgent)) {
var key; key = '&#8984;'; // Command
if (/Mac/i.test(navigator.userAgent)) { } else {
key = '&#8984;'; // Command key = 'Ctrl';
} else { }
key = 'Ctrl'; return showTooltip(e.trigger, "Press " + key + "-C to copy");
} };
return showTooltip(e.trigger, "Press " + key + "-C to copy");
}; showTooltip = function(target, title) {
var $target = $(target);
showTooltip = function(target, title) { var originalTitle = $target.data('original-title');
var $target = $(target);
var originalTitle = $target.data('original-title'); $target
.attr('title', 'Copied')
$target .tooltip('fixTitle')
.attr('title', 'Copied') .tooltip('show')
.tooltip('fixTitle') .attr('title', originalTitle)
.tooltip('show') .tooltip('fixTitle');
.attr('title', originalTitle) };
.tooltip('fixTitle');
}; $(function() {
var clipboard;
$(function() {
var clipboard; clipboard = new Clipboard('[data-clipboard-target], [data-clipboard-text]');
clipboard.on('success', genericSuccess);
clipboard = new Clipboard('[data-clipboard-target], [data-clipboard-text]'); return clipboard.on('error', genericError);
clipboard.on('success', genericSuccess); });
return clipboard.on('error', genericError);
});
}).call(window);
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, comma-dangle, prefer-template, quotes, no-param-reassign, wrap-iife, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, comma-dangle, prefer-template, quotes, no-param-reassign, wrap-iife, max-len */
/* global Api */ /* global Api */
(function (w) { class CreateLabelDropdown {
class CreateLabelDropdown { constructor ($el, namespacePath, projectPath) {
constructor ($el, namespacePath, projectPath) { this.$el = $el;
this.$el = $el; this.namespacePath = namespacePath;
this.namespacePath = namespacePath; this.projectPath = projectPath;
this.projectPath = projectPath; this.$dropdownBack = $('.dropdown-menu-back', this.$el.closest('.dropdown'));
this.$dropdownBack = $('.dropdown-menu-back', this.$el.closest('.dropdown')); this.$cancelButton = $('.js-cancel-label-btn', this.$el);
this.$cancelButton = $('.js-cancel-label-btn', this.$el); this.$newLabelField = $('#new_label_name', this.$el);
this.$newLabelField = $('#new_label_name', this.$el); this.$newColorField = $('#new_label_color', this.$el);
this.$newColorField = $('#new_label_color', this.$el); this.$colorPreview = $('.js-dropdown-label-color-preview', this.$el);
this.$colorPreview = $('.js-dropdown-label-color-preview', this.$el); this.$newLabelError = $('.js-label-error', this.$el);
this.$newLabelError = $('.js-label-error', this.$el); this.$newLabelCreateButton = $('.js-new-label-btn', this.$el);
this.$newLabelCreateButton = $('.js-new-label-btn', this.$el); this.$colorSuggestions = $('.suggest-colors-dropdown a', this.$el);
this.$colorSuggestions = $('.suggest-colors-dropdown a', this.$el);
this.$newLabelError.hide();
this.$newLabelError.hide(); this.$newLabelCreateButton.disable();
this.$newLabelCreateButton.disable();
this.cleanBinding();
this.addBinding();
}
this.cleanBinding(); cleanBinding () {
this.addBinding(); this.$colorSuggestions.off('click');
} this.$newLabelField.off('keyup change');
this.$newColorField.off('keyup change');
this.$dropdownBack.off('click');
this.$cancelButton.off('click');
this.$newLabelCreateButton.off('click');
}
cleanBinding () { addBinding () {
this.$colorSuggestions.off('click'); const self = this;
this.$newLabelField.off('keyup change');
this.$newColorField.off('keyup change');
this.$dropdownBack.off('click');
this.$cancelButton.off('click');
this.$newLabelCreateButton.off('click');
}
addBinding () { this.$colorSuggestions.on('click', function (e) {
const self = this; const $this = $(this);
self.addColorValue(e, $this);
});
this.$colorSuggestions.on('click', function (e) { this.$newLabelField.on('keyup change', this.enableLabelCreateButton.bind(this));
const $this = $(this); this.$newColorField.on('keyup change', this.enableLabelCreateButton.bind(this));
self.addColorValue(e, $this);
});
this.$newLabelField.on('keyup change', this.enableLabelCreateButton.bind(this)); this.$dropdownBack.on('click', this.resetForm.bind(this));
this.$newColorField.on('keyup change', this.enableLabelCreateButton.bind(this));
this.$dropdownBack.on('click', this.resetForm.bind(this)); this.$cancelButton.on('click', function(e) {
e.preventDefault();
e.stopPropagation();
this.$cancelButton.on('click', function(e) { self.resetForm();
e.preventDefault(); self.$dropdownBack.trigger('click');
e.stopPropagation(); });
self.resetForm(); this.$newLabelCreateButton.on('click', this.saveLabel.bind(this));
self.$dropdownBack.trigger('click'); }
});
this.$newLabelCreateButton.on('click', this.saveLabel.bind(this)); addColorValue (e, $this) {
} e.preventDefault();
e.stopPropagation();
addColorValue (e, $this) { this.$newColorField.val($this.data('color')).trigger('change');
e.preventDefault(); this.$colorPreview
e.stopPropagation(); .css('background-color', $this.data('color'))
.parent()
.addClass('is-active');
}
this.$newColorField.val($this.data('color')).trigger('change'); enableLabelCreateButton () {
this.$colorPreview if (this.$newLabelField.val() !== '' && this.$newColorField.val() !== '') {
.css('background-color', $this.data('color')) this.$newLabelError.hide();
.parent() this.$newLabelCreateButton.enable();
.addClass('is-active'); } else {
this.$newLabelCreateButton.disable();
} }
}
enableLabelCreateButton () { resetForm () {
if (this.$newLabelField.val() !== '' && this.$newColorField.val() !== '') { this.$newLabelField
this.$newLabelError.hide(); .val('')
this.$newLabelCreateButton.enable(); .trigger('change');
} else {
this.$newLabelCreateButton.disable();
}
}
resetForm () { this.$newColorField
this.$newLabelField .val('')
.val('') .trigger('change');
.trigger('change');
this.$newColorField this.$colorPreview
.val('') .css('background-color', '')
.trigger('change'); .parent()
.removeClass('is-active');
}
this.$colorPreview saveLabel (e) {
.css('background-color', '') e.preventDefault();
.parent() e.stopPropagation();
.removeClass('is-active');
}
saveLabel (e) { Api.newLabel(this.namespacePath, this.projectPath, {
e.preventDefault(); title: this.$newLabelField.val(),
e.stopPropagation(); color: this.$newColorField.val()
}, (label) => {
this.$newLabelCreateButton.enable();
Api.newLabel(this.namespacePath, this.projectPath, { if (label.message) {
title: this.$newLabelField.val(), let errors;
color: this.$newColorField.val()
}, (label) => {
this.$newLabelCreateButton.enable();
if (label.message) {
let errors;
if (typeof label.message === 'string') {
errors = label.message;
} else {
errors = Object.keys(label.message).map(key =>
`${gl.text.humanize(key)} ${label.message[key].join(', ')}`
).join("<br/>");
}
this.$newLabelError
.html(errors)
.show();
} else {
this.$dropdownBack.trigger('click');
$(document).trigger('created.label', label); if (typeof label.message === 'string') {
errors = label.message;
} else {
errors = Object.keys(label.message).map(key =>
`${gl.text.humanize(key)} ${label.message[key].join(', ')}`
).join("<br/>");
} }
});
}
}
if (!w.gl) { this.$newLabelError
w.gl = {}; .html(errors)
.show();
} else {
this.$dropdownBack.trigger('click');
$(document).trigger('created.label', label);
}
});
} }
}
gl.CreateLabelDropdown = CreateLabelDropdown; window.gl = window.gl || {};
})(window); gl.CreateLabelDropdown = CreateLabelDropdown;
...@@ -2,129 +2,127 @@ ...@@ -2,129 +2,127 @@
require('./lib/utils/url_utility'); require('./lib/utils/url_utility');
(() => { const UNFOLD_COUNT = 20;
const UNFOLD_COUNT = 20; let isBound = false;
let isBound = false;
class Diff { class Diff {
constructor() { constructor() {
const $diffFile = $('.files .diff-file'); const $diffFile = $('.files .diff-file');
$diffFile.singleFileDiff(); $diffFile.singleFileDiff();
$diffFile.filesCommentButton(); $diffFile.filesCommentButton();
$diffFile.each((index, file) => new gl.ImageFile(file)); $diffFile.each((index, file) => new gl.ImageFile(file));
if (this.diffViewType() === 'parallel') { if (this.diffViewType() === 'parallel') {
$('.content-wrapper .container-fluid').removeClass('container-limited'); $('.content-wrapper .container-fluid').removeClass('container-limited');
} }
if (!isBound) {
$(document)
.on('click', '.js-unfold', this.handleClickUnfold.bind(this))
.on('click', '.diff-line-num a', this.handleClickLineNum.bind(this));
isBound = true;
}
if (gl.utils.getLocationHash()) { if (!isBound) {
this.highlightSelectedLine(); $(document)
} .on('click', '.js-unfold', this.handleClickUnfold.bind(this))
.on('click', '.diff-line-num a', this.handleClickLineNum.bind(this));
isBound = true;
}
this.openAnchoredDiff(); if (gl.utils.getLocationHash()) {
this.highlightSelectedLine();
} }
handleClickUnfold(e) { this.openAnchoredDiff();
const $target = $(e.target); }
// current babel config relies on iterators implementation, so we cannot simply do:
// const [oldLineNumber, newLineNumber] = this.lineNumbers($target.parent()); handleClickUnfold(e) {
const ref = this.lineNumbers($target.parent()); const $target = $(e.target);
const oldLineNumber = ref[0]; // current babel config relies on iterators implementation, so we cannot simply do:
const newLineNumber = ref[1]; // const [oldLineNumber, newLineNumber] = this.lineNumbers($target.parent());
const offset = newLineNumber - oldLineNumber; const ref = this.lineNumbers($target.parent());
const bottom = $target.hasClass('js-unfold-bottom'); const oldLineNumber = ref[0];
let since; const newLineNumber = ref[1];
let to; const offset = newLineNumber - oldLineNumber;
let unfold = true; const bottom = $target.hasClass('js-unfold-bottom');
let since;
if (bottom) { let to;
const lineNumber = newLineNumber + 1; let unfold = true;
since = lineNumber;
to = lineNumber + UNFOLD_COUNT; if (bottom) {
} else { const lineNumber = newLineNumber + 1;
const lineNumber = newLineNumber - 1; since = lineNumber;
since = lineNumber - UNFOLD_COUNT; to = lineNumber + UNFOLD_COUNT;
to = lineNumber; } else {
const lineNumber = newLineNumber - 1;
// make sure we aren't loading more than we need since = lineNumber - UNFOLD_COUNT;
const prevNewLine = this.lineNumbers($target.parent().prev())[1]; to = lineNumber;
if (since <= prevNewLine + 1) {
since = prevNewLine + 1; // make sure we aren't loading more than we need
unfold = false; const prevNewLine = this.lineNumbers($target.parent().prev())[1];
} if (since <= prevNewLine + 1) {
since = prevNewLine + 1;
unfold = false;
} }
}
const file = $target.parents('.diff-file'); const file = $target.parents('.diff-file');
const link = file.data('blob-diff-path'); const link = file.data('blob-diff-path');
const view = file.data('view'); const view = file.data('view');
const params = { since, to, bottom, offset, unfold, view }; const params = { since, to, bottom, offset, unfold, view };
$.get(link, params, response => $target.parent().replaceWith(response)); $.get(link, params, response => $target.parent().replaceWith(response));
} }
openAnchoredDiff(cb) { openAnchoredDiff(cb) {
const locationHash = gl.utils.getLocationHash(); const locationHash = gl.utils.getLocationHash();
const anchoredDiff = locationHash && locationHash.split('_')[0]; const anchoredDiff = locationHash && locationHash.split('_')[0];
if (!anchoredDiff) return;
const diffTitle = $(`#${anchoredDiff}`);
const diffFile = diffTitle.closest('.diff-file');
const nothingHereBlock = $('.nothing-here-block:visible', diffFile);
if (nothingHereBlock.length) {
const clickTarget = $('.js-file-title, .click-to-expand', diffFile);
diffFile.data('singleFileDiff').toggleDiff(clickTarget, () => {
this.highlightSelectedLine();
if (cb) cb();
});
} else if (cb) {
cb();
}
}
handleClickLineNum(e) { if (!anchoredDiff) return;
const hash = $(e.currentTarget).attr('href');
e.preventDefault(); const diffTitle = $(`#${anchoredDiff}`);
if (window.history.pushState) { const diffFile = diffTitle.closest('.diff-file');
window.history.pushState(null, null, hash); const nothingHereBlock = $('.nothing-here-block:visible', diffFile);
} else { if (nothingHereBlock.length) {
window.location.hash = hash; const clickTarget = $('.js-file-title, .click-to-expand', diffFile);
} diffFile.data('singleFileDiff').toggleDiff(clickTarget, () => {
this.highlightSelectedLine(); this.highlightSelectedLine();
if (cb) cb();
});
} else if (cb) {
cb();
} }
}
diffViewType() { handleClickLineNum(e) {
return $('.inline-parallel-buttons a.active').data('view-type'); const hash = $(e.currentTarget).attr('href');
e.preventDefault();
if (window.history.pushState) {
window.history.pushState(null, null, hash);
} else {
window.location.hash = hash;
} }
this.highlightSelectedLine();
}
lineNumbers(line) { diffViewType() {
if (!line.children().length) { return $('.inline-parallel-buttons a.active').data('view-type');
return [0, 0]; }
}
return line.find('.diff-line-num').map((i, elm) => parseInt($(elm).data('linenumber'), 10)); lineNumbers(line) {
if (!line.children().length) {
return [0, 0];
} }
return line.find('.diff-line-num').map((i, elm) => parseInt($(elm).data('linenumber'), 10));
}
highlightSelectedLine() { highlightSelectedLine() {
const hash = gl.utils.getLocationHash(); const hash = gl.utils.getLocationHash();
const $diffFiles = $('.diff-file'); const $diffFiles = $('.diff-file');
$diffFiles.find('.hll').removeClass('hll'); $diffFiles.find('.hll').removeClass('hll');
if (hash) { if (hash) {
$diffFiles $diffFiles
.find(`tr#${hash}:not(.match) td, td#${hash}, td[data-line-code="${hash}"]`) .find(`tr#${hash}:not(.match) td, td#${hash}, td[data-line-code="${hash}"]`)
.addClass('hll'); .addClass('hll');
}
} }
} }
}
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.Diff = Diff; window.gl.Diff = Diff;
})();
This diff is collapsed.
This diff is collapsed.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Makes search request for content when user types a value in the search input. * Makes search request for content when user types a value in the search input.
* Updates the html content of the page with the received one. * Updates the html content of the page with the received one.
*/ */
export default class FilterableList { export default class FilterableList {
constructor(form, filter, holder) { constructor(form, filter, holder) {
this.filterForm = form; this.filterForm = form;
......
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, no-param-reassign, quotes, quote-props, prefer-template, comma-dangle, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, no-param-reassign, quotes, quote-props, prefer-template, comma-dangle, max-len */
(function() {
this.Flash = (function() {
var hideFlash;
hideFlash = function() { window.Flash = (function() {
return $(this).fadeOut(); var hideFlash;
};
function Flash(message, type, parent) { hideFlash = function() {
var flash, textDiv; return $(this).fadeOut();
if (type == null) { };
type = 'alert';
} function Flash(message, type, parent) {
if (parent == null) { var flash, textDiv;
parent = null; if (type == null) {
} type = 'alert';
if (parent) { }
this.flashContainer = parent.find('.flash-container'); if (parent == null) {
} else { parent = null;
this.flashContainer = $('.flash-container-page'); }
} if (parent) {
this.flashContainer.html(''); this.flashContainer = parent.find('.flash-container');
flash = $('<div/>', { } else {
"class": "flash-" + type this.flashContainer = $('.flash-container-page');
}); }
flash.on('click', hideFlash); this.flashContainer.html('');
textDiv = $('<div/>', { flash = $('<div/>', {
"class": 'flash-text', "class": "flash-" + type
text: message });
}); flash.on('click', hideFlash);
textDiv.appendTo(flash); textDiv = $('<div/>', {
if (this.flashContainer.parent().hasClass('content-wrapper')) { "class": 'flash-text',
textDiv.addClass('container-fluid container-limited'); text: message
} });
flash.appendTo(this.flashContainer); textDiv.appendTo(flash);
this.flashContainer.show(); if (this.flashContainer.parent().hasClass('content-wrapper')) {
textDiv.addClass('container-fluid container-limited');
} }
flash.appendTo(this.flashContainer);
this.flashContainer.show();
}
return Flash; return Flash;
})(); })();
}).call(window);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -2,47 +2,46 @@ ...@@ -2,47 +2,46 @@
require('./gl_field_error'); require('./gl_field_error');
((global) => { const customValidationFlag = 'gl-field-error-ignore';
const customValidationFlag = 'gl-field-error-ignore';
class GlFieldErrors {
class GlFieldErrors { constructor(form) {
constructor(form) { this.form = $(form);
this.form = $(form); this.state = {
this.state = { inputs: [],
inputs: [], valid: false
valid: false };
}; this.initValidators();
this.initValidators(); }
}
initValidators () { initValidators () {
// register selectors here as needed // register selectors here as needed
const validateSelectors = [':text', ':password', '[type=email]'] const validateSelectors = [':text', ':password', '[type=email]']
.map((selector) => `input${selector}`).join(','); .map((selector) => `input${selector}`).join(',');
this.state.inputs = this.form.find(validateSelectors).toArray() this.state.inputs = this.form.find(validateSelectors).toArray()
.filter((input) => !input.classList.contains(customValidationFlag)) .filter((input) => !input.classList.contains(customValidationFlag))
.map((input) => new global.GlFieldError({ input, formErrors: this })); .map((input) => new window.gl.GlFieldError({ input, formErrors: this }));
this.form.on('submit', this.catchInvalidFormSubmit); this.form.on('submit', this.catchInvalidFormSubmit);
} }
/* Neccessary to prevent intercept and override invalid form submit /* Neccessary to prevent intercept and override invalid form submit
* because Safari & iOS quietly allow form submission when form is invalid * because Safari & iOS quietly allow form submission when form is invalid
* and prevents disabling of invalid submit button by application.js */ * and prevents disabling of invalid submit button by application.js */
catchInvalidFormSubmit (event) { catchInvalidFormSubmit (event) {
if (!event.currentTarget.checkValidity()) { if (!event.currentTarget.checkValidity()) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
}
} }
}
focusOnFirstInvalid () { focusOnFirstInvalid () {
const firstInvalid = this.state.inputs.filter((input) => !input.inputDomElement.validity.valid)[0]; const firstInvalid = this.state.inputs.filter((input) => !input.inputDomElement.validity.valid)[0];
firstInvalid.inputElement.focus(); firstInvalid.inputElement.focus();
}
} }
}
global.GlFieldErrors = GlFieldErrors; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.GlFieldErrors = GlFieldErrors;
This diff is collapsed.
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, one-var, one-var-declaration-per-line, no-useless-escape, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, one-var, one-var-declaration-per-line, no-useless-escape, max-len */
(function() {
this.GroupAvatar = (function() {
function GroupAvatar() {
$('.js-choose-group-avatar-button').on("click", function() {
var form;
form = $(this).closest("form");
return form.find(".js-group-avatar-input").click();
});
$('.js-group-avatar-input').on("change", function() {
var filename, form;
form = $(this).closest("form");
filename = $(this).val().replace(/^.*[\\\/]/, '');
return form.find(".js-avatar-filename").text(filename);
});
}
return GroupAvatar; window.GroupAvatar = (function() {
})(); function GroupAvatar() {
}).call(window); $('.js-choose-group-avatar-button').on("click", function() {
var form;
form = $(this).closest("form");
return form.find(".js-group-avatar-input").click();
});
$('.js-group-avatar-input').on("change", function() {
var filename, form;
form = $(this).closest("form");
filename = $(this).val().replace(/^.*[\\\/]/, '');
return form.find(".js-avatar-filename").text(filename);
});
}
return GroupAvatar;
})();
This diff is collapsed.
/* eslint-disable wrap-iife, func-names, space-before-function-paren, prefer-arrow-callback, no-var, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var */
(function() {
$(document).on('todo:toggle', function(e, count) { $(document).on('todo:toggle', function(e, count) {
var $todoPendingCount = $('.todos-pending-count'); var $todoPendingCount = $('.todos-pending-count');
$todoPendingCount.text(gl.text.highCountTrim(count)); $todoPendingCount.text(gl.text.highCountTrim(count));
$todoPendingCount.toggleClass('hidden', count === 0); $todoPendingCount.toggleClass('hidden', count === 0);
}); });
})();
This diff is collapsed.
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