2022-01-28 16:00:11 -05:00
|
|
|
import $ from 'jquery';
|
2022-01-05 07:17:25 -05:00
|
|
|
import {createCommentEasyMDE, getAttachedEasyMDE} from './comp/EasyMDE.js';
|
2021-10-16 13:28:04 -04:00
|
|
|
import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
|
2022-06-28 13:52:58 -04:00
|
|
|
import {initEasyMDEImagePaste} from './comp/ImagePaste.js';
|
2021-10-16 13:28:04 -04:00
|
|
|
import {
|
2022-12-23 11:03:11 -05:00
|
|
|
initRepoIssueBranchSelect, initRepoIssueCodeCommentCancel, initRepoIssueCommentDelete,
|
|
|
|
initRepoIssueComments, initRepoIssueDependencyDelete, initRepoIssueReferenceIssue,
|
|
|
|
initRepoIssueStatusButton, initRepoIssueTitleEdit, initRepoIssueWipToggle,
|
2023-03-02 14:53:22 -05:00
|
|
|
initRepoPullRequestUpdate, updateIssuesMeta, handleReply
|
2021-10-16 13:28:04 -04:00
|
|
|
} from './repo-issue.js';
|
2022-01-06 20:18:52 -05:00
|
|
|
import {initUnicodeEscapeButton} from './repo-unicode-escape.js';
|
2021-10-16 13:28:04 -04:00
|
|
|
import {svg} from '../svg.js';
|
|
|
|
import {htmlEscape} from 'escape-goat';
|
|
|
|
import {initRepoBranchTagDropdown} from '../components/RepoBranchTagDropdown.js';
|
|
|
|
import {
|
2022-12-23 11:03:11 -05:00
|
|
|
initRepoCloneLink, initRepoCommonBranchOrTagDropdown, initRepoCommonFilterSearchDropdown,
|
2021-10-16 13:28:04 -04:00
|
|
|
initRepoCommonLanguageStats,
|
|
|
|
} from './repo-common.js';
|
2022-11-11 12:02:50 -05:00
|
|
|
import {initCitationFileCopyContent} from './citation.js';
|
2021-10-16 13:28:04 -04:00
|
|
|
import {initCompLabelEdit} from './comp/LabelEdit.js';
|
|
|
|
import {initRepoDiffConversationNav} from './repo-diff.js';
|
2022-12-23 11:03:11 -05:00
|
|
|
import {attachTribute} from './tribute.js';
|
|
|
|
import {createDropzone} from './dropzone.js';
|
2021-10-16 13:28:04 -04:00
|
|
|
import {initCommentContent, initMarkupContent} from '../markup/content.js';
|
|
|
|
import {initCompReactionSelector} from './comp/ReactionSelector.js';
|
|
|
|
import {initRepoSettingBranches} from './repo-settings.js';
|
2022-12-23 11:03:11 -05:00
|
|
|
import {initRepoPullRequestMergeForm} from './repo-issue-pr-form.js';
|
2023-02-18 23:06:14 -05:00
|
|
|
import {hideElem, showElem} from '../utils/dom.js';
|
2021-10-16 13:28:04 -04:00
|
|
|
|
2021-10-21 03:37:43 -04:00
|
|
|
const {csrfToken} = window.config;
|
2021-10-16 13:28:04 -04:00
|
|
|
|
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-23 20:26:27 -05:00
|
|
|
// if there are draft comments (more than 20 chars), confirm before reloading, to avoid losing comments
|
|
|
|
function reloadConfirmDraftComment() {
|
|
|
|
const commentTextareas = [
|
|
|
|
document.querySelector('.edit-content-zone:not(.gt-hidden) textarea'),
|
|
|
|
document.querySelector('.edit_area'),
|
|
|
|
];
|
|
|
|
for (const textarea of commentTextareas) {
|
|
|
|
// Most users won't feel too sad if they lose a comment with 10 or 20 chars, they can re-type these in seconds.
|
|
|
|
// But if they have typed more (like 50) chars and the comment is lost, they will be very unhappy.
|
|
|
|
if (textarea && textarea.value.trim().length > 20) {
|
|
|
|
textarea.parentElement.scrollIntoView();
|
|
|
|
if (!window.confirm('Page will be reloaded, but there are draft comments. Continuing to reload will discard the comments. Continue?')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
|
2021-10-16 13:28:04 -04:00
|
|
|
export function initRepoCommentForm() {
|
2022-06-28 13:52:58 -04:00
|
|
|
const $commentForm = $('.comment.form');
|
|
|
|
if ($commentForm.length === 0) {
|
2021-10-16 13:28:04 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function initBranchSelector() {
|
|
|
|
const $selectBranch = $('.ui.select-branch');
|
|
|
|
const $branchMenu = $selectBranch.find('.reference-list-menu');
|
|
|
|
const $isNewIssue = $branchMenu.hasClass('new-issue');
|
|
|
|
$branchMenu.find('.item:not(.no-select)').click(function () {
|
|
|
|
const selectedValue = $(this).data('id');
|
|
|
|
const editMode = $('#editing_mode').val();
|
2022-01-16 06:19:26 -05:00
|
|
|
$($(this).data('id-selector')).val(selectedValue);
|
2021-10-16 13:28:04 -04:00
|
|
|
if ($isNewIssue) {
|
|
|
|
$selectBranch.find('.ui .branch-name').text($(this).data('name'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (editMode === 'true') {
|
|
|
|
const form = $('#update_issueref_form');
|
2021-10-21 03:37:43 -04:00
|
|
|
$.post(form.attr('action'), {_csrf: csrfToken, ref: selectedValue}, () => window.location.reload());
|
2021-10-16 13:28:04 -04:00
|
|
|
} else if (editMode === '') {
|
|
|
|
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$selectBranch.find('.reference.column').on('click', function () {
|
2023-02-18 23:06:14 -05:00
|
|
|
hideElem($selectBranch.find('.scrolling.reference-list-menu'));
|
2021-10-16 13:28:04 -04:00
|
|
|
$selectBranch.find('.reference .text').removeClass('black');
|
2023-02-18 23:06:14 -05:00
|
|
|
showElem($($(this).data('target')));
|
2021-10-16 13:28:04 -04:00
|
|
|
$(this).find('.text').addClass('black');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-08 08:33:32 -05:00
|
|
|
(async () => {
|
2023-02-27 18:13:52 -05:00
|
|
|
const $statusButton = $('#status-button');
|
2022-09-02 03:58:49 -04:00
|
|
|
for (const textarea of $commentForm.find('textarea:not(.review-textarea, .no-easymde)')) {
|
|
|
|
// Don't initialize EasyMDE for the dormant #edit-content-form
|
|
|
|
if (textarea.closest('#edit-content-form')) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-02-27 18:13:52 -05:00
|
|
|
const easyMDE = await createCommentEasyMDE(textarea, {
|
|
|
|
'onChange': () => {
|
|
|
|
const value = easyMDE?.value().trim();
|
|
|
|
$statusButton.text($statusButton.attr(value.length === 0 ? 'data-status' : 'data-status-and-comment'));
|
|
|
|
},
|
|
|
|
});
|
2022-09-02 03:58:49 -04:00
|
|
|
initEasyMDEImagePaste(easyMDE, $commentForm.find('.dropzone'));
|
|
|
|
}
|
2022-01-08 08:33:32 -05:00
|
|
|
})();
|
|
|
|
|
2021-10-16 13:28:04 -04:00
|
|
|
initBranchSelector();
|
2022-06-28 13:52:58 -04:00
|
|
|
initCompMarkupContentPreviewTab($commentForm);
|
2021-10-16 13:28:04 -04:00
|
|
|
|
2021-11-18 11:45:00 -05:00
|
|
|
// List submits
|
2021-10-16 13:28:04 -04:00
|
|
|
function initListSubmits(selector, outerSelector) {
|
|
|
|
const $list = $(`.ui.${outerSelector}.list`);
|
|
|
|
const $noSelect = $list.find('.no-select');
|
|
|
|
const $listMenu = $(`.${selector} .menu`);
|
|
|
|
let hasUpdateAction = $listMenu.data('action') === 'update';
|
|
|
|
const items = {};
|
|
|
|
|
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-23 20:26:27 -05:00
|
|
|
$(`.${selector}`).dropdown({
|
|
|
|
'action': 'nothing', // do not hide the menu if user presses Enter
|
|
|
|
fullTextSearch: 'exact',
|
|
|
|
async onHide() {
|
|
|
|
hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var
|
|
|
|
if (hasUpdateAction) {
|
|
|
|
// TODO: Add batch functionality and make this 1 network request.
|
|
|
|
const itemEntries = Object.entries(items);
|
|
|
|
for (const [elementId, item] of itemEntries) {
|
2021-11-15 21:21:13 -05:00
|
|
|
await updateIssuesMeta(
|
|
|
|
item['update-url'],
|
|
|
|
item.action,
|
|
|
|
item['issue-id'],
|
|
|
|
elementId,
|
|
|
|
);
|
|
|
|
}
|
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-23 20:26:27 -05:00
|
|
|
if (itemEntries.length) {
|
|
|
|
reloadConfirmDraftComment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-10-16 13:28:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
$listMenu.find('.item:not(.no-select)').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if ($(this).hasClass('ban-change')) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
|
|
|
|
const clickedItem = $(this);
|
|
|
|
const scope = $(this).attr('data-scope');
|
|
|
|
|
|
|
|
$(this).parent().find('.item').each(function () {
|
|
|
|
if (scope) {
|
|
|
|
// Enable only clicked item for scoped labels
|
|
|
|
if ($(this).attr('data-scope') !== scope) {
|
|
|
|
return true;
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
2023-03-06 05:20:29 -05:00
|
|
|
if (!$(this).is(clickedItem) && !$(this).hasClass('checked')) {
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (!$(this).is(clickedItem)) {
|
|
|
|
// Toggle for other labels
|
|
|
|
return true;
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
|
|
|
|
if ($(this).hasClass('checked')) {
|
|
|
|
$(this).removeClass('checked');
|
|
|
|
$(this).find('.octicon-check').addClass('invisible');
|
|
|
|
if (hasUpdateAction) {
|
|
|
|
if (!($(this).data('id') in items)) {
|
|
|
|
items[$(this).data('id')] = {
|
|
|
|
'update-url': $listMenu.data('update-url'),
|
|
|
|
action: 'detach',
|
|
|
|
'issue-id': $listMenu.data('issue-id'),
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
delete items[$(this).data('id')];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$(this).addClass('checked');
|
|
|
|
$(this).find('.octicon-check').removeClass('invisible');
|
|
|
|
if (hasUpdateAction) {
|
|
|
|
if (!($(this).data('id') in items)) {
|
|
|
|
items[$(this).data('id')] = {
|
|
|
|
'update-url': $listMenu.data('update-url'),
|
|
|
|
action: 'attach',
|
|
|
|
'issue-id': $listMenu.data('issue-id'),
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
delete items[$(this).data('id')];
|
|
|
|
}
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
}
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
});
|
2021-10-16 13:28:04 -04:00
|
|
|
|
|
|
|
// TODO: Which thing should be done for choosing review requests
|
|
|
|
// to make chosen items be shown on time here?
|
|
|
|
if (selector === 'select-reviewers-modify' || selector === 'select-assignees-modify') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const listIds = [];
|
|
|
|
$(this).parent().find('.item').each(function () {
|
|
|
|
if ($(this).hasClass('checked')) {
|
|
|
|
listIds.push($(this).data('id'));
|
2023-02-18 23:06:14 -05:00
|
|
|
$($(this).data('id-selector')).removeClass('gt-hidden');
|
2021-10-16 13:28:04 -04:00
|
|
|
} else {
|
2023-02-18 23:06:14 -05:00
|
|
|
$($(this).data('id-selector')).addClass('gt-hidden');
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (listIds.length === 0) {
|
2023-02-18 23:06:14 -05:00
|
|
|
$noSelect.removeClass('gt-hidden');
|
2021-10-16 13:28:04 -04:00
|
|
|
} else {
|
2023-02-18 23:06:14 -05:00
|
|
|
$noSelect.addClass('gt-hidden');
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
2022-01-16 06:19:26 -05:00
|
|
|
$($(this).parent().data('id')).val(listIds.join(','));
|
2021-10-16 13:28:04 -04:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
$listMenu.find('.no-select.item').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (hasUpdateAction) {
|
|
|
|
updateIssuesMeta(
|
|
|
|
$listMenu.data('update-url'),
|
|
|
|
'clear',
|
|
|
|
$listMenu.data('issue-id'),
|
|
|
|
'',
|
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-23 20:26:27 -05:00
|
|
|
).then(reloadConfirmDraftComment);
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$(this).parent().find('.item').each(function () {
|
|
|
|
$(this).removeClass('checked');
|
2023-03-01 14:18:35 -05:00
|
|
|
$(this).find('.octicon-check').addClass('invisible');
|
2021-10-16 13:28:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
if (selector === 'select-reviewers-modify' || selector === 'select-assignees-modify') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$list.find('.item').each(function () {
|
2023-02-18 23:06:14 -05:00
|
|
|
$(this).addClass('gt-hidden');
|
2021-10-16 13:28:04 -04:00
|
|
|
});
|
2023-02-18 23:06:14 -05:00
|
|
|
$noSelect.removeClass('gt-hidden');
|
2022-01-16 06:19:26 -05:00
|
|
|
$($(this).parent().data('id')).val('');
|
2021-10-16 13:28:04 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init labels and assignees
|
|
|
|
initListSubmits('select-label', 'labels');
|
|
|
|
initListSubmits('select-assignees', 'assignees');
|
|
|
|
initListSubmits('select-assignees-modify', 'assignees');
|
|
|
|
initListSubmits('select-reviewers-modify', 'assignees');
|
|
|
|
|
|
|
|
function selectItem(select_id, input_id) {
|
|
|
|
const $menu = $(`${select_id} .menu`);
|
|
|
|
const $list = $(`.ui${select_id}.list`);
|
|
|
|
const hasUpdateAction = $menu.data('action') === 'update';
|
|
|
|
|
|
|
|
$menu.find('.item:not(.no-select)').on('click', function () {
|
|
|
|
$(this).parent().find('.item').each(function () {
|
|
|
|
$(this).removeClass('selected active');
|
|
|
|
});
|
|
|
|
|
|
|
|
$(this).addClass('selected active');
|
|
|
|
if (hasUpdateAction) {
|
|
|
|
updateIssuesMeta(
|
|
|
|
$menu.data('update-url'),
|
|
|
|
'',
|
|
|
|
$menu.data('issue-id'),
|
|
|
|
$(this).data('id'),
|
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-23 20:26:27 -05:00
|
|
|
).then(reloadConfirmDraftComment);
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
let icon = '';
|
|
|
|
if (input_id === '#milestone_id') {
|
2023-02-13 12:59:59 -05:00
|
|
|
icon = svg('octicon-milestone', 18, 'gt-mr-3');
|
2021-10-16 13:28:04 -04:00
|
|
|
} else if (input_id === '#project_id') {
|
2023-02-13 12:59:59 -05:00
|
|
|
icon = svg('octicon-project', 18, 'gt-mr-3');
|
2021-10-16 13:28:04 -04:00
|
|
|
} else if (input_id === '#assignee_id') {
|
2023-02-13 12:59:59 -05:00
|
|
|
icon = `<img class="ui avatar image gt-mr-3" src=${$(this).data('avatar')}>`;
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$list.find('.selected').html(`
|
|
|
|
<a class="item muted sidebar-item-link" href=${$(this).data('href')}>
|
|
|
|
${icon}
|
|
|
|
${htmlEscape($(this).text())}
|
|
|
|
</a>
|
|
|
|
`);
|
|
|
|
|
2023-02-18 23:06:14 -05:00
|
|
|
$(`.ui${select_id}.list .no-select`).addClass('gt-hidden');
|
2021-10-16 13:28:04 -04:00
|
|
|
$(input_id).val($(this).data('id'));
|
|
|
|
});
|
|
|
|
$menu.find('.no-select.item').on('click', function () {
|
|
|
|
$(this).parent().find('.item:not(.no-select)').each(function () {
|
|
|
|
$(this).removeClass('selected active');
|
|
|
|
});
|
|
|
|
|
|
|
|
if (hasUpdateAction) {
|
|
|
|
updateIssuesMeta(
|
|
|
|
$menu.data('update-url'),
|
|
|
|
'',
|
|
|
|
$menu.data('issue-id'),
|
|
|
|
$(this).data('id'),
|
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-23 20:26:27 -05:00
|
|
|
).then(reloadConfirmDraftComment);
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$list.find('.selected').html('');
|
2023-02-18 23:06:14 -05:00
|
|
|
$list.find('.no-select').removeClass('gt-hidden');
|
2022-01-16 06:19:26 -05:00
|
|
|
$(input_id).val('');
|
2021-10-16 13:28:04 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Milestone, Assignee, Project
|
|
|
|
selectItem('.select-project', '#project_id');
|
|
|
|
selectItem('.select-milestone', '#milestone_id');
|
|
|
|
selectItem('.select-assignee', '#assignee_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-18 11:45:00 -05:00
|
|
|
async function onEditContent(event) {
|
|
|
|
event.preventDefault();
|
2022-01-05 07:17:25 -05:00
|
|
|
|
2021-11-18 11:45:00 -05:00
|
|
|
const $segment = $(this).closest('.header').next();
|
|
|
|
const $editContentZone = $segment.find('.edit-content-zone');
|
|
|
|
const $renderContent = $segment.find('.render-content');
|
|
|
|
const $rawContent = $segment.find('.raw-content');
|
|
|
|
let $textarea;
|
2021-12-09 21:51:27 -05:00
|
|
|
let easyMDE;
|
2021-11-18 11:45:00 -05:00
|
|
|
|
|
|
|
// Setup new form
|
|
|
|
if ($editContentZone.html().length === 0) {
|
|
|
|
$editContentZone.html($('#edit-content-form').html());
|
|
|
|
$textarea = $editContentZone.find('textarea');
|
|
|
|
await attachTribute($textarea.get(), {mentions: true, emoji: true});
|
|
|
|
|
|
|
|
let dz;
|
|
|
|
const $dropzone = $editContentZone.find('.dropzone');
|
|
|
|
if ($dropzone.length === 1) {
|
|
|
|
$dropzone.data('saved', false);
|
|
|
|
|
|
|
|
const fileUuidDict = {};
|
|
|
|
dz = await createDropzone($dropzone[0], {
|
|
|
|
url: $dropzone.data('upload-url'),
|
|
|
|
headers: {'X-Csrf-Token': csrfToken},
|
|
|
|
maxFiles: $dropzone.data('max-file'),
|
|
|
|
maxFilesize: $dropzone.data('max-size'),
|
|
|
|
acceptedFiles: (['*/*', ''].includes($dropzone.data('accepts'))) ? null : $dropzone.data('accepts'),
|
|
|
|
addRemoveLinks: true,
|
|
|
|
dictDefaultMessage: $dropzone.data('default-message'),
|
|
|
|
dictInvalidFileType: $dropzone.data('invalid-input-type'),
|
|
|
|
dictFileTooBig: $dropzone.data('file-too-big'),
|
|
|
|
dictRemoveFile: $dropzone.data('remove-file'),
|
|
|
|
timeout: 0,
|
|
|
|
thumbnailMethod: 'contain',
|
|
|
|
thumbnailWidth: 480,
|
|
|
|
thumbnailHeight: 480,
|
|
|
|
init() {
|
|
|
|
this.on('success', (file, data) => {
|
2022-06-25 15:49:56 -04:00
|
|
|
file.uuid = data.uuid;
|
2021-11-18 11:45:00 -05:00
|
|
|
fileUuidDict[file.uuid] = {submitted: false};
|
|
|
|
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid);
|
|
|
|
$dropzone.find('.files').append(input);
|
|
|
|
});
|
|
|
|
this.on('removedfile', (file) => {
|
|
|
|
$(`#${file.uuid}`).remove();
|
|
|
|
if ($dropzone.data('remove-url') && !fileUuidDict[file.uuid].submitted) {
|
|
|
|
$.post($dropzone.data('remove-url'), {
|
|
|
|
file: file.uuid,
|
|
|
|
_csrf: csrfToken,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.on('submit', () => {
|
|
|
|
$.each(fileUuidDict, (fileUuid) => {
|
|
|
|
fileUuidDict[fileUuid].submitted = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.on('reload', () => {
|
|
|
|
$.getJSON($editContentZone.data('attachment-url'), (data) => {
|
|
|
|
dz.removeAllFiles(true);
|
|
|
|
$dropzone.find('.files').empty();
|
|
|
|
$.each(data, function () {
|
|
|
|
const imgSrc = `${$dropzone.data('link-url')}/${this.uuid}`;
|
|
|
|
dz.emit('addedfile', this);
|
|
|
|
dz.emit('thumbnail', this, imgSrc);
|
|
|
|
dz.emit('complete', this);
|
|
|
|
dz.files.push(this);
|
|
|
|
fileUuidDict[this.uuid] = {submitted: true};
|
|
|
|
$dropzone.find(`img[src='${imgSrc}']`).css('max-width', '100%');
|
|
|
|
const input = $(`<input id="${this.uuid}" name="files" type="hidden">`).val(this.uuid);
|
|
|
|
$dropzone.find('.files').append(input);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
dz.emit('reload');
|
|
|
|
}
|
|
|
|
// Give new write/preview data-tab name to distinguish from others
|
|
|
|
const $editContentForm = $editContentZone.find('.ui.comment.form');
|
|
|
|
const $tabMenu = $editContentForm.find('.tabular.menu');
|
|
|
|
$tabMenu.attr('data-write', $editContentZone.data('write'));
|
|
|
|
$tabMenu.attr('data-preview', $editContentZone.data('preview'));
|
|
|
|
$tabMenu.find('.write.item').attr('data-tab', $editContentZone.data('write'));
|
|
|
|
$tabMenu.find('.preview.item').attr('data-tab', $editContentZone.data('preview'));
|
|
|
|
$editContentForm.find('.write').attr('data-tab', $editContentZone.data('write'));
|
|
|
|
$editContentForm.find('.preview').attr('data-tab', $editContentZone.data('preview'));
|
2022-01-05 07:17:25 -05:00
|
|
|
easyMDE = await createCommentEasyMDE($textarea);
|
2021-11-18 11:45:00 -05:00
|
|
|
|
|
|
|
initCompMarkupContentPreviewTab($editContentForm);
|
2022-06-28 13:52:58 -04:00
|
|
|
initEasyMDEImagePaste(easyMDE, $dropzone);
|
2021-11-18 11:45:00 -05:00
|
|
|
|
2022-05-19 22:26:04 -04:00
|
|
|
const $saveButton = $editContentZone.find('.save.button');
|
|
|
|
$textarea.on('ce-quick-submit', () => {
|
|
|
|
$saveButton.trigger('click');
|
|
|
|
});
|
|
|
|
|
2021-11-18 11:45:00 -05:00
|
|
|
$editContentZone.find('.cancel.button').on('click', () => {
|
2023-02-18 23:06:14 -05:00
|
|
|
showElem($renderContent);
|
|
|
|
hideElem($editContentZone);
|
2021-11-18 11:45:00 -05:00
|
|
|
if (dz) {
|
|
|
|
dz.emit('reload');
|
|
|
|
}
|
|
|
|
});
|
2022-05-19 22:26:04 -04:00
|
|
|
|
|
|
|
$saveButton.on('click', () => {
|
2023-02-18 23:06:14 -05:00
|
|
|
showElem($renderContent);
|
|
|
|
hideElem($editContentZone);
|
2021-11-18 11:45:00 -05:00
|
|
|
const $attachments = $dropzone.find('.files').find('[name=files]').map(function () {
|
|
|
|
return $(this).val();
|
|
|
|
}).get();
|
|
|
|
$.post($editContentZone.data('update-url'), {
|
|
|
|
_csrf: csrfToken,
|
|
|
|
content: $textarea.val(),
|
|
|
|
context: $editContentZone.data('context'),
|
|
|
|
files: $attachments,
|
|
|
|
}, (data) => {
|
|
|
|
if (data.length === 0 || data.content.length === 0) {
|
|
|
|
$renderContent.html($('#no-content').html());
|
|
|
|
$rawContent.text('');
|
|
|
|
} else {
|
|
|
|
$renderContent.html(data.content);
|
|
|
|
$rawContent.text($textarea.val());
|
|
|
|
}
|
|
|
|
const $content = $segment;
|
|
|
|
if (!$content.find('.dropzone-attachments').length) {
|
|
|
|
if (data.attachments !== '') {
|
|
|
|
$content.append(`<div class="dropzone-attachments"></div>`);
|
|
|
|
$content.find('.dropzone-attachments').replaceWith(data.attachments);
|
|
|
|
}
|
|
|
|
} else if (data.attachments === '') {
|
|
|
|
$content.find('.dropzone-attachments').remove();
|
|
|
|
} else {
|
|
|
|
$content.find('.dropzone-attachments').replaceWith(data.attachments);
|
|
|
|
}
|
|
|
|
if (dz) {
|
|
|
|
dz.emit('submit');
|
|
|
|
dz.emit('reload');
|
|
|
|
}
|
|
|
|
initMarkupContent();
|
|
|
|
initCommentContent();
|
|
|
|
});
|
|
|
|
});
|
2022-05-19 22:26:04 -04:00
|
|
|
} else { // use existing form
|
2021-11-18 11:45:00 -05:00
|
|
|
$textarea = $segment.find('textarea');
|
2021-12-09 21:51:27 -05:00
|
|
|
easyMDE = getAttachedEasyMDE($textarea);
|
2021-11-18 11:45:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show write/preview tab and copy raw content as needed
|
2023-02-18 23:06:14 -05:00
|
|
|
showElem($editContentZone);
|
|
|
|
hideElem($renderContent);
|
2021-11-18 11:45:00 -05:00
|
|
|
if ($textarea.val().length === 0) {
|
|
|
|
$textarea.val($rawContent.text());
|
2021-12-09 21:51:27 -05:00
|
|
|
easyMDE.value($rawContent.text());
|
2021-11-18 11:45:00 -05:00
|
|
|
}
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
$textarea.focus();
|
2021-12-09 21:51:27 -05:00
|
|
|
easyMDE.codemirror.focus();
|
2021-11-18 11:45:00 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-09 04:27:25 -05:00
|
|
|
export function initRepository() {
|
2021-10-16 13:28:04 -04:00
|
|
|
if ($('.repository').length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// File list and commits
|
2022-02-09 15:28:55 -05:00
|
|
|
if ($('.repository.file.list').length > 0 || $('.branch-dropdown').length > 0 ||
|
2021-10-16 13:28:04 -04:00
|
|
|
$('.repository.commits').length > 0 || $('.repository.release').length > 0) {
|
|
|
|
initRepoBranchTagDropdown('.choose.reference .dropdown');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wiki
|
|
|
|
if ($('.repository.wiki.view').length > 0) {
|
|
|
|
initRepoCommonFilterSearchDropdown('.choose.page .dropdown');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Options
|
|
|
|
if ($('.repository.settings.options').length > 0) {
|
|
|
|
// Enable or select internal/external wiki system and issue tracker.
|
|
|
|
$('.enable-system').on('change', function () {
|
|
|
|
if (this.checked) {
|
2022-01-16 06:19:26 -05:00
|
|
|
$($(this).data('target')).removeClass('disabled');
|
|
|
|
if (!$(this).data('context')) $($(this).data('context')).addClass('disabled');
|
2021-10-16 13:28:04 -04:00
|
|
|
} else {
|
2022-01-16 06:19:26 -05:00
|
|
|
$($(this).data('target')).addClass('disabled');
|
|
|
|
if (!$(this).data('context')) $($(this).data('context')).removeClass('disabled');
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$('.enable-system-radio').on('change', function () {
|
|
|
|
if (this.value === 'false') {
|
2022-01-16 06:19:26 -05:00
|
|
|
$($(this).data('target')).addClass('disabled');
|
2022-11-21 19:58:55 -05:00
|
|
|
if ($(this).data('context') !== undefined) $($(this).data('context')).removeClass('disabled');
|
2021-10-16 13:28:04 -04:00
|
|
|
} else if (this.value === 'true') {
|
2022-01-16 06:19:26 -05:00
|
|
|
$($(this).data('target')).removeClass('disabled');
|
2022-11-21 19:58:55 -05:00
|
|
|
if ($(this).data('context') !== undefined) $($(this).data('context')).addClass('disabled');
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
});
|
2022-06-10 01:39:53 -04:00
|
|
|
const $trackerIssueStyleRadios = $('.js-tracker-issue-style');
|
|
|
|
$trackerIssueStyleRadios.on('change input', () => {
|
|
|
|
const checkedVal = $trackerIssueStyleRadios.filter(':checked').val();
|
|
|
|
$('#tracker-issue-style-regex-box').toggleClass('disabled', checkedVal !== 'regexp');
|
|
|
|
});
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Labels
|
|
|
|
initCompLabelEdit('.repository.labels');
|
|
|
|
|
|
|
|
// Milestones
|
|
|
|
if ($('.repository.new.milestone').length > 0) {
|
|
|
|
$('#clear-date').on('click', () => {
|
|
|
|
$('#deadline').val('');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Repo Creation
|
|
|
|
if ($('.repository.new.repo').length > 0) {
|
|
|
|
$('input[name="gitignores"], input[name="license"]').on('change', () => {
|
|
|
|
const gitignores = $('input[name="gitignores"]').val();
|
|
|
|
const license = $('input[name="license"]').val();
|
|
|
|
if (gitignores || license) {
|
|
|
|
$('input[name="auto_init"]').prop('checked', true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-18 11:45:00 -05:00
|
|
|
// Compare or pull request
|
|
|
|
const $repoDiff = $('.repository.diff');
|
|
|
|
if ($repoDiff.length) {
|
|
|
|
initRepoCommonBranchOrTagDropdown('.choose.branch .dropdown');
|
|
|
|
initRepoCommonFilterSearchDropdown('.choose.branch .dropdown');
|
|
|
|
}
|
|
|
|
|
2022-03-28 23:21:30 -04:00
|
|
|
initRepoCloneLink();
|
2022-11-11 12:02:50 -05:00
|
|
|
initCitationFileCopyContent();
|
2021-11-18 11:45:00 -05:00
|
|
|
initRepoCommonLanguageStats();
|
|
|
|
initRepoSettingBranches();
|
|
|
|
|
2021-10-16 13:28:04 -04:00
|
|
|
// Issues
|
|
|
|
if ($('.repository.view.issue').length > 0) {
|
2021-11-18 11:45:00 -05:00
|
|
|
initRepoIssueCommentEdit();
|
|
|
|
|
2021-10-16 13:28:04 -04:00
|
|
|
initRepoIssueBranchSelect();
|
|
|
|
initRepoIssueTitleEdit();
|
|
|
|
initRepoIssueWipToggle();
|
|
|
|
initRepoIssueComments();
|
|
|
|
|
|
|
|
initRepoDiffConversationNav();
|
|
|
|
initRepoIssueReferenceIssue();
|
|
|
|
|
|
|
|
|
|
|
|
initRepoIssueCommentDelete();
|
|
|
|
initRepoIssueDependencyDelete();
|
|
|
|
initRepoIssueCodeCommentCancel();
|
|
|
|
initRepoIssueStatusButton();
|
|
|
|
initRepoPullRequestUpdate();
|
|
|
|
initCompReactionSelector();
|
2022-05-12 09:39:02 -04:00
|
|
|
|
|
|
|
initRepoPullRequestMergeForm();
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Pull request
|
|
|
|
const $repoComparePull = $('.repository.compare.pull');
|
|
|
|
if ($repoComparePull.length > 0) {
|
|
|
|
// show pull request form
|
|
|
|
$repoComparePull.find('button.show-form').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
2023-02-18 23:06:14 -05:00
|
|
|
hideElem($(this).parent());
|
2021-11-18 11:45:00 -05:00
|
|
|
|
|
|
|
const $form = $repoComparePull.find('.pullrequest-form');
|
2023-02-18 23:06:14 -05:00
|
|
|
showElem($form);
|
2022-09-02 03:58:49 -04:00
|
|
|
$form.find('textarea.edit_area').each(function() {
|
|
|
|
const easyMDE = getAttachedEasyMDE($(this));
|
|
|
|
if (easyMDE) {
|
|
|
|
easyMDE.codemirror.refresh();
|
|
|
|
}
|
|
|
|
});
|
2021-10-16 13:28:04 -04:00
|
|
|
});
|
|
|
|
}
|
2022-01-06 20:18:52 -05:00
|
|
|
|
|
|
|
initUnicodeEscapeButton();
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
|
2021-11-18 11:45:00 -05:00
|
|
|
function initRepoIssueCommentEdit() {
|
|
|
|
// Issue/PR Context Menus
|
|
|
|
$('.comment-header-right .context-dropdown').dropdown({action: 'hide'});
|
|
|
|
|
|
|
|
// Edit issue or comment content
|
|
|
|
$(document).on('click', '.edit-content', onEditContent);
|
|
|
|
|
2021-10-16 13:28:04 -04:00
|
|
|
// Quote reply
|
2023-03-02 14:53:22 -05:00
|
|
|
$(document).on('click', '.quote-reply', async function (event) {
|
|
|
|
event.preventDefault();
|
2021-10-16 13:28:04 -04:00
|
|
|
const target = $(this).data('target');
|
2022-12-09 11:25:32 -05:00
|
|
|
const quote = $(`#${target}`).text().replace(/\n/g, '\n> ');
|
2021-10-16 13:28:04 -04:00
|
|
|
const content = `> ${quote}\n\n`;
|
2021-12-09 21:51:27 -05:00
|
|
|
let easyMDE;
|
2021-10-16 13:28:04 -04:00
|
|
|
if ($(this).hasClass('quote-reply-diff')) {
|
2023-03-02 14:53:22 -05:00
|
|
|
const $replyBtn = $(this).closest('.comment-code-cloud').find('button.comment-form-reply');
|
|
|
|
easyMDE = await handleReply($replyBtn);
|
2021-11-18 11:45:00 -05:00
|
|
|
} else {
|
|
|
|
// for normal issue/comment page
|
2021-12-09 21:51:27 -05:00
|
|
|
easyMDE = getAttachedEasyMDE($('#comment-form .edit_area'));
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
2021-12-09 21:51:27 -05:00
|
|
|
if (easyMDE) {
|
|
|
|
if (easyMDE.value() !== '') {
|
|
|
|
easyMDE.value(`${easyMDE.value()}\n\n${content}`);
|
2021-10-16 13:28:04 -04:00
|
|
|
} else {
|
2021-12-09 21:51:27 -05:00
|
|
|
easyMDE.value(`${content}`);
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
2021-11-18 11:45:00 -05:00
|
|
|
requestAnimationFrame(() => {
|
2021-12-09 21:51:27 -05:00
|
|
|
easyMDE.codemirror.focus();
|
|
|
|
easyMDE.codemirror.setCursor(easyMDE.codemirror.lineCount(), 0);
|
2021-11-18 11:45:00 -05:00
|
|
|
});
|
2021-10-16 13:28:04 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|