|
|
|
@ -2,21 +2,20 @@
|
|
|
|
|
/* exported timeAddManual, toggleStopwatch, cancelStopwatch */
|
|
|
|
|
/* exported toggleDeadlineForm, setDeadline, updateDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */
|
|
|
|
|
|
|
|
|
|
import './publicPath.js';
|
|
|
|
|
import './publicpath.js';
|
|
|
|
|
import './polyfills.js';
|
|
|
|
|
|
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
import 'jquery.are-you-sure';
|
|
|
|
|
import './vendor/semanticDropdown.js';
|
|
|
|
|
import './vendor/semanticdropdown.js';
|
|
|
|
|
import {svg} from './utils.js';
|
|
|
|
|
|
|
|
|
|
import initContextPopups from './features/contextPopup.js';
|
|
|
|
|
import initContextPopups from './features/contextpopup.js';
|
|
|
|
|
import initHighlight from './features/highlight.js';
|
|
|
|
|
import initGitGraph from './features/gitGraph.js';
|
|
|
|
|
import initGitGraph from './features/gitgraph.js';
|
|
|
|
|
import initClipboard from './features/clipboard.js';
|
|
|
|
|
import initUserHeatmap from './features/userHeatmap.js';
|
|
|
|
|
import initUserHeatmap from './features/userheatmap.js';
|
|
|
|
|
import createDropzone from './features/dropzone.js';
|
|
|
|
|
|
|
|
|
|
import ActivityTopAuthors from './components/ActivityTopAuthors.vue';
|
|
|
|
|
|
|
|
|
|
const {AppSubUrl, StaticUrlPrefix, csrf} = window.config;
|
|
|
|
@ -99,7 +98,6 @@ function initEditDiffTab($form) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initEditForm() {
|
|
|
|
|
if ($('.edit.form').length === 0) {
|
|
|
|
|
return;
|
|
|
|
@ -192,9 +190,7 @@ function initReactionSelector(parent) {
|
|
|
|
|
|
|
|
|
|
if ($(this).hasClass('disabled')) return;
|
|
|
|
|
|
|
|
|
|
const actionURL = $(this).hasClass('item')
|
|
|
|
|
? $(this).closest('.select-reaction').data('action-url')
|
|
|
|
|
: $(this).data('action-url');
|
|
|
|
|
const actionURL = $(this).hasClass('item') ? $(this).closest('.select-reaction').data('action-url') : $(this).data('action-url');
|
|
|
|
|
const url = `${actionURL}/${$(this).hasClass('blue') ? 'unreact' : 'react'}`;
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
@ -235,9 +231,7 @@ function insertAtCursor(field, value) {
|
|
|
|
|
if (field.selectionStart || field.selectionStart === 0) {
|
|
|
|
|
const startPos = field.selectionStart;
|
|
|
|
|
const endPos = field.selectionEnd;
|
|
|
|
|
field.value = field.value.substring(0, startPos)
|
|
|
|
|
+ value
|
|
|
|
|
+ field.value.substring(endPos, field.value.length);
|
|
|
|
|
field.value = field.value.substring(0, startPos) + value + field.value.substring(endPos, field.value.length);
|
|
|
|
|
field.selectionStart = startPos + value.length;
|
|
|
|
|
field.selectionEnd = startPos + value.length;
|
|
|
|
|
} else {
|
|
|
|
@ -268,7 +262,7 @@ function retrieveImageFromClipboardAsBlob(pasteEvent, callback) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
|
if (items[i].type.indexOf('image') === -1) continue;
|
|
|
|
|
if (!items[i].type.includes('image')) continue;
|
|
|
|
|
const blob = items[i].getAsFile();
|
|
|
|
|
|
|
|
|
|
if (typeof (callback) === 'function') {
|
|
|
|
@ -282,11 +276,11 @@ function retrieveImageFromClipboardAsBlob(pasteEvent, callback) {
|
|
|
|
|
function uploadFile(file, callback) {
|
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
|
|
|
|
|
|
|
xhr.onload = function () {
|
|
|
|
|
xhr.addEventListener('load', () => {
|
|
|
|
|
if (xhr.status === 200) {
|
|
|
|
|
callback(xhr.responseText);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
xhr.open('post', `${AppSubUrl}/attachments`, true);
|
|
|
|
|
xhr.setRequestHeader('X-Csrf-Token', csrf);
|
|
|
|
@ -493,8 +487,8 @@ function initCommentForm() {
|
|
|
|
|
htmlEncode($(this).text())}</a>`);
|
|
|
|
|
break;
|
|
|
|
|
case '#assignee_id':
|
|
|
|
|
$list.find('.selected').html(`<a class="item" href=${$(this).data('href')}>`
|
|
|
|
|
+ `<img class="ui avatar image" src=${$(this).data('avatar')}>${
|
|
|
|
|
$list.find('.selected').html(`<a class="item" href=${$(this).data('href')}>` +
|
|
|
|
|
`<img class="ui avatar image" src=${$(this).data('avatar')}>${
|
|
|
|
|
htmlEncode($(this).text())}</a>`);
|
|
|
|
|
}
|
|
|
|
|
$(`.ui${select_id}.list .no-select`).addClass('hide');
|
|
|
|
@ -797,11 +791,9 @@ function initRepository() {
|
|
|
|
|
$.post(update_url, {
|
|
|
|
|
_csrf: csrf,
|
|
|
|
|
target_branch: targetBranch
|
|
|
|
|
})
|
|
|
|
|
.success((data) => {
|
|
|
|
|
}).success((data) => {
|
|
|
|
|
$branchTarget.text(data.base_branch);
|
|
|
|
|
})
|
|
|
|
|
.always(() => {
|
|
|
|
|
}).always(() => {
|
|
|
|
|
reload();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
@ -814,8 +806,7 @@ function initRepository() {
|
|
|
|
|
$.post($(this).data('update-url'), {
|
|
|
|
|
_csrf: csrf,
|
|
|
|
|
title: $editInput.val()
|
|
|
|
|
},
|
|
|
|
|
(data) => {
|
|
|
|
|
}, (data) => {
|
|
|
|
|
$editInput.val(data.title);
|
|
|
|
|
$issueTitle.text(data.title);
|
|
|
|
|
pullrequest_targetbranch_change(pullrequest_target_update_url);
|
|
|
|
@ -1142,8 +1133,8 @@ function initMigration() {
|
|
|
|
|
const toggleMigrations = function () {
|
|
|
|
|
const authUserName = $('#auth_username').val();
|
|
|
|
|
const cloneAddr = $('#clone_addr').val();
|
|
|
|
|
if (!$('#mirror').is(':checked') && (authUserName && authUserName.length > 0)
|
|
|
|
|
&& (cloneAddr !== undefined && (cloneAddr.startsWith('https://github.com') || cloneAddr.startsWith('http://github.com')))) {
|
|
|
|
|
if (!$('#mirror').is(':checked') && (authUserName && authUserName.length > 0) &&
|
|
|
|
|
(cloneAddr !== undefined && (cloneAddr.startsWith('https://github.com') || cloneAddr.startsWith('http://github.com')))) {
|
|
|
|
|
$('#migrate_items').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#migrate_items').hide();
|
|
|
|
@ -1203,8 +1194,7 @@ function initPullRequestReview() {
|
|
|
|
|
.on('mouseenter', function () {
|
|
|
|
|
const parent = $(this).closest('td');
|
|
|
|
|
$(this).closest('tr').addClass(
|
|
|
|
|
parent.hasClass('lines-num-old') || parent.hasClass('lines-code-old')
|
|
|
|
|
? 'focus-lines-old' : 'focus-lines-new'
|
|
|
|
|
parent.hasClass('lines-num-old') || parent.hasClass('lines-code-old') ? 'focus-lines-old' : 'focus-lines-new'
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.on('mouseleave', function () {
|
|
|
|
@ -1225,8 +1215,8 @@ function initPullRequestReview() {
|
|
|
|
|
let ntr = tr.next();
|
|
|
|
|
if (!ntr.hasClass('add-comment')) {
|
|
|
|
|
ntr = $(`<tr class="add-comment">${
|
|
|
|
|
isSplit ? '<td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-left"></td><td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-right"></td>'
|
|
|
|
|
: '<td class="lines-num"></td><td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-left add-comment-right"></td>'
|
|
|
|
|
isSplit ? '<td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-left"></td><td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-right"></td>' :
|
|
|
|
|
'<td class="lines-num"></td><td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-left add-comment-right"></td>'
|
|
|
|
|
}</tr>`);
|
|
|
|
|
tr.after(ntr);
|
|
|
|
|
}
|
|
|
|
@ -1297,7 +1287,7 @@ function initWikiForm() {
|
|
|
|
|
// FIXME: still send render request when return back to edit mode
|
|
|
|
|
const render = function () {
|
|
|
|
|
sideBySideChanges = 0;
|
|
|
|
|
if (sideBySideTimeout != null) {
|
|
|
|
|
if (sideBySideTimeout !== null) {
|
|
|
|
|
clearTimeout(sideBySideTimeout);
|
|
|
|
|
sideBySideTimeout = null;
|
|
|
|
|
}
|
|
|
|
@ -1306,8 +1296,7 @@ function initWikiForm() {
|
|
|
|
|
mode: 'gfm',
|
|
|
|
|
context: $editArea.data('context'),
|
|
|
|
|
text: plainText
|
|
|
|
|
},
|
|
|
|
|
(data) => {
|
|
|
|
|
}, (data) => {
|
|
|
|
|
preview.innerHTML = `<div class="markdown ui segment">${data}</div>`;
|
|
|
|
|
emojify.run($('.editor-preview')[0]);
|
|
|
|
|
$(preview).find('pre code').each((_, e) => {
|
|
|
|
@ -1324,7 +1313,7 @@ function initWikiForm() {
|
|
|
|
|
render();
|
|
|
|
|
}
|
|
|
|
|
// or delay preview by timeout
|
|
|
|
|
if (sideBySideTimeout != null) {
|
|
|
|
|
if (sideBySideTimeout !== null) {
|
|
|
|
|
clearTimeout(sideBySideTimeout);
|
|
|
|
|
sideBySideTimeout = null;
|
|
|
|
|
}
|
|
|
|
@ -1479,8 +1468,7 @@ function setSimpleMDE($editArea) {
|
|
|
|
|
mode: 'gfm',
|
|
|
|
|
context: $editArea.data('context'),
|
|
|
|
|
text: plainText
|
|
|
|
|
},
|
|
|
|
|
(data) => {
|
|
|
|
|
}, (data) => {
|
|
|
|
|
preview.innerHTML = `<div class="markdown ui segment">${data}</div>`;
|
|
|
|
|
emojify.run($('.editor-preview')[0]);
|
|
|
|
|
});
|
|
|
|
@ -1658,7 +1646,7 @@ function initEditor() {
|
|
|
|
|
apiCall = extension;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (previewLink.length && apiCall && previewFileModes && previewFileModes.length && previewFileModes.indexOf(apiCall) >= 0) {
|
|
|
|
|
if (previewLink.length && apiCall && previewFileModes && previewFileModes.length && previewFileModes.includes(apiCall)) {
|
|
|
|
|
dataUrl = previewLink.data('url');
|
|
|
|
|
previewLink.data('url', dataUrl.replace(/(.*)\/.*/i, `$1/${mode}`));
|
|
|
|
|
previewLink.show();
|
|
|
|
@ -1667,7 +1655,7 @@ function initEditor() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If this file is a Markdown extensions, we will load that editor and return
|
|
|
|
|
if (markdownFileExts.indexOf(extWithDot) >= 0) {
|
|
|
|
|
if (markdownFileExts.includes(extWithDot)) {
|
|
|
|
|
if (setSimpleMDE($editArea)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -1683,7 +1671,7 @@ function initEditor() {
|
|
|
|
|
CodeMirror.autoLoadMode(codeMirrorEditor, mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lineWrapExtensions.indexOf(extWithDot) >= 0) {
|
|
|
|
|
if (lineWrapExtensions.includes(extWithDot)) {
|
|
|
|
|
codeMirrorEditor.setOption('lineWrapping', true);
|
|
|
|
|
} else {
|
|
|
|
|
codeMirrorEditor.setOption('lineWrapping', false);
|
|
|
|
@ -1708,7 +1696,7 @@ function initEditor() {
|
|
|
|
|
// - https://codemirror.net/doc/manual.html#keymaps
|
|
|
|
|
codeMirrorEditor.setOption('extraKeys', {
|
|
|
|
|
Tab(cm) {
|
|
|
|
|
const spaces = Array(parseInt(cm.getOption('indentUnit')) + 1).join(' ');
|
|
|
|
|
const spaces = new Array(parseInt(cm.getOption('indentUnit')) + 1).join(' ');
|
|
|
|
|
cm.replaceSelection(spaces);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -2165,11 +2153,11 @@ function initCodeView() {
|
|
|
|
|
const $row = $blob.parent().parent();
|
|
|
|
|
$.get(`${$blob.data('url')}?${$blob.data('query')}&anchor=${$blob.data('anchor')}`, (blob) => {
|
|
|
|
|
$row.replaceWith(blob);
|
|
|
|
|
$(`[data-anchor="${$blob.data('anchor')}"]`).on('click', (e) => { insertBlobExcerpt(e); });
|
|
|
|
|
$(`[data-anchor="${$blob.data('anchor')}"]`).on('click', (e) => { insertBlobExcerpt(e) });
|
|
|
|
|
$('.diff-detail-box.ui.sticky').sticky();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
$('.ui.blob-excerpt').on('click', (e) => { insertBlobExcerpt(e); });
|
|
|
|
|
$('.ui.blob-excerpt').on('click', (e) => { insertBlobExcerpt(e) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initU2FAuth() {
|
|
|
|
@ -2238,7 +2226,6 @@ function checkError(resp) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function u2fError(errorType) {
|
|
|
|
|
const u2fErrors = {
|
|
|
|
|
browser: $('#unsupported-browser'),
|
|
|
|
@ -2529,7 +2516,7 @@ $(document).ready(async () => {
|
|
|
|
|
// NOTICE: This reset of checkbox state targets Firefox caching behaviour, as the checkboxes stay checked after reload
|
|
|
|
|
if (action === 'close' || action === 'open') {
|
|
|
|
|
// uncheck all checkboxes
|
|
|
|
|
$('.issue-checkbox input[type="checkbox"]').each((_, e) => { e.checked = false; });
|
|
|
|
|
$('.issue-checkbox input[type="checkbox"]').each((_, e) => { e.checked = false });
|
|
|
|
|
}
|
|
|
|
|
reload();
|
|
|
|
|
});
|
|
|
|
@ -3031,8 +3018,8 @@ function initFilterBranchTagDropdown(selector) {
|
|
|
|
|
const vm = this;
|
|
|
|
|
|
|
|
|
|
const items = vm.items.filter((item) => {
|
|
|
|
|
return ((vm.mode === 'branches' && item.branch) || (vm.mode === 'tags' && item.tag))
|
|
|
|
|
&& (!vm.searchTerm || item.name.toLowerCase().indexOf(vm.searchTerm.toLowerCase()) >= 0);
|
|
|
|
|
return ((vm.mode === 'branches' && item.branch) || (vm.mode === 'tags' && item.tag)) &&
|
|
|
|
|
(!vm.searchTerm || item.name.toLowerCase().includes(vm.searchTerm.toLowerCase()));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
vm.active = (items.length === 0 && vm.showCreateNewBranch ? 0 : -1);
|
|
|
|
@ -3276,13 +3263,13 @@ function initTopicbar() {
|
|
|
|
|
const query = stripTags(this.urlData.query.trim());
|
|
|
|
|
let found_query = false;
|
|
|
|
|
const current_topics = [];
|
|
|
|
|
topicDropdown.find('div.label.visible.topic,a.label.visible').each((_, e) => { current_topics.push(e.dataset.value); });
|
|
|
|
|
topicDropdown.find('div.label.visible.topic,a.label.visible').each((_, e) => { current_topics.push(e.dataset.value) });
|
|
|
|
|
|
|
|
|
|
if (res.topics) {
|
|
|
|
|
let found = false;
|
|
|
|
|
for (let i = 0; i < res.topics.length; i++) {
|
|
|
|
|
// skip currently added tags
|
|
|
|
|
if (current_topics.indexOf(res.topics[i].topic_name) !== -1) {
|
|
|
|
|
if (current_topics.includes(res.topics[i].topic_name)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3308,7 +3295,6 @@ function initTopicbar() {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return formattedResponse;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|