Skip to content
Snippets Groups Projects
Unverified Commit c559bcca authored by Mike Greiling's avatar Mike Greiling
Browse files

Prettify additional modules (I through Z)

parent aeaf6686
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Showing
with 302 additions and 233 deletions
Loading
Loading
@@ -26,14 +26,17 @@ export default class IssuableIndex {
static resetIncomingEmailToken() {
const $resetToken = $('.incoming-email-token-reset');
 
$resetToken.on('click', (e) => {
$resetToken.on('click', e => {
e.preventDefault();
 
$resetToken.text('resetting...');
 
axios.put($resetToken.attr('href'))
axios
.put($resetToken.attr('href'))
.then(({ data }) => {
$('#issuable_email').val(data.new_address).focus();
$('#issuable_email')
.val(data.new_address)
.focus();
 
$resetToken.text('reset it');
})
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ export default class Issue {
}
 
// Listen to state changes in the Vue app
document.addEventListener('issuable_vue_app:change', (event) => {
document.addEventListener('issuable_vue_app:change', event => {
this.updateTopState(event.detail.isClosed, event.detail.data);
});
}
Loading
Loading
@@ -55,7 +55,13 @@ export default class Issue {
$(document).trigger('issuable:change', isClosed);
this.toggleCloseReopenButton(isClosed);
 
let numProjectIssues = Number(projectIssuesCounter.first().text().trim().replace(/[^\d]/, ''));
let numProjectIssues = Number(
projectIssuesCounter
.first()
.text()
.trim()
.replace(/[^\d]/, ''),
);
numProjectIssues = isClosed ? numProjectIssues - 1 : numProjectIssues + 1;
projectIssuesCounter.text(addDelimiter(numProjectIssues));
 
Loading
Loading
@@ -76,29 +82,34 @@ export default class Issue {
initIssueBtnEventListeners() {
const issueFailMessage = 'Unable to update this issue at this time.';
 
return $(document).on('click', '.js-issuable-actions a.btn-close, .js-issuable-actions a.btn-reopen', (e) => {
var $button, shouldSubmit, url;
e.preventDefault();
e.stopImmediatePropagation();
$button = $(e.currentTarget);
shouldSubmit = $button.hasClass('btn-comment');
if (shouldSubmit) {
Issue.submitNoteForm($button.closest('form'));
}
this.disableCloseReopenButton($button);
return $(document).on(
'click',
'.js-issuable-actions a.btn-close, .js-issuable-actions a.btn-reopen',
e => {
var $button, shouldSubmit, url;
e.preventDefault();
e.stopImmediatePropagation();
$button = $(e.currentTarget);
shouldSubmit = $button.hasClass('btn-comment');
if (shouldSubmit) {
Issue.submitNoteForm($button.closest('form'));
}
 
url = $button.attr('href');
return axios.put(url)
.then(({ data }) => {
const isClosed = $button.hasClass('btn-close');
this.updateTopState(isClosed, data);
})
.catch(() => flash(issueFailMessage))
.then(() => {
this.disableCloseReopenButton($button, false);
});
});
this.disableCloseReopenButton($button);
url = $button.attr('href');
return axios
.put(url)
.then(({ data }) => {
const isClosed = $button.hasClass('btn-close');
this.updateTopState(isClosed, data);
})
.catch(() => flash(issueFailMessage))
.then(() => {
this.disableCloseReopenButton($button, false);
});
},
);
}
 
initCloseReopenReport() {
Loading
Loading
@@ -124,7 +135,7 @@ export default class Issue {
 
static submitNoteForm(form) {
var noteText;
noteText = form.find("textarea.js-note-text").val();
noteText = form.find('textarea.js-note-text').val();
if (noteText && noteText.trim().length > 0) {
return form.submit();
}
Loading
Loading
@@ -133,22 +144,26 @@ export default class Issue {
static initMergeRequests() {
var $container;
$container = $('#merge-requests');
return axios.get($container.data('url'))
return axios
.get($container.data('url'))
.then(({ data }) => {
if ('html' in data) {
$container.html(data.html);
}
}).catch(() => flash('Failed to load referenced merge requests'));
})
.catch(() => flash('Failed to load referenced merge requests'));
}
 
static initRelatedBranches() {
var $container;
$container = $('#related-branches');
return axios.get($container.data('url'))
return axios
.get($container.data('url'))
.then(({ data }) => {
if ('html' in data) {
$container.html(data.html);
}
}).catch(() => flash('Failed to load related branches'));
})
.catch(() => flash('Failed to load related branches'));
}
}
Loading
Loading
@@ -42,16 +42,14 @@ export default class Job extends LogOutputBehaviours {
 
this.scrollThrottled = _.throttle(this.toggleScroll.bind(this), 100);
 
this.$window
.off('scroll')
.on('scroll', () => {
if (!isScrolledToBottom()) {
this.toggleScrollAnimation(false);
} else if (isScrolledToBottom() && !this.isLogComplete) {
this.toggleScrollAnimation(true);
}
this.scrollThrottled();
});
this.$window.off('scroll').on('scroll', () => {
if (!isScrolledToBottom()) {
this.toggleScrollAnimation(false);
} else if (isScrolledToBottom() && !this.isLogComplete) {
this.toggleScrollAnimation(true);
}
this.scrollThrottled();
});
 
this.$window
.off('resize.build')
Loading
Loading
@@ -87,10 +85,11 @@ export default class Job extends LogOutputBehaviours {
}
 
getBuildTrace() {
return axios.get(`${this.pagePath}/trace.json`, {
params: { state: this.state },
})
.then((res) => {
return axios
.get(`${this.pagePath}/trace.json`, {
params: { state: this.state },
})
.then(res => {
const log = res.data;
 
if (!this.fetchingStatusFavicon) {
Loading
Loading
@@ -186,5 +185,4 @@ export default class Job extends LogOutputBehaviours {
sidebarOnClick() {
if (this.shouldHideSidebarForViewport()) this.toggleSidebar();
}
}
Loading
Loading
@@ -47,7 +47,10 @@ export default class LabelManager {
}
 
toggleEmptyState($label, $btn, action) {
this.emptyState.classList.toggle('hidden', !!this.prioritizedLabels[0].querySelector(':scope > li'));
this.emptyState.classList.toggle(
'hidden',
!!this.prioritizedLabels[0].querySelector(':scope > li'),
);
}
 
toggleLabelPriority($label, action, persistState) {
Loading
Loading
@@ -80,16 +83,14 @@ export default class LabelManager {
return;
}
if (action === 'remove') {
axios.delete(url)
.catch(rollbackLabelPosition);
axios.delete(url).catch(rollbackLabelPosition);
 
// Restore empty message
if (!$from.find('li').length) {
$from.find('.empty-message').removeClass('hidden');
}
} else {
this.savePrioritySort($label, action)
.catch(rollbackLabelPosition);
this.savePrioritySort($label, action).catch(rollbackLabelPosition);
}
}
 
Loading
Loading
@@ -102,8 +103,7 @@ export default class LabelManager {
}
 
onPrioritySortUpdate() {
this.savePrioritySort()
.catch(() => flash(this.errorMessage));
this.savePrioritySort().catch(() => flash(this.errorMessage));
}
 
savePrioritySort() {
Loading
Loading
Loading
Loading
@@ -22,7 +22,7 @@ export default class Labels {
updateColorPreview() {
const previewColor = $('input#label_color').val();
return $('div.label-color-preview').css('background-color', previewColor);
// Updates the the preview color with the hex-color input
// Updates the the preview color with the hex-color input
}
 
// Updates the preview color with a click on a suggested color
Loading
Loading
Loading
Loading
@@ -5,7 +5,9 @@ import initFlyOutNav from './fly_out_nav';
function hideEndFade($scrollingTabs) {
$scrollingTabs.each(function scrollTabsLoop() {
const $this = $(this);
$this.siblings('.fade-right').toggleClass('scrolling', Math.round($this.width()) < $this.prop('scrollWidth'));
$this
.siblings('.fade-right')
.toggleClass('scrolling', Math.round($this.width()) < $this.prop('scrollWidth'));
});
}
 
Loading
Loading
@@ -15,38 +17,42 @@ export default function initLayoutNav() {
 
initFlyOutNav();
 
$(document).on('init.scrolling-tabs', () => {
const $scrollingTabs = $('.scrolling-tabs').not('.is-initialized');
$scrollingTabs.addClass('is-initialized');
$(document)
.on('init.scrolling-tabs', () => {
const $scrollingTabs = $('.scrolling-tabs').not('.is-initialized');
$scrollingTabs.addClass('is-initialized');
 
$(window).on('resize.nav', () => {
hideEndFade($scrollingTabs);
}).trigger('resize.nav');
$(window)
.on('resize.nav', () => {
hideEndFade($scrollingTabs);
})
.trigger('resize.nav');
 
$scrollingTabs.on('scroll', function tabsScrollEvent() {
const $this = $(this);
const currentPosition = $this.scrollLeft();
const maxPosition = $this.prop('scrollWidth') - $this.outerWidth();
$scrollingTabs.on('scroll', function tabsScrollEvent() {
const $this = $(this);
const currentPosition = $this.scrollLeft();
const maxPosition = $this.prop('scrollWidth') - $this.outerWidth();
 
$this.siblings('.fade-left').toggleClass('scrolling', currentPosition > 0);
$this.siblings('.fade-right').toggleClass('scrolling', currentPosition < maxPosition - 1);
});
$this.siblings('.fade-left').toggleClass('scrolling', currentPosition > 0);
$this.siblings('.fade-right').toggleClass('scrolling', currentPosition < maxPosition - 1);
});
 
$scrollingTabs.each(function scrollTabsEachLoop() {
const $this = $(this);
const scrollingTabWidth = $this.width();
const $active = $this.find('.active');
const activeWidth = $active.width();
$scrollingTabs.each(function scrollTabsEachLoop() {
const $this = $(this);
const scrollingTabWidth = $this.width();
const $active = $this.find('.active');
const activeWidth = $active.width();
 
if ($active.length) {
const offset = $active.offset().left + activeWidth;
if ($active.length) {
const offset = $active.offset().left + activeWidth;
 
if (offset > scrollingTabWidth - 30) {
const scrollLeft = (offset - (scrollingTabWidth / 2)) - (activeWidth / 2);
if (offset > scrollingTabWidth - 30) {
const scrollLeft = offset - scrollingTabWidth / 2 - activeWidth / 2;
 
$this.scrollLeft(scrollLeft);
$this.scrollLeft(scrollLeft);
}
}
}
});
}).trigger('init.scrolling-tabs');
});
})
.trigger('init.scrolling-tabs');
}
Loading
Loading
@@ -70,7 +70,7 @@ LineHighlighter.prototype.highlightHash = function(newHash) {
const scrollOptions = {
// Scroll to the first highlighted line on initial load
// Offset -50 for the sticky top bar, and another -100 for some context
offset: -150
offset: -150,
};
if (this.options.scrollFileHolder) {
$(this.options.fileHolderSelector).scrollTo(lineSelector, scrollOptions);
Loading
Loading
@@ -85,7 +85,9 @@ LineHighlighter.prototype.clickHandler = function(event) {
var current, lineNumber, range;
event.preventDefault();
this.clearHighlight();
lineNumber = $(event.target).closest('a').data('lineNumber');
lineNumber = $(event.target)
.closest('a')
.data('lineNumber');
current = this.hashToRange(this._hash);
if (!(current[0] && event.shiftKey)) {
// If there's no current selection, or there is but Shift wasn't held,
Loading
Loading
@@ -104,7 +106,7 @@ LineHighlighter.prototype.clickHandler = function(event) {
};
 
LineHighlighter.prototype.clearHighlight = function() {
return $("." + this.highlightLineClass).removeClass(this.highlightLineClass);
return $('.' + this.highlightLineClass).removeClass(this.highlightLineClass);
};
 
// Convert a URL hash String into line numbers
Loading
Loading
@@ -135,7 +137,7 @@ LineHighlighter.prototype.hashToRange = function(hash) {
//
// lineNumber - Line number to highlight
LineHighlighter.prototype.highlightLine = function(lineNumber) {
return $("#LC" + lineNumber).addClass(this.highlightLineClass);
return $('#LC' + lineNumber).addClass(this.highlightLineClass);
};
 
// Highlight all lines within a range
Loading
Loading
@@ -160,9 +162,9 @@ LineHighlighter.prototype.highlightRange = function(range) {
LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) {
var hash;
if (lastLineNumber) {
hash = "#L" + firstLineNumber + "-" + lastLineNumber;
hash = '#L' + firstLineNumber + '-' + lastLineNumber;
} else {
hash = "#L" + firstLineNumber;
hash = '#L' + firstLineNumber;
}
this._hash = hash;
return this.__setLocationHash__(hash);
Loading
Loading
@@ -172,11 +174,15 @@ LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) {
//
// This method is stubbed in tests.
LineHighlighter.prototype.__setLocationHash__ = function(value) {
return window.history.pushState({
url: value
// We're using pushState instead of assigning location.hash directly to
// prevent the page from scrolling on the hashchange event
}, document.title, value);
return window.history.pushState(
{
url: value,
// We're using pushState instead of assigning location.hash directly to
// prevent the page from scrolling on the hashchange event
},
document.title,
value,
);
};
 
export default LineHighlighter;
Loading
Loading
@@ -15,7 +15,7 @@ export default (input, parameters, escapeParameters = true) => {
let output = input;
 
if (parameters) {
Object.keys(parameters).forEach((parameterName) => {
Object.keys(parameters).forEach(parameterName => {
const parameterValue = parameters[parameterName];
const escapedParameterValue = escapeParameters ? _.escape(parameterValue) : parameterValue;
output = output.replace(new RegExp(`%{${parameterName}}`, 'g'), escapedParameterValue);
Loading
Loading
Loading
Loading
@@ -9,7 +9,9 @@ import { parsePikadayDate, pikadayToString } from './lib/utils/datefix';
//
export default function memberExpirationDate(selector = '.js-access-expiration-date') {
function toggleClearInput() {
$(this).closest('.clearable-input').toggleClass('has-value', $(this).val() !== '');
$(this)
.closest('.clearable-input')
.toggleClass('has-value', $(this).val() !== '');
}
const inputs = $(selector);
 
Loading
Loading
@@ -40,7 +42,9 @@ export default function memberExpirationDate(selector = '.js-access-expiration-d
inputs.next('.js-clear-input').on('click', function clicked(event) {
event.preventDefault();
 
const input = $(this).closest('.clearable-input').find(selector);
const input = $(this)
.closest('.clearable-input')
.find(selector);
const calendar = input.data('pikaday');
 
calendar.setDate(null);
Loading
Loading
Loading
Loading
@@ -16,26 +16,29 @@ function MergeRequest(opts) {
this.opts = opts != null ? opts : {};
this.submitNoteForm = this.submitNoteForm.bind(this);
this.$el = $('.merge-request');
this.$('.show-all-commits').on('click', (function(_this) {
return function() {
return _this.showAllCommits();
};
})(this));
this.$('.show-all-commits').on(
'click',
(function(_this) {
return function() {
return _this.showAllCommits();
};
})(this),
);
 
this.initTabs();
this.initMRBtnListeners();
this.initCommitMessageListeners();
this.closeReopenReportToggle = IssuablesHelper.initCloseReopenReport();
 
if ($("a.btn-close").length) {
if ($('a.btn-close').length) {
this.taskList = new TaskList({
dataType: 'merge_request',
fieldName: 'description',
selector: '.detail-page-description',
onSuccess: (result) => {
onSuccess: result => {
document.querySelector('#task_status').innerText = result.task_status;
document.querySelector('#task_status_short').innerText = result.task_status_short;
}
},
});
}
}
Loading
Loading
@@ -84,7 +87,7 @@ MergeRequest.prototype.initMRBtnListeners = function() {
 
MergeRequest.prototype.submitNoteForm = function(form, $button) {
var noteText;
noteText = form.find("textarea.js-note-text").val();
noteText = form.find('textarea.js-note-text').val();
if (noteText.trim().length > 0) {
form.submit();
$button.data('submitted', true);
Loading
Loading
@@ -122,7 +125,7 @@ MergeRequest.setStatusBoxToMerged = function() {
 
MergeRequest.decreaseCounter = function(by = 1) {
const $el = $('.js-merge-counter');
const count = Math.max((parseInt($el.text().replace(/[^\d]/, ''), 10) - by), 0);
const count = Math.max(parseInt($el.text().replace(/[^\d]/, ''), 10) - by, 0);
 
$el.text(addDelimiter(count));
};
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ export default class Milestone {
}
 
bindTabsSwitching() {
return $('a[data-toggle="tab"]').on('show.bs.tab', (e) => {
return $('a[data-toggle="tab"]').on('show.bs.tab', e => {
const $target = $(e.target);
 
window.location.hash = $target.attr('href');
Loading
Loading
@@ -36,7 +36,8 @@ export default class Milestone {
const tabElId = $target.attr('href');
 
if (endpoint && !$target.hasClass('is-loaded')) {
axios.get(endpoint)
axios
.get(endpoint)
.then(({ data }) => {
$(tabElId).html(data.html);
$target.addClass('is-loaded');
Loading
Loading
@@ -46,23 +47,28 @@ export default class Milestone {
}
 
static initDeprecationMessage() {
const deprecationMesssageContainer = document.querySelector('.js-milestone-deprecation-message');
const deprecationMesssageContainer = document.querySelector(
'.js-milestone-deprecation-message',
);
 
if (!deprecationMesssageContainer) return;
 
const deprecationMessage = deprecationMesssageContainer.querySelector('.js-milestone-deprecation-message-template').innerHTML;
const deprecationMessage = deprecationMesssageContainer.querySelector(
'.js-milestone-deprecation-message-template',
).innerHTML;
const $popover = $('.js-popover-link', deprecationMesssageContainer);
const hideOnScroll = togglePopover.bind($popover, false);
 
$popover.popover({
content: deprecationMessage,
html: true,
placement: 'bottom',
})
.on('mouseenter', mouseenter)
.on('mouseleave', debouncedMouseleave())
.on('show.bs.popover', () => {
window.addEventListener('scroll', hideOnScroll, { once: true });
});
$popover
.popover({
content: deprecationMessage,
html: true,
placement: 'bottom',
})
.on('mouseenter', mouseenter)
.on('mouseleave', debouncedMouseleave())
.on('show.bs.popover', () => {
window.addEventListener('scroll', hideOnScroll, { once: true });
});
}
}
Loading
Loading
@@ -46,7 +46,7 @@ export default class MiniPipelineGraph {
$(document).on(
'click',
`${this.container} .js-builds-dropdown-list a.mini-pipeline-graph-dropdown-item`,
(e) => {
e => {
e.stopPropagation();
},
);
Loading
Loading
@@ -82,7 +82,8 @@ export default class MiniPipelineGraph {
this.renderBuildsList(button, '');
this.toggleLoading(button);
 
axios.get(endpoint)
axios
.get(endpoint)
.then(({ data }) => {
this.toggleLoading(button);
this.renderBuildsList(button, data.html);
Loading
Loading
@@ -90,7 +91,11 @@ export default class MiniPipelineGraph {
})
.catch(() => {
this.toggleLoading(button);
if ($(button).parent().hasClass('open')) {
if (
$(button)
.parent()
.hasClass('open')
) {
$(button).dropdown('toggle');
}
flash('An error occurred while fetching the builds.', 'alert');
Loading
Loading
@@ -104,8 +109,8 @@ export default class MiniPipelineGraph {
* @return {type}
*/
toggleLoading(stageContainer) {
stageContainer.parentElement.querySelector(
`${this.dropdownListSelector} .js-builds-dropdown-loading`,
).classList.toggle('hidden');
stageContainer.parentElement
.querySelector(`${this.dropdownListSelector} .js-builds-dropdown-loading`)
.classList.toggle('hidden');
}
}
Loading
Loading
@@ -14,14 +14,14 @@ export default class NamespaceSelect {
selectable: true,
filterRemote: true,
search: {
fields: ['path']
fields: ['path'],
},
fieldName: fieldName,
toggleLabel: function(selected) {
if (selected.id == null) {
return selected.text;
} else {
return selected.kind + ": " + selected.full_path;
return selected.kind + ': ' + selected.full_path;
}
},
data: function(term, dataCallback) {
Loading
Loading
@@ -29,7 +29,7 @@ export default class NamespaceSelect {
if (isFilter) {
const anyNamespace = {
text: 'Any namespace',
id: null
id: null,
};
namespaces.unshift(anyNamespace);
namespaces.splice(1, 0, 'divider');
Loading
Loading
@@ -41,7 +41,7 @@ export default class NamespaceSelect {
if (namespace.id == null) {
return namespace.text;
} else {
return namespace.kind + ": " + namespace.full_path;
return namespace.kind + ': ' + namespace.full_path;
}
},
renderRow: this.renderRow,
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ export default (function() {
this.mtime = 0;
this.mspace = 0;
this.parents = {};
this.colors = ["#000"];
this.colors = ['#000'];
this.offsetX = 150;
this.offsetY = 20;
this.unitTime = 30;
Loading
Loading
@@ -30,9 +30,10 @@ export default (function() {
}
 
BranchGraph.prototype.load = function() {
axios.get(this.options.url)
axios
.get(this.options.url)
.then(({ data }) => {
$(".loading", this.element).hide();
$('.loading', this.element).hide();
this.prepareData(data.days, data.commits);
this.buildGraph();
})
Loading
Loading
@@ -71,17 +72,19 @@ export default (function() {
c = ref[j];
this.mtime = Math.max(this.mtime, c.time);
this.mspace = Math.max(this.mspace, c.space);
results.push((function() {
var l, len1, ref1, results1;
ref1 = c.parents;
results1 = [];
for (l = 0, len1 = ref1.length; l < len1; l += 1) {
p = ref1[l];
this.parents[p[0]] = true;
results1.push(this.mspace = Math.max(this.mspace, p[1]));
}
return results1;
}).call(this));
results.push(
function() {
var l, len1, ref1, results1;
ref1 = c.parents;
results1 = [];
for (l = 0, len1 = ref1.length; l < len1; l += 1) {
p = ref1[l];
this.parents[p[0]] = true;
results1.push((this.mspace = Math.max(this.mspace, p[1])));
}
return results1;
}.call(this),
);
}
return results;
};
Loading
Loading
@@ -91,11 +94,11 @@ export default (function() {
k = 0;
results = [];
while (k < this.mspace) {
this.colors.push(Raphael.getColor(.8));
this.colors.push(Raphael.getColor(0.8));
// Skipping a few colors in the spectrum to get more contrast between colors
Raphael.getColor();
Raphael.getColor();
results.push(k += 1);
results.push((k += 1));
}
return results;
};
Loading
Loading
@@ -104,12 +107,12 @@ export default (function() {
var cuday, cumonth, day, j, len, mm, ref;
const { r } = this;
cuday = 0;
cumonth = "";
cumonth = '';
r.rect(0, 0, 40, this.barHeight).attr({
fill: "#222"
fill: '#222',
});
r.rect(40, 0, 30, this.barHeight).attr({
fill: "#444"
fill: '#444',
});
ref = this.days;
 
Loading
Loading
@@ -118,16 +121,16 @@ export default (function() {
if (cuday !== day[0] || cumonth !== day[1]) {
// Dates
r.text(55, this.offsetY + this.unitTime * mm, day[0]).attr({
font: "12px Monaco, monospace",
fill: "#BBB"
font: '12px Monaco, monospace',
fill: '#BBB',
});
[cuday] = day;
}
if (cumonth !== day[1]) {
// Months
r.text(20, this.offsetY + this.unitTime * mm, day[1]).attr({
font: "12px Monaco, monospace",
fill: "#EEE"
font: '12px Monaco, monospace',
fill: '#EEE',
});
 
// eslint-disable-next-line prefer-destructuring
Loading
Loading
@@ -173,11 +176,13 @@ export default (function() {
BranchGraph.prototype.bindEvents = function() {
const { element } = this;
 
return $(element).scroll((function(_this) {
return function(event) {
return _this.renderPartialGraph();
};
})(this));
return $(element).scroll(
(function(_this) {
return function(event) {
return _this.renderPartialGraph();
};
})(this),
);
};
 
BranchGraph.prototype.scrollDown = function() {
Loading
Loading
@@ -219,46 +224,53 @@ export default (function() {
shortrefs = commit.refs;
// Truncate if longer than 15 chars
if (shortrefs.length > 17) {
shortrefs = shortrefs.substr(0, 15) + "";
shortrefs = shortrefs.substr(0, 15) + '';
}
text = r.text(x + 4, y, shortrefs).attr({
"text-anchor": "start",
font: "10px Monaco, monospace",
fill: "#FFF",
title: commit.refs
'text-anchor': 'start',
font: '10px Monaco, monospace',
fill: '#FFF',
title: commit.refs,
});
textbox = text.getBBox();
// Create rectangle based on the size of the textbox
rect = r.rect(x, y - 7, textbox.width + 5, textbox.height + 5, 4).attr({
fill: "#000",
"fill-opacity": .5,
stroke: "none"
fill: '#000',
'fill-opacity': 0.5,
stroke: 'none',
});
triangle = r.path(["M", x - 5, y, "L", x - 15, y - 4, "L", x - 15, y + 4, "Z"]).attr({
fill: "#000",
"fill-opacity": .5,
stroke: "none"
triangle = r.path(['M', x - 5, y, 'L', x - 15, y - 4, 'L', x - 15, y + 4, 'Z']).attr({
fill: '#000',
'fill-opacity': 0.5,
stroke: 'none',
});
label = r.set(rect, text);
label.transform(["t", -rect.getBBox().width - 15, 0]);
label.transform(['t', -rect.getBBox().width - 15, 0]);
// Set text to front
return text.toFront();
};
 
BranchGraph.prototype.appendAnchor = function(x, y, commit) {
const { r, top, options } = this;
const anchor = r.circle(x, y, 10).attr({
fill: "#000",
opacity: 0,
cursor: "pointer"
}).click(function() {
return window.open(options.commit_url.replace("%s", commit.id), "_blank");
}).hover(function() {
this.tooltip = r.commitTooltip(x + 5, y, commit);
return top.push(this.tooltip.insertBefore(this));
}, function() {
return this.tooltip && this.tooltip.remove() && delete this.tooltip;
});
const anchor = r
.circle(x, y, 10)
.attr({
fill: '#000',
opacity: 0,
cursor: 'pointer',
})
.click(function() {
return window.open(options.commit_url.replace('%s', commit.id), '_blank');
})
.hover(
function() {
this.tooltip = r.commitTooltip(x + 5, y, commit);
return top.push(this.tooltip.insertBefore(this));
},
function() {
return this.tooltip && this.tooltip.remove() && delete this.tooltip;
},
);
return top.push(anchor);
};
 
Loading
Loading
@@ -266,7 +278,7 @@ export default (function() {
const { r } = this;
r.circle(x, y, 3).attr({
fill: this.colors[commit.space],
stroke: "none"
stroke: 'none',
});
 
const avatar_box_x = this.offsetX + this.unitSpace * this.mspace + 10;
Loading
Loading
@@ -274,13 +286,15 @@ export default (function() {
 
r.rect(avatar_box_x, avatar_box_y, 20, 20).attr({
stroke: this.colors[commit.space],
"stroke-width": 2
'stroke-width': 2,
});
r.image(commit.author.icon, avatar_box_x, avatar_box_y, 20, 20);
return r.text(this.offsetX + this.unitSpace * this.mspace + 35, y, commit.message.split("\n")[0]).attr({
"text-anchor": "start",
font: "14px Monaco, monospace"
});
return r
.text(this.offsetX + this.unitSpace * this.mspace + 35, y, commit.message.split('\n')[0])
.attr({
'text-anchor': 'start',
font: '14px Monaco, monospace',
});
};
 
BranchGraph.prototype.drawLines = function(x, y, commit) {
Loading
Loading
@@ -304,30 +318,32 @@ export default (function() {
// Build line shape
if (parent[1] === commit.space) {
offset = [0, 5];
arrow = "l-2,5,4,0,-2,-5,0,5";
arrow = 'l-2,5,4,0,-2,-5,0,5';
} else if (parent[1] < commit.space) {
offset = [3, 3];
arrow = "l5,0,-2,4,-3,-4,4,2";
arrow = 'l5,0,-2,4,-3,-4,4,2';
} else {
offset = [-3, 3];
arrow = "l-5,0,2,4,3,-4,-4,2";
arrow = 'l-5,0,2,4,3,-4,-4,2';
}
// Start point
route = ["M", x + offset[0], y + offset[1]];
route = ['M', x + offset[0], y + offset[1]];
// Add arrow if not first parent
if (i > 0) {
route.push(arrow);
}
// Circumvent if overlap
if (commit.space !== parentCommit.space || commit.space !== parent[1]) {
route.push("L", parentX2, y + 10, "L", parentX2, parentY - 5);
route.push('L', parentX2, y + 10, 'L', parentX2, parentY - 5);
}
// End point
route.push("L", parentX1, parentY);
results.push(r.path(route).attr({
stroke: color,
"stroke-width": 2
}));
route.push('L', parentX1, parentY);
results.push(
r.path(route).attr({
stroke: color,
'stroke-width': 2,
}),
);
}
return results;
};
Loading
Loading
@@ -337,10 +353,10 @@ export default (function() {
const { r } = this;
const x = this.offsetX + this.unitSpace * (this.mspace - commit.space);
const y = this.offsetY + this.unitTime * commit.time;
r.path(["M", x + 5, y, "L", x + 15, y + 4, "L", x + 15, y - 4, "Z"]).attr({
fill: "#000",
"fill-opacity": .5,
stroke: "none"
r.path(['M', x + 5, y, 'L', x + 15, y + 4, 'L', x + 15, y - 4, 'Z']).attr({
fill: '#000',
'fill-opacity': 0.5,
stroke: 'none',
});
// Displayed in the center
return this.element.scrollTop(y - this.graphHeight / 2);
Loading
Loading
Loading
Loading
@@ -49,7 +49,7 @@ Raphael.prototype.textWrap = function testWrap(t, width) {
const s = [];
for (let j = 0, len = words.length; j < len; j += 1) {
const word = words[j];
if (x + (word.length * letterWidth) > width) {
if (x + word.length * letterWidth > width) {
s.push('\n');
x = 0;
}
Loading
Loading
Loading
Loading
@@ -30,24 +30,24 @@ export default class NewBranchForm {
startsWith = {
pattern: /^(\/|\.)/g,
prefix: "can't start with",
conjunction: "or"
conjunction: 'or',
};
endsWith = {
pattern: /(\/|\.|\.lock)$/g,
prefix: "can't end in",
conjunction: "or"
conjunction: 'or',
};
invalid = {
pattern: /(\s|~|\^|:|\?|\*|\[|\\|\.\.|@\{|\/{2,}){1}/g,
prefix: "can't contain",
conjunction: ", "
conjunction: ', ',
};
single = {
pattern: /^@+$/g,
prefix: "can't be",
conjunction: "or"
conjunction: 'or',
};
return this.restrictions = [startsWith, invalid, endsWith, single];
return (this.restrictions = [startsWith, invalid, endsWith, single]);
}
 
validate() {
Loading
Loading
@@ -73,7 +73,7 @@ export default class NewBranchForm {
return "'" + value + "'";
}
});
return restriction.prefix + " " + (formatted.join(restriction.conjunction));
return restriction.prefix + ' ' + formatted.join(restriction.conjunction);
};
validator = (function(_this) {
return function(errors, restriction) {
Loading
Loading
@@ -88,7 +88,7 @@ export default class NewBranchForm {
})(this);
errors = this.restrictions.reduce(validator, []);
if (errors.length > 0) {
errorMessage = $("<span/>").text(errors.join(', '));
errorMessage = $('<span/>').text(errors.join(', '));
return this.branchNameError.append(errorMessage);
}
}
Loading
Loading
Loading
Loading
@@ -6,9 +6,7 @@ export default class NewCommitForm {
this.branchName = form.find('.js-branch-name');
this.originalBranch = form.find('.js-original-branch');
this.createMergeRequest = form.find('.js-create-merge-request');
this.createMergeRequestContainer = form.find(
'.js-create-merge-request-container',
);
this.createMergeRequestContainer = form.find('.js-create-merge-request-container');
this.branchName.keyup(this.renderDestination);
this.renderDestination();
}
Loading
Loading
Loading
Loading
@@ -18,7 +18,9 @@ export default function notificationsDropdown() {
 
$(document).on('ajax:success', '.notification-form', (e, data) => {
if (data.saved) {
$(e.currentTarget).closest('.js-notification-dropdown').replaceWith(data.html);
$(e.currentTarget)
.closest('.js-notification-dropdown')
.replaceWith(data.html);
} else {
Flash('Failed to save new settings', 'alert');
}
Loading
Loading
Loading
Loading
@@ -22,7 +22,8 @@ export default class NotificationsForm {
 
// eslint-disable-next-line class-methods-use-this
showCheckboxLoadingSpinner($parent) {
$parent.addClass('is-loading')
$parent
.addClass('is-loading')
.find('.custom-notification-event-loading')
.removeClass('fa-check')
.addClass('fa-spin fa-spinner')
Loading
Loading
@@ -38,9 +39,12 @@ export default class NotificationsForm {
.then(({ data }) => {
$checkbox.enable();
if (data.saved) {
$parent.find('.custom-notification-event-loading').toggleClass('fa-spin fa-spinner fa-check is-done');
$parent
.find('.custom-notification-event-loading')
.toggleClass('fa-spin fa-spinner fa-check is-done');
setTimeout(() => {
$parent.removeClass('is-loading')
$parent
.removeClass('is-loading')
.find('.custom-notification-event-loading')
.toggleClass('fa-spin fa-spinner fa-check is-done');
}, 2000);
Loading
Loading
Loading
Loading
@@ -24,22 +24,25 @@ export default {
 
getOld() {
this.loading.show();
axios.get(this.url, {
params: {
limit: this.limit,
offset: this.offset,
},
}).then(({ data }) => {
this.append(data.count, this.prepareData(data.html));
this.callback();
axios
.get(this.url, {
params: {
limit: this.limit,
offset: this.offset,
},
})
.then(({ data }) => {
this.append(data.count, this.prepareData(data.html));
this.callback();
 
// keep loading until we've filled the viewport height
if (!this.disable && !this.isScrollable()) {
this.getOld();
} else {
this.loading.hide();
}
}).catch(() => this.loading.hide());
// keep loading until we've filled the viewport height
if (!this.disable && !this.isScrollable()) {
this.getOld();
} else {
this.loading.hide();
}
})
.catch(() => this.loading.hide());
},
 
append(count, html) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment