mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	Expand/Collapse all changed files (#23639)
close #23628 Now in `...` dropdown, you can expand or collapse all diff files that have loaded. https://user-images.githubusercontent.com/33891828/227749688-2d406916-3347-49f6-93a5-4092a00e8809.mov Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
		@@ -4,6 +4,8 @@ const {csrfToken, pageData} = window.config;
 | 
			
		||||
const prReview = pageData.prReview || {};
 | 
			
		||||
const viewedStyleClass = 'viewed-file-checked-form';
 | 
			
		||||
const viewedCheckboxSelector = '.viewed-file-form'; // Selector under which all "Viewed" checkbox forms can be found
 | 
			
		||||
const expandFilesBtnSelector = '#expand-files-btn';
 | 
			
		||||
const collapseFilesBtnSelector = '#collapse-files-btn';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Refreshes the summary of viewed files if present
 | 
			
		||||
@@ -69,3 +71,21 @@ export function initViewedCheckboxListenerFor() {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function initExpandAndCollapseFilesButton() {
 | 
			
		||||
  // expand btn
 | 
			
		||||
  document.querySelector(expandFilesBtnSelector)?.addEventListener('click', () => {
 | 
			
		||||
    for (const box of document.querySelectorAll('.file-content[data-folded="true"]')) {
 | 
			
		||||
      setFileFolding(box, box.querySelector('.fold-file'), false);
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
  // collapse btn, need to exclude the div of “show more”
 | 
			
		||||
  document.querySelector(collapseFilesBtnSelector)?.addEventListener('click', () => {
 | 
			
		||||
    for (const box of document.querySelectorAll('.file-content:not([data-folded="true"])')) {
 | 
			
		||||
      if (box.getAttribute('id') === 'diff-incomplete') continue;
 | 
			
		||||
      setFileFolding(box, box.querySelector('.fold-file'), true);
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user