mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Improve "goto issue by number" button (#24577)
Follow #24479      --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
		@@ -4,7 +4,6 @@ import {showTemporaryTooltip, createTippy} from '../modules/tippy.js';
 | 
			
		||||
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
 | 
			
		||||
import {setFileFolding} from './file-fold.js';
 | 
			
		||||
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
 | 
			
		||||
import {parseIssueHref} from '../utils.js';
 | 
			
		||||
 | 
			
		||||
const {appSubUrl, csrfToken} = window.config;
 | 
			
		||||
 | 
			
		||||
@@ -638,34 +637,6 @@ export function initRepoIssueBranchSelect() {
 | 
			
		||||
  $('#branch-select > .item').on('click', changeBranchSelect);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function initRepoIssueGotoID() {
 | 
			
		||||
  const issueidre = /^(?:\w+\/\w+#\d+|#\d+|\d+)$/;
 | 
			
		||||
  const isGlobalIssuesArea = $('.repo.name.item').length > 0; // for global issues area or repository issues area
 | 
			
		||||
  $('form.list-header-search').on('submit', (e) => {
 | 
			
		||||
    const qval = e.target.q.value;
 | 
			
		||||
    const aElm = document.activeElement;
 | 
			
		||||
    if (!$('#hashtag-button').length || aElm.id === 'search-button' || (aElm.name === 'q' && !qval.includes('#')) || (isGlobalIssuesArea && !qval.includes('/')) || !issueidre.test(qval)) return;
 | 
			
		||||
    const pathname = window.location.pathname;
 | 
			
		||||
    let gotoUrl = qval.includes('/') ? `${qval.replace('#', '/issues/')}` : `${pathname}/${qval.replace('#', '')}`;
 | 
			
		||||
    if (appSubUrl.length) {
 | 
			
		||||
      gotoUrl = qval.includes('/') ? `/${appSubUrl}/${qval.replace('#', '/issues/')}` : `/${appSubUrl}/${pathname}/${qval.replace('#', '')}`;
 | 
			
		||||
    }
 | 
			
		||||
    const {owner, repo, type, index} = parseIssueHref(gotoUrl);
 | 
			
		||||
    if (owner && repo && type && index) {
 | 
			
		||||
      e.preventDefault();
 | 
			
		||||
      window.location.href = gotoUrl;
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
  $('form.list-header-search input[name=q]').on('input', (e) => {
 | 
			
		||||
    const qval = e.target.value;
 | 
			
		||||
    if (isGlobalIssuesArea && qval.includes('/') && issueidre.test(qval) || !isGlobalIssuesArea && issueidre.test(qval)) {
 | 
			
		||||
      showElem($('#hashtag-button'));
 | 
			
		||||
    } else {
 | 
			
		||||
      hideElem($('#hashtag-button'));
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function initSingleCommentEditor($commentForm) {
 | 
			
		||||
  // pages:
 | 
			
		||||
  // * normal new issue/pr page, no status-button
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user