Merge pull request #8 from BinaryAlley/feature/toggle-file-system-browser-dialog-thumbnails-preview-icon

Adds file system browser dialog thumbnails preview icon toggle
This commit is contained in:
BinaryAlley authored and GitHub committed 2024-10-03 13:20:35 +03:00
commit f1a4db79ec
2 files changed
+25 -2

No files matched your search

@@ -382,7 +382,7 @@
<rect x="4.5" y="4.5" width="21" height="21" ry="2.5" fill="none" stroke="#039bfc" style="paint-order:stroke fill markers" filter="url(#glow)" />
</g>
<g transform="translate(3,2.5) scale(0.32)">
<path xmlns="http://www.w3.org/2000/svg" style="fill:currentColor;" class="navigator-icon-fill" filter="url(#glow)" d="M 20,17L 44.25,17L 56,28.75L 56,59L 20,59L 20,17 Z M 24,21L 24,55L 52,55L 52,34L 39,34L 39,21L 24,21 Z M 43,22.25L 43,30L 50.75,30L 43,22.25 Z M 27,47.5L 30,50.5L 42.5,38L 47.5,43L 51,39L 51,54L 25,54L 25,50L 27,47.5 Z M 33,22C 33,26.3723 29.3723,30 25,30L 25,22L 33,22 Z " />
<path xmlns="http://www.w3.org/2000/svg" style="fill:currentColor;" class="navigator-icon-fill thumbnails" filter="url(#glow)" d="M 20,17L 44.25,17L 56,28.75L 56,59L 20,59L 20,17 Z M 24,21L 24,55L 52,55L 52,34L 39,34L 39,21L 24,21 Z M 43,22.25L 43,30L 50.75,30L 43,22.25 Z M 27,47.5L 30,50.5L 42.5,38L 47.5,43L 51,39L 51,54L 25,54L 25,50L 27,47.5 Z M 33,22C 33,26.3723 29.3723,30 25,30L 25,22L 33,22 Z " />
</g>
</svg>
<!--Toggle Hidden Elements-->
@@ -20,11 +20,13 @@ const btnNavigatorNavigateForward = document.getElementById('navigator-navigate-
const btnNavigatorNavigateUp = document.getElementById('navigator-navigate-up');
const btnNavigatorToggleTreeView = document.getElementById('navigator-toggle-tree-view-button');
const btnNavigatorToggleThumbnails = document.getElementById('navigator-toggle-thumbnails-button');
const btnNavigatorToggleSelectionMode = document.getElementById('navigator-toggle-selection-button');
const btnNavigatorHiddenElements = document.getElementById('navigator-toggle-hidden-button');
const btnEditPath = document.getElementById('navigator-edit-path-button');
const svgTreeView = document.querySelectorAll('.navigator-icon-fill.tree-view');
const svgThumbnails = document.querySelectorAll('.navigator-icon-fill.thumbnails');
const svgSelectionMode = document.querySelectorAll('.navigator-icon-fill.selection-mode');
const svgHiddenElements = document.querySelectorAll('.navigator-icon-fill.hidden-elements');
const svgListView = document.querySelectorAll('.navigator-icon-fill.list');
@@ -193,6 +195,7 @@ async function showFileSystemBrowserDialogAsync(path, showHiddenElementsValue) {
addressBarInput.value = path;
await toggleShowFileSystemHiddenElementsAsync(false);
await toggleFileSystemTreeViewAsync(false);
await toggleShowFileSystemElementsThumbnailsAsync(false);
await navigateToPathAsync(path, false, false);
} else
notificationService.Show("Path cannot be null!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented
@@ -303,7 +306,8 @@ async function navigateToPathAsync(path, isForwardNavigation, isBackwardNavigati
await getFileSystemItemsAsync(path);
if (showFileSystemTreeView)
await getFileSystemTreeViewAsync(path);
getFileSystemVisibleItems();
if (showThumbnails)
getFileSystemVisibleItems();
}
addressBarInput.value = _path;
if (addressBarInput.value !== null && !addressBarInput.value.endsWith(pathSeparator))
@@ -1487,6 +1491,24 @@ async function toggleShowFileSystemHiddenElementsAsync(isManualSet) {
}
}
/**
* Enables or disables the display of file system elements thumbnails.
* @param {boolean} isManualSet - Indicates whether the toggle is triggered manually (by clicking on the icon) or automatically.
*/
async function toggleShowFileSystemElementsThumbnailsAsync(isManualSet) {
if (isManualSet)
showThumbnails = !showThumbnails;
svgThumbnails.forEach(element => {
showThumbnails ? element.classList.add('enabled') : element.classList.remove('enabled');
});
if (isManualSet && addressBarInput.value !== null) {
if (!addressBarInput.value.endsWith(pathSeparator))
addressBarInput.value += pathSeparator;
await navigateToPathAsync(addressBarInput.value, false, false);
}
}
/**
* Closes all comboboxes except for the one passed as an argument.
* @param {HTMLElement} exceptionCheckbox - The checkbox of the combobox that should remain open.
@@ -1530,6 +1552,7 @@ btnLargeIconsView.addEventListener('click', () => switchViewMode('icons', 'large
btnExtraLargeIconsView.addEventListener('click', () => switchViewMode('icons', 'extra-large', true));
btnNavigatorToggleTreeView.addEventListener('click', async () => await toggleFileSystemTreeViewAsync(true));
btnNavigatorToggleThumbnails.addEventListener('click', async () => await toggleShowFileSystemElementsThumbnailsAsync(true));
btnNavigatorToggleSelectionMode.addEventListener('click', toggleFileSystemSelectionMode);
btnNavigatorHiddenElements.addEventListener('click', async () => await toggleShowFileSystemHiddenElementsAsync(true));
btnNavigatorNavigateUp.addEventListener('click', navigateUpAsync);