summaryrefslogtreecommitdiffstats
path: root/web_src/js/features/file-fold.js
diff options
context:
space:
mode:
authordelvh <leon@kske.dev>2022-05-07 20:28:10 +0200
committerGitHub <noreply@github.com>2022-05-07 20:28:10 +0200
commit5ca224a789394d00cc1efb5afcae7b87aa7d1e49 (patch)
treed88bddc7a08449a2c8f2b4e5ae47d3ef067a1cc0 /web_src/js/features/file-fold.js
parent59b30f060a840cde305952ef7bc344fa4101c0d5 (diff)
downloadgitea-5ca224a789394d00cc1efb5afcae7b87aa7d1e49.tar.gz
gitea-5ca224a789394d00cc1efb5afcae7b87aa7d1e49.zip
Allow to mark files in a PR as viewed (#19007)
Users can now mark files in PRs as viewed, resulting in them not being shown again by default when they reopen the PR again.
Diffstat (limited to 'web_src/js/features/file-fold.js')
-rw-r--r--web_src/js/features/file-fold.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/web_src/js/features/file-fold.js b/web_src/js/features/file-fold.js
new file mode 100644
index 0000000000..5e714a1de8
--- /dev/null
+++ b/web_src/js/features/file-fold.js
@@ -0,0 +1,18 @@
+import {svg} from '../svg.js';
+
+
+// Hides the file if newFold is true, and shows it otherwise. The actual hiding is performed using CSS.
+//
+// The fold arrow is the icon displayed on the upper left of the file box, especially intended for components having the 'fold-file' class.
+// The file content box is the box that should be hidden or shown, especially intended for components having the 'file-content' class.
+//
+export function setFileFolding(fileContentBox, foldArrow, newFold) {
+ foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
+ fileContentBox.setAttribute('data-folded', newFold);
+}
+
+// Like `setFileFolding`, except that it automatically inverts the current file folding state.
+export function invertFileFolding(fileContentBox, foldArrow) {
+ setFileFolding(fileContentBox, foldArrow, fileContentBox.getAttribute('data-folded') !== 'true');
+}
+