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 386 additions and 256 deletions
<script>
import pdfjsLib from 'vendor/pdf';
import workerSrc from 'vendor/pdf.worker.min';
import pdfjsLib from 'vendor/pdf';
import workerSrc from 'vendor/pdf.worker.min';
 
import page from './page/index.vue';
import page from './page/index.vue';
 
export default {
components: { page },
props: {
pdf: {
type: [String, Uint8Array],
required: true,
},
export default {
components: { page },
props: {
pdf: {
type: [String, Uint8Array],
required: true,
},
data() {
return {
loading: false,
pages: [],
};
},
data() {
return {
loading: false,
pages: [],
};
},
computed: {
document() {
return typeof this.pdf === 'string' ? this.pdf : { data: this.pdf };
},
computed: {
document() {
return typeof this.pdf === 'string' ? this.pdf : { data: this.pdf };
},
hasPDF() {
return this.pdf && this.pdf.length > 0;
},
hasPDF() {
return this.pdf && this.pdf.length > 0;
},
watch: { pdf: 'load' },
mounted() {
pdfjsLib.PDFJS.workerSrc = workerSrc;
if (this.hasPDF) this.load();
},
watch: { pdf: 'load' },
mounted() {
pdfjsLib.PDFJS.workerSrc = workerSrc;
if (this.hasPDF) this.load();
},
methods: {
load() {
this.pages = [];
return pdfjsLib
.getDocument(this.document)
.then(this.renderPages)
.then(() => this.$emit('pdflabload'))
.catch(error => this.$emit('pdflaberror', error))
.then(() => {
this.loading = false;
});
},
methods: {
load() {
this.pages = [];
return pdfjsLib.getDocument(this.document)
.then(this.renderPages)
.then(() => this.$emit('pdflabload'))
.catch(error => this.$emit('pdflaberror', error))
.then(() => { this.loading = false; });
},
renderPages(pdf) {
const pagePromises = [];
this.loading = true;
for (let num = 1; num <= pdf.numPages; num += 1) {
pagePromises.push(
pdf.getPage(num).then(p => this.pages.push(p)),
);
}
return Promise.all(pagePromises);
},
renderPages(pdf) {
const pagePromises = [];
this.loading = true;
for (let num = 1; num <= pdf.numPages; num += 1) {
pagePromises.push(pdf.getPage(num).then(p => this.pages.push(p)));
}
return Promise.all(pagePromises);
},
};
},
};
</script>
 
<template>
Loading
Loading
@@ -69,9 +70,9 @@
</template>
 
<style>
.pdf-viewer {
background: url('./assets/img/bg.gif');
display: flex;
flex-flow: column nowrap;
}
.pdf-viewer {
background: url('./assets/img/bg.gif');
display: flex;
flex-flow: column nowrap;
}
</style>
<script>
export default {
props: {
page: {
type: Object,
required: true,
},
number: {
type: Number,
required: true,
},
export default {
props: {
page: {
type: Object,
required: true,
},
data() {
return {
scale: 4,
rendering: false,
};
number: {
type: Number,
required: true,
},
},
data() {
return {
scale: 4,
rendering: false,
};
},
computed: {
viewport() {
return this.page.getViewport(this.scale);
},
computed: {
viewport() {
return this.page.getViewport(this.scale);
},
context() {
return this.$refs.canvas.getContext('2d');
},
renderContext() {
return {
canvasContext: this.context,
viewport: this.viewport,
};
},
context() {
return this.$refs.canvas.getContext('2d');
},
mounted() {
this.$refs.canvas.height = this.viewport.height;
this.$refs.canvas.width = this.viewport.width;
this.rendering = true;
this.page.render(this.renderContext)
.then(() => { this.rendering = false; })
.catch(error => this.$emit('pdflaberror', error));
renderContext() {
return {
canvasContext: this.context,
viewport: this.viewport,
};
},
};
},
mounted() {
this.$refs.canvas.height = this.viewport.height;
this.$refs.canvas.width = this.viewport.width;
this.rendering = true;
this.page
.render(this.renderContext)
.then(() => {
this.rendering = false;
})
.catch(error => this.$emit('pdflaberror', error));
},
};
</script>
 
<template>
Loading
Loading
@@ -51,20 +54,20 @@
</template>
 
<style>
.pdf-page {
margin: 8px auto 0 auto;
border-top: 1px #ddd solid;
border-bottom: 1px #ddd solid;
width: 100%;
}
.pdf-page {
margin: 8px auto 0 auto;
border-top: 1px #ddd solid;
border-bottom: 1px #ddd solid;
width: 100%;
}
 
.pdf-page:first-child {
margin-top: 0px;
border-top: 0px;
}
.pdf-page:first-child {
margin-top: 0px;
border-top: 0px;
}
 
.pdf-page:last-child {
margin-bottom: 0px;
border-bottom: 0px;
}
.pdf-page:last-child {
margin-bottom: 0px;
border-bottom: 0px;
}
</style>
Loading
Loading
@@ -64,10 +64,7 @@ export default {
return [];
}
const { details } = this.pipeline;
return [
...(details.manual_actions || []),
...(details.scheduled_actions || []),
];
return [...(details.manual_actions || []), ...(details.scheduled_actions || [])];
},
/**
* If provided, returns the commit tag.
Loading
Loading
Loading
Loading
@@ -10,14 +10,14 @@ import { __ } from '~/locale';
const highlighter = function(element, text, matches) {
var highlightText, j, lastIndex, len, matchIndex, matchedChars, unmatched;
lastIndex = 0;
highlightText = "";
highlightText = '';
matchedChars = [];
for (j = 0, len = matches.length; j < len; j += 1) {
matchIndex = matches[j];
unmatched = text.substring(lastIndex, matchIndex);
if (unmatched) {
if (matchedChars.length) {
element.append(matchedChars.join("").bold());
element.append(matchedChars.join('').bold());
}
matchedChars = [];
element.append(document.createTextNode(unmatched));
Loading
Loading
@@ -26,7 +26,7 @@ const highlighter = function(element, text, matches) {
lastIndex = matchIndex + 1;
}
if (matchedChars.length) {
element.append(matchedChars.join("").bold());
element.append(matchedChars.join('').bold());
}
return element.append(document.createTextNode(text.substring(lastIndex)));
};
Loading
Loading
@@ -40,7 +40,7 @@ export default class ProjectFindFile {
this.selectRowDown = this.selectRowDown.bind(this);
this.selectRowUp = this.selectRowUp.bind(this);
this.filePaths = {};
this.inputElement = this.element.find(".file-finder-input");
this.inputElement = this.element.find('.file-finder-input');
// init event
this.initEvent();
// focus text input box
Loading
Loading
@@ -50,38 +50,51 @@ export default class ProjectFindFile {
}
 
initEvent() {
this.inputElement.off("keyup");
this.inputElement.on("keyup", (function(_this) {
return function(event) {
var oldValue, ref, target, value;
target = $(event.target);
value = target.val();
oldValue = (ref = target.data("oldValue")) != null ? ref : "";
if (value !== oldValue) {
target.data("oldValue", value);
_this.findFile();
return _this.element.find("tr.tree-item").eq(0).addClass("selected").focus();
}
};
})(this));
this.inputElement.off('keyup');
this.inputElement.on(
'keyup',
(function(_this) {
return function(event) {
var oldValue, ref, target, value;
target = $(event.target);
value = target.val();
oldValue = (ref = target.data('oldValue')) != null ? ref : '';
if (value !== oldValue) {
target.data('oldValue', value);
_this.findFile();
return _this.element
.find('tr.tree-item')
.eq(0)
.addClass('selected')
.focus();
}
};
})(this),
);
}
 
findFile() {
var result, searchText;
searchText = this.inputElement.val();
result = searchText.length > 0 ? fuzzaldrinPlus.filter(this.filePaths, searchText) : this.filePaths;
result =
searchText.length > 0 ? fuzzaldrinPlus.filter(this.filePaths, searchText) : this.filePaths;
return this.renderList(result, searchText);
// find file
// find file
}
 
// files pathes load
load(url) {
axios.get(url)
axios
.get(url)
.then(({ data }) => {
this.element.find('.loading').hide();
this.filePaths = data;
this.findFile();
this.element.find('.files-slider tr.tree-item').eq(0).addClass('selected').focus();
this.element
.find('.files-slider tr.tree-item')
.eq(0)
.addClass('selected')
.focus();
})
.catch(() => flash(__('An error occurred while loading filenames')));
}
Loading
Loading
@@ -89,7 +102,7 @@ export default class ProjectFindFile {
// render result
renderList(filePaths, searchText) {
var blobItemUrl, filePath, html, i, len, matches, results;
this.element.find(".tree-table > tbody").empty();
this.element.find('.tree-table > tbody').empty();
results = [];
 
for (i = 0, len = filePaths.length; i < len; i += 1) {
Loading
Loading
@@ -100,9 +113,9 @@ export default class ProjectFindFile {
if (searchText) {
matches = fuzzaldrinPlus.match(filePath, searchText);
}
blobItemUrl = this.options.blobUrlTemplate + "/" + filePath;
blobItemUrl = this.options.blobUrlTemplate + '/' + filePath;
html = ProjectFindFile.makeHtml(filePath, matches, blobItemUrl);
results.push(this.element.find(".tree-table > tbody").append(html));
results.push(this.element.find('.tree-table > tbody').append(html));
}
return results;
}
Loading
Loading
@@ -110,52 +123,56 @@ export default class ProjectFindFile {
// make tbody row html
static makeHtml(filePath, matches, blobItemUrl) {
var $tr;
$tr = $("<tr class='tree-item'><td class='tree-item-file-name link-container'><a><i class='fa fa-file-text-o fa-fw'></i><span class='str-truncated'></span></a></td></tr>");
$tr = $(
"<tr class='tree-item'><td class='tree-item-file-name link-container'><a><i class='fa fa-file-text-o fa-fw'></i><span class='str-truncated'></span></a></td></tr>",
);
if (matches) {
$tr.find("a").replaceWith(highlighter($tr.find("a"), filePath, matches).attr("href", blobItemUrl));
$tr
.find('a')
.replaceWith(highlighter($tr.find('a'), filePath, matches).attr('href', blobItemUrl));
} else {
$tr.find("a").attr("href", blobItemUrl);
$tr.find(".str-truncated").text(filePath);
$tr.find('a').attr('href', blobItemUrl);
$tr.find('.str-truncated').text(filePath);
}
return $tr;
}
 
selectRow(type) {
var next, rows, selectedRow;
rows = this.element.find(".files-slider tr.tree-item");
selectedRow = this.element.find(".files-slider tr.tree-item.selected");
rows = this.element.find('.files-slider tr.tree-item');
selectedRow = this.element.find('.files-slider tr.tree-item.selected');
if (rows && rows.length > 0) {
if (selectedRow && selectedRow.length > 0) {
if (type === "UP") {
if (type === 'UP') {
next = selectedRow.prev();
} else if (type === "DOWN") {
} else if (type === 'DOWN') {
next = selectedRow.next();
}
if (next.length > 0) {
selectedRow.removeClass("selected");
selectedRow.removeClass('selected');
selectedRow = next;
}
} else {
selectedRow = rows.eq(0);
}
return selectedRow.addClass("selected").focus();
return selectedRow.addClass('selected').focus();
}
}
 
selectRowUp() {
return this.selectRow("UP");
return this.selectRow('UP');
}
 
selectRowDown() {
return this.selectRow("DOWN");
return this.selectRow('DOWN');
}
 
goToTree() {
return window.location.href = this.options.treeUrl;
return (window.location.href = this.options.treeUrl);
}
 
goToBlob() {
var $link = this.element.find(".tree-item.selected .tree-item-file-name a");
var $link = this.element.find('.tree-item.selected .tree-item-file-name a');
 
if ($link.length) {
$link.get(0).click();
Loading
Loading
Loading
Loading
@@ -5,4 +5,3 @@ export default function projectImport() {
visitUrl(window.location.href);
}, 5000);
}
Loading
Loading
@@ -31,32 +31,35 @@ export default class ProjectLabelSubscription {
 
$btn.addClass('disabled');
 
axios.post(url).then(() => {
let newStatus;
let newAction;
axios
.post(url)
.then(() => {
let newStatus;
let newAction;
 
if (oldStatus === 'unsubscribed') {
[newStatus, newAction] = ['subscribed', 'Unsubscribe'];
} else {
[newStatus, newAction] = ['unsubscribed', 'Subscribe'];
}
if (oldStatus === 'unsubscribed') {
[newStatus, newAction] = ['subscribed', 'Unsubscribe'];
} else {
[newStatus, newAction] = ['unsubscribed', 'Subscribe'];
}
 
$btn.removeClass('disabled');
$btn.removeClass('disabled');
 
this.$buttons.attr('data-status', newStatus);
this.$buttons.find('> span').text(newAction);
this.$buttons.attr('data-status', newStatus);
this.$buttons.find('> span').text(newAction);
 
this.$buttons.map((i, button) => {
const $button = $(button);
const originalTitle = $button.attr('data-original-title');
this.$buttons.map((i, button) => {
const $button = $(button);
const originalTitle = $button.attr('data-original-title');
 
if (originalTitle) {
ProjectLabelSubscription.setNewTitle($button, originalTitle, newStatus, newAction);
}
if (originalTitle) {
ProjectLabelSubscription.setNewTitle($button, originalTitle, newStatus, newAction);
}
 
return button;
});
}).catch(() => flash(__('There was an error subscribing to this label.')));
return button;
});
})
.catch(() => flash(__('There was an error subscribing to this label.')));
}
 
static setNewTitle($button, originalTitle, newStatus) {
Loading
Loading
Loading
Loading
@@ -16,28 +16,28 @@ export default function projectSelect() {
this.withMergeRequestsEnabled = $(select).data('withMergeRequestsEnabled');
this.allowClear = $(select).data('allowClear') || false;
 
placeholder = "Search for project";
placeholder = 'Search for project';
if (this.includeGroups) {
placeholder += " or group";
placeholder += ' or group';
}
 
$(select).select2({
placeholder: placeholder,
minimumInputLength: 0,
query: (function (_this) {
return function (query) {
query: (function(_this) {
return function(query) {
var finalCallback, projectsCallback;
finalCallback = function (projects) {
finalCallback = function(projects) {
var data;
data = {
results: projects
results: projects,
};
return query.callback(data);
};
if (_this.includeGroups) {
projectsCallback = function (projects) {
projectsCallback = function(projects) {
var groupsCallback;
groupsCallback = function (groups) {
groupsCallback = function(groups) {
var data;
data = groups.concat(projects);
return finalCallback(data);
Loading
Loading
@@ -48,17 +48,26 @@ export default function projectSelect() {
projectsCallback = finalCallback;
}
if (_this.groupId) {
return Api.groupProjects(_this.groupId, query.term, {
with_issues_enabled: _this.withIssuesEnabled,
with_merge_requests_enabled: _this.withMergeRequestsEnabled,
}, projectsCallback);
return Api.groupProjects(
_this.groupId,
query.term,
{
with_issues_enabled: _this.withIssuesEnabled,
with_merge_requests_enabled: _this.withMergeRequestsEnabled,
},
projectsCallback,
);
} else {
return Api.projects(query.term, {
order_by: _this.orderBy,
with_issues_enabled: _this.withIssuesEnabled,
with_merge_requests_enabled: _this.withMergeRequestsEnabled,
membership: !_this.allProjects,
}, projectsCallback);
return Api.projects(
query.term,
{
order_by: _this.orderBy,
with_issues_enabled: _this.withIssuesEnabled,
with_merge_requests_enabled: _this.withMergeRequestsEnabled,
membership: !_this.allProjects,
},
projectsCallback,
);
}
};
})(this),
Loading
Loading
@@ -69,7 +78,7 @@ export default function projectSelect() {
url: project.web_url,
});
},
text: function (project) {
text: function(project) {
return project.name_with_namespace || project.name;
},
 
Loading
Loading
@@ -79,7 +88,7 @@ export default function projectSelect() {
 
allowClear: this.allowClear,
 
dropdownCssClass: "ajax-project-dropdown"
dropdownCssClass: 'ajax-project-dropdown',
});
if (simpleFilter) return select;
return new ProjectSelectComboButton(select);
Loading
Loading
Loading
Loading
@@ -14,10 +14,11 @@ export default class ProjectSelectComboButton {
}
 
bindEvents() {
this.projectSelectInput.siblings('.new-project-item-select-button')
this.projectSelectInput
.siblings('.new-project-item-select-button')
.on('click', e => this.openDropdown(e));
 
this.newItemBtn.on('click', (e) => {
this.newItemBtn.on('click', e => {
if (!this.getProjectFromLocalStorage()) {
e.preventDefault();
this.openDropdown(e);
Loading
Loading
@@ -31,14 +32,21 @@ export default class ProjectSelectComboButton {
const localStorageIsSafe = AccessorUtilities.isLocalStorageAccessSafe();
 
if (localStorageIsSafe) {
this.localStorageKey = ['group', this.groupId, this.formattedText.localStorageItemType, 'recent-project'].join('-');
this.localStorageKey = [
'group',
this.groupId,
this.formattedText.localStorageItemType,
'recent-project',
].join('-');
this.setBtnTextFromLocalStorage();
}
}
 
// eslint-disable-next-line class-methods-use-this
openDropdown(event) {
$(event.currentTarget).siblings('.project-item-select').select2('open');
$(event.currentTarget)
.siblings('.project-item-select')
.select2('open');
}
 
selectProject() {
Loading
Loading
@@ -86,8 +94,14 @@ export default class ProjectSelectComboButton {
const defaultTextPrefix = this.resourceLabel;
 
// the trailing slice call depluralizes each of these strings (e.g. new-issues -> new-issue)
const localStorageItemType = `new-${this.resourceType.split('_').join('-').slice(0, -1)}`;
const presetTextSuffix = this.resourceType.split('_').join(' ').slice(0, -1);
const localStorageItemType = `new-${this.resourceType
.split('_')
.join('-')
.slice(0, -1)}`;
const presetTextSuffix = this.resourceType
.split('_')
.join(' ')
.slice(0, -1);
 
return {
localStorageItemType, // new-issue / new-merge-request
Loading
Loading
@@ -96,4 +110,3 @@ export default class ProjectSelectComboButton {
};
}
}
Loading
Loading
@@ -7,7 +7,7 @@ function setVisibilityOptions(namespaceSelector) {
const selectedNamespace = namespaceSelector.options[namespaceSelector.selectedIndex];
const { name, visibility, visibilityLevel, showPath, editPath } = selectedNamespace.dataset;
 
document.querySelectorAll('.visibility-level-setting .form-check').forEach((option) => {
document.querySelectorAll('.visibility-level-setting .form-check').forEach(option => {
const optionInput = option.querySelector('input[type=radio]');
const optionValue = optionInput ? optionInput.value : 0;
const optionTitle = option.querySelector('.option-title');
Loading
Loading
@@ -20,8 +20,7 @@ function setVisibilityOptions(namespaceSelector) {
optionInput.disabled = true;
const reason = option.querySelector('.option-disabled-reason');
if (reason) {
reason.innerHTML =
`This project cannot be ${optionName} because the visibility of
reason.innerHTML = `This project cannot be ${optionName} because the visibility of
<a href="${showPath}">${name}</a> is ${visibility}. To make this project
${optionName}, you must first <a href="${editPath}">change the visibility</a>
of the parent group.`;
Loading
Loading
Loading
Loading
@@ -65,10 +65,14 @@ export default class PrometheusMetrics {
let totalMissingEnvVarMetrics = 0;
let totalExporters = 0;
 
metrics.forEach((metric) => {
metrics.forEach(metric => {
if (metric.active_metrics > 0) {
totalExporters += 1;
this.$monitoredMetricsList.append(`<li>${_.escape(metric.group)}<span class="badge">${_.escape(metric.active_metrics)}</span></li>`);
this.$monitoredMetricsList.append(
`<li>${_.escape(metric.group)}<span class="badge">${_.escape(
metric.active_metrics,
)}</span></li>`,
);
totalMonitoredMetrics += metric.active_metrics;
if (metric.metrics_missing_requirements > 0) {
this.$missingEnvVarMetricsList.append(`<li>${_.escape(metric.group)}</li>`);
Loading
Loading
@@ -78,17 +82,26 @@ export default class PrometheusMetrics {
});
 
if (totalMonitoredMetrics === 0) {
const emptyCommonMetricsText = sprintf(s__('PrometheusService|<p class="text-tertiary">No <a href="%{docsUrl}">common metrics</a> were found</p>'), {
docsUrl: this.helpMetricsPath,
}, false);
const emptyCommonMetricsText = sprintf(
s__(
'PrometheusService|<p class="text-tertiary">No <a href="%{docsUrl}">common metrics</a> were found</p>',
),
{
docsUrl: this.helpMetricsPath,
},
false,
);
this.$monitoredMetricsEmpty.empty();
this.$monitoredMetricsEmpty.append(emptyCommonMetricsText);
this.showMonitoringMetricsPanelState(PANEL_STATE.EMPTY);
} else {
const metricsCountText = sprintf(s__('PrometheusService|%{exporters} with %{metrics} were found'), {
exporters: n__('%d exporter', '%d exporters', totalExporters),
metrics: n__('%d metric', '%d metrics', totalMonitoredMetrics),
});
const metricsCountText = sprintf(
s__('PrometheusService|%{exporters} with %{metrics} were found'),
{
exporters: n__('%d exporter', '%d exporters', totalExporters),
metrics: n__('%d metric', '%d metrics', totalMonitoredMetrics),
},
);
this.$monitoredMetricsCount.text(metricsCountText);
this.showMonitoringMetricsPanelState(PANEL_STATE.LIST);
 
Loading
Loading
@@ -102,7 +115,8 @@ export default class PrometheusMetrics {
loadActiveMetrics() {
this.showMonitoringMetricsPanelState(PANEL_STATE.LOADING);
backOff((next, stop) => {
axios.get(this.activeMetricsEndpoint)
axios
.get(this.activeMetricsEndpoint)
.then(({ data }) => {
if (data && data.success) {
stop(data);
Loading
Loading
@@ -117,7 +131,7 @@ export default class PrometheusMetrics {
})
.catch(stop);
})
.then((res) => {
.then(res => {
if (res && res.data && res.data.length) {
this.populateActiveMetrics(res.data);
} else {
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ const IGNORE_ERRORS = [
'canvas.contentDocument',
'MyApp_RemoveAllHighlights',
'http://tt.epicplay.com',
'Can\'t find variable: ZiteReader',
"Can't find variable: ZiteReader",
'jigsaw is not defined',
'ComboSearch is not defined',
'http://loading.retry.widdit.com/',
Loading
Loading
Loading
Loading
@@ -2,7 +2,8 @@ import $ from 'jquery';
 
class RefSelectDropdown {
constructor($dropdownButton, availableRefs) {
const availableRefsValue = availableRefs || JSON.parse(document.getElementById('availableRefs').innerHTML);
const availableRefsValue =
availableRefs || JSON.parse(document.getElementById('availableRefs').innerHTML);
$dropdownButton.glDropdown({
data: availableRefsValue,
filterable: true,
Loading
Loading
@@ -29,7 +30,7 @@ class RefSelectDropdown {
const $fieldInput = $(`input[name="${$dropdownButton.data('fieldName')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer);
 
$filterInput.on('keyup', (e) => {
$filterInput.on('keyup', e => {
const keyCode = e.keyCode || e.which;
if (keyCode !== 13) return;
 
Loading
Loading
Loading
Loading
@@ -3,10 +3,14 @@ import { __ } from './locale';
 
function expandSection($section) {
$section.find('.js-settings-toggle:not(.js-settings-toggle-trigger-only)').text(__('Collapse'));
$section.find('.settings-content').off('scroll.expandSection').scrollTop(0);
$section
.find('.settings-content')
.off('scroll.expandSection')
.scrollTop(0);
$section.addClass('expanded');
if (!$section.hasClass('no-animate')) {
$section.addClass('animating')
$section
.addClass('animating')
.one('animationend.animateSection', () => $section.removeClass('animating'));
}
}
Loading
Loading
@@ -16,7 +20,8 @@ function closeSection($section) {
$section.find('.settings-content').on('scroll.expandSection', () => expandSection($section));
$section.removeClass('expanded');
if (!$section.hasClass('no-animate')) {
$section.addClass('animating')
$section
.addClass('animating')
.one('animationend.animateSection', () => $section.removeClass('animating'));
}
}
Loading
Loading
Loading
Loading
@@ -10,8 +10,10 @@ import syntaxHighlight from './syntax_highlight';
 
const WRAPPER = '<div class="diff-content"></div>';
const LOADING_HTML = '<i class="fa fa-spinner fa-spin"></i>';
const ERROR_HTML = '<div class="nothing-here-block"><i class="fa fa-warning"></i> Could not load diff</div>';
const COLLAPSED_HTML = '<div class="nothing-here-block diff-collapsed">This diff is collapsed. <button class="click-to-expand btn btn-link">Click to expand it.</button></div>';
const ERROR_HTML =
'<div class="nothing-here-block"><i class="fa fa-warning"></i> Could not load diff</div>';
const COLLAPSED_HTML =
'<div class="nothing-here-block diff-collapsed">This diff is collapsed. <button class="click-to-expand btn btn-link">Click to expand it.</button></div>';
 
export default class SingleFileDiff {
constructor(file) {
Loading
Loading
@@ -23,23 +25,36 @@ export default class SingleFileDiff {
this.isOpen = !this.diffForPath;
if (this.diffForPath) {
this.collapsedContent = this.content;
this.loadingContent = $(WRAPPER).addClass('loading').html(LOADING_HTML).hide();
this.loadingContent = $(WRAPPER)
.addClass('loading')
.html(LOADING_HTML)
.hide();
this.content = null;
this.collapsedContent.after(this.loadingContent);
this.$toggleIcon.addClass('fa-caret-right');
} else {
this.collapsedContent = $(WRAPPER).html(COLLAPSED_HTML).hide();
this.collapsedContent = $(WRAPPER)
.html(COLLAPSED_HTML)
.hide();
this.content.after(this.collapsedContent);
this.$toggleIcon.addClass('fa-caret-down');
}
 
$('.js-file-title, .click-to-expand', this.file).on('click', (function (e) {
this.toggleDiff($(e.target));
}).bind(this));
$('.js-file-title, .click-to-expand', this.file).on(
'click',
function(e) {
this.toggleDiff($(e.target));
}.bind(this),
);
}
 
toggleDiff($target, cb) {
if (!$target.hasClass('js-file-title') && !$target.hasClass('click-to-expand') && !$target.hasClass('diff-toggle-caret')) return;
if (
!$target.hasClass('js-file-title') &&
!$target.hasClass('click-to-expand') &&
!$target.hasClass('diff-toggle-caret')
)
return;
this.isOpen = !this.isOpen;
if (!this.isOpen && !this.hasError) {
this.content.hide();
Loading
Loading
@@ -65,7 +80,8 @@ export default class SingleFileDiff {
this.collapsedContent.hide();
this.loadingContent.show();
 
axios.get(this.diffForPath)
axios
.get(this.diffForPath)
.then(({ data }) => {
this.loadingContent.hide();
if (data.html) {
Loading
Loading
Loading
Loading
@@ -93,7 +93,9 @@ export default class SmartInterval {
destroy() {
this.cancel();
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
$(document).off('visibilitychange').off('beforeunload');
$(document)
.off('visibilitychange')
.off('beforeunload');
}
 
/* private */
Loading
Loading
@@ -111,11 +113,12 @@ export default class SmartInterval {
 
triggerCallback() {
this.isLoading = true;
this.cfg.callback()
this.cfg
.callback()
.then(() => {
this.isLoading = false;
})
.catch((err) => {
.catch(err => {
this.isLoading = false;
throw err;
});
Loading
Loading
@@ -134,9 +137,9 @@ export default class SmartInterval {
 
handleVisibilityChange(e) {
this.state.pageVisibility = e.target.visibilityState;
const intervalAction = this.isPageVisible() ?
this.onVisibilityVisible :
this.onVisibilityHidden;
const intervalAction = this.isPageVisible()
? this.onVisibilityVisible
: this.onVisibilityHidden;
 
intervalAction.apply(this);
}
Loading
Loading
@@ -162,7 +165,9 @@ export default class SmartInterval {
this.setCurrentInterval(nextInterval);
}
 
isPageVisible() { return this.state.pageVisibility === 'visible'; }
isPageVisible() {
return this.state.pageVisibility === 'visible';
}
 
stopTimer() {
const { state } = this;
Loading
Loading
@@ -170,4 +175,3 @@ export default class SmartInterval {
state.intervalId = window.clearInterval(state.intervalId);
}
}
Loading
Loading
@@ -11,10 +11,14 @@ export default class Star {
const $starSpan = $this.find('span');
const $startIcon = $this.find('svg');
 
axios.post($this.data('endpoint'))
axios
.post($this.data('endpoint'))
.then(({ data }) => {
const isStarred = $starSpan.hasClass('starred');
$this.parent().find('.star-count').text(data.star_count);
$this
.parent()
.find('.star-count')
.text(data.star_count);
 
if (isStarred) {
$starSpan.removeClass('starred').text(s__('StarProject|Star'));
Loading
Loading
Loading
Loading
@@ -26,7 +26,11 @@ export default class TaskList {
// Prevent duplicate event bindings
this.disable();
$(`${this.selector} .js-task-list-container`).taskList('enable');
$(document).on('tasklist:changed', `${this.selector} .js-task-list-container`, this.update.bind(this));
$(document).on(
'tasklist:changed',
`${this.selector} .js-task-list-container`,
this.update.bind(this),
);
}
 
disable() {
Loading
Loading
@@ -41,7 +45,8 @@ export default class TaskList {
[this.fieldName]: $target.val(),
};
 
return axios.patch($target.data('updateUrl') || $('form.js-issuable-update').attr('action'), patchData)
return axios
.patch($target.data('updateUrl') || $('form.js-issuable-update').attr('action'), patchData)
.then(({ data }) => this.onSuccess(data))
.catch(err => this.onError(err));
}
Loading
Loading
Loading
Loading
@@ -31,12 +31,18 @@ export default class IssuableTemplateSelector extends TemplateSelector {
 
requestFile(query) {
this.startLoadingSpinner();
Api.issueTemplate(this.namespacePath, this.projectPath, query.name, this.issuableType, (err, currentTemplate) => {
this.currentTemplate = currentTemplate;
this.stopLoadingSpinner();
if (err) return; // Error handled by global AJAX error handler
this.setInputValueToTemplateContent();
});
Api.issueTemplate(
this.namespacePath,
this.projectPath,
query.name,
this.issuableType,
(err, currentTemplate) => {
this.currentTemplate = currentTemplate;
this.stopLoadingSpinner();
if (err) return; // Error handled by global AJAX error handler
this.setInputValueToTemplateContent();
},
);
return;
}
 
Loading
Loading
Loading
Loading
@@ -4,10 +4,14 @@ import * as fit from 'xterm/lib/addons/fit/fit';
 
export default class GLTerminal {
constructor(options = {}) {
this.options = Object.assign({}, {
cursorBlink: true,
screenKeys: true,
}, options);
this.options = Object.assign(
{},
{
cursorBlink: true,
screenKeys: true,
},
options,
);
 
this.container = document.querySelector(options.selector);
 
Loading
Loading
Loading
Loading
@@ -4,15 +4,43 @@ function simulateEvent(el, type, options = {}) {
 
if (/^mouse/.test(type)) {
event = el.ownerDocument.createEvent('MouseEvents');
event.initMouseEvent(type, true, true, el.ownerDocument.defaultView,
options.button, options.screenX, options.screenY, options.clientX, options.clientY,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, el);
event.initMouseEvent(
type,
true,
true,
el.ownerDocument.defaultView,
options.button,
options.screenX,
options.screenY,
options.clientX,
options.clientY,
options.ctrlKey,
options.altKey,
options.shiftKey,
options.metaKey,
options.button,
el,
);
} else {
event = el.ownerDocument.createEvent('CustomEvent');
 
event.initCustomEvent(type, true, true, el.ownerDocument.defaultView,
options.button, options.screenX, options.screenY, options.clientX, options.clientY,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, el);
event.initCustomEvent(
type,
true,
true,
el.ownerDocument.defaultView,
options.button,
options.screenX,
options.screenY,
options.clientX,
options.clientY,
options.ctrlKey,
options.altKey,
options.shiftKey,
options.metaKey,
options.button,
el,
);
 
event.dataTransfer = {
data: {},
Loading
Loading
@@ -37,14 +65,16 @@ function simulateEvent(el, type, options = {}) {
}
 
function isLast(target) {
const el = typeof target.el === 'string' ? document.getElementById(target.el.substr(1)) : target.el;
const el =
typeof target.el === 'string' ? document.getElementById(target.el.substr(1)) : target.el;
const { children } = el;
 
return children.length - 1 === target.index;
}
 
function getTarget(target) {
const el = typeof target.el === 'string' ? document.getElementById(target.el.substr(1)) : target.el;
const el =
typeof target.el === 'string' ? document.getElementById(target.el.substr(1)) : target.el;
const { children } = el;
 
return (
Loading
Loading
@@ -58,13 +88,13 @@ function getTarget(target) {
function getRect(el) {
const rect = el.getBoundingClientRect();
const width = rect.right - rect.left;
const height = (rect.bottom - rect.top) + 10;
const height = rect.bottom - rect.top + 10;
 
return {
x: rect.left,
y: rect.top,
cx: rect.left + (width / 2),
cy: rect.top + (height / 2),
cx: rect.left + width / 2,
cy: rect.top + height / 2,
w: width,
h: height,
hw: width / 2,
Loading
Loading
@@ -112,8 +142,8 @@ export default function simulateDrag(options) {
 
const dragInterval = setInterval(() => {
const progress = (new Date().getTime() - startTime) / duration;
const x = (fromRect.cx + ((toRect.cx - fromRect.cx) * progress));
const y = (fromRect.cy + ((toRect.cy - fromRect.cy) * progress));
const x = fromRect.cx + (toRect.cx - fromRect.cx) * progress;
const y = fromRect.cy + (toRect.cy - fromRect.cy) * progress;
const overEl = fromEl.ownerDocument.elementFromPoint(x, y);
 
simulateEvent(overEl, 'mousemove', {
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