You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

file-fold.js 994B

12345678910111213141516171819
  1. import {svg} from '../svg.js';
  2. // Hides the file if newFold is true, and shows it otherwise. The actual hiding is performed using CSS.
  3. //
  4. // The fold arrow is the icon displayed on the upper left of the file box, especially intended for components having the 'fold-file' class.
  5. // The file content box is the box that should be hidden or shown, especially intended for components having the 'file-content' class.
  6. //
  7. export function setFileFolding(fileContentBox, foldArrow, newFold) {
  8. foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
  9. fileContentBox.setAttribute('data-folded', newFold);
  10. if (newFold && fileContentBox.getBoundingClientRect().top < 0) {
  11. fileContentBox.scrollIntoView();
  12. }
  13. }
  14. // Like `setFileFolding`, except that it automatically inverts the current file folding state.
  15. export function invertFileFolding(fileContentBox, foldArrow) {
  16. setFileFolding(fileContentBox, foldArrow, fileContentBox.getAttribute('data-folded') !== 'true');
  17. }