diff options
Diffstat (limited to 'viewer/src/services')
-rw-r--r-- | viewer/src/services/dragscrollclickfix.ts | 3 | ||||
-rw-r--r-- | viewer/src/services/indexfactory.ts | 21 | ||||
-rw-r--r-- | viewer/src/services/indexsearch.ts | 1 | ||||
-rw-r--r-- | viewer/src/services/ldzoom.ts | 6 | ||||
-rw-r--r-- | viewer/src/services/navigation.ts | 24 |
5 files changed, 32 insertions, 23 deletions
diff --git a/viewer/src/services/dragscrollclickfix.ts b/viewer/src/services/dragscrollclickfix.ts index 38eb106..7125510 100644 --- a/viewer/src/services/dragscrollclickfix.ts +++ b/viewer/src/services/dragscrollclickfix.ts | |||
@@ -19,7 +19,6 @@ | |||
19 | 19 | ||
20 | // https://github.com/donmbelembe/vue-dragscroll/issues/61 | 20 | // https://github.com/donmbelembe/vue-dragscroll/issues/61 |
21 | export default class DragScrollClickFix { | 21 | export default class DragScrollClickFix { |
22 | |||
23 | readonly DRAG_DELAY = 250; // This is the minimal delay to consider a click to be a drag, mostly usefull for touch devices | 22 | readonly DRAG_DELAY = 250; // This is the minimal delay to consider a click to be a drag, mostly usefull for touch devices |
24 | 23 | ||
25 | timer: NodeJS.Timeout | null = null; | 24 | timer: NodeJS.Timeout | null = null; |
@@ -39,7 +38,7 @@ export default class DragScrollClickFix { | |||
39 | clearTimeout(this.timer); | 38 | clearTimeout(this.timer); |
40 | this.timer = null; | 39 | this.timer = null; |
41 | } | 40 | } |
42 | setTimeout(() => this.dragging = false); | 41 | setTimeout(() => (this.dragging = false)); |
43 | } | 42 | } |
44 | 43 | ||
45 | onClickCapture(e: MouseEvent) { | 44 | onClickCapture(e: MouseEvent) { |
diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts index 00abc05..c4b6d51 100644 --- a/viewer/src/services/indexfactory.ts +++ b/viewer/src/services/indexfactory.ts | |||
@@ -22,7 +22,6 @@ import { ItemType } from "@/@types/ItemType"; | |||
22 | import Navigation from "@/services/navigation"; | 22 | import Navigation from "@/services/navigation"; |
23 | 23 | ||
24 | export default class IndexFactory { | 24 | export default class IndexFactory { |
25 | |||
26 | public static generateTags(root: Gallery.Item | null): Tag.Index { | 25 | public static generateTags(root: Gallery.Item | null): Tag.Index { |
27 | let tagsIndex: Tag.Index = {}; | 26 | let tagsIndex: Tag.Index = {}; |
28 | if (root) IndexFactory.pushTagsForItem(tagsIndex, root); | 27 | if (root) IndexFactory.pushTagsForItem(tagsIndex, root); |
@@ -51,7 +50,15 @@ export default class IndexFactory { | |||
51 | } | 50 | } |
52 | 51 | ||
53 | private static pushPartToIndex(index: Tag.Node, part: string, item: Gallery.Item, rootPart: boolean): Tag.Node { | 52 | private static pushPartToIndex(index: Tag.Node, part: string, item: Gallery.Item, rootPart: boolean): Tag.Node { |
54 | if (!index) index = { tag: part, tagfiltered: Navigation.normalize(part), rootPart, childPart: !rootPart, items: [], children: {} }; | 53 | if (!index) |
54 | index = { | ||
55 | tag: part, | ||
56 | tagfiltered: Navigation.normalize(part), | ||
57 | rootPart, | ||
58 | childPart: !rootPart, | ||
59 | items: [], | ||
60 | children: {}, | ||
61 | }; | ||
55 | else if (rootPart) index.rootPart = true; | 62 | else if (rootPart) index.rootPart = true; |
56 | else index.childPart = true; | 63 | else index.childPart = true; |
57 | 64 | ||
@@ -61,7 +68,6 @@ export default class IndexFactory { | |||
61 | 68 | ||
62 | // --- | 69 | // --- |
63 | 70 | ||
64 | |||
65 | public static searchTags(tagsIndex: Tag.Index, filter: string, strict: boolean): Tag.Search[] { | 71 | public static searchTags(tagsIndex: Tag.Index, filter: string, strict: boolean): Tag.Search[] { |
66 | let search: Tag.Search[] = []; | 72 | let search: Tag.Search[] = []; |
67 | if (tagsIndex && filter) { | 73 | if (tagsIndex && filter) { |
@@ -106,7 +112,12 @@ export default class IndexFactory { | |||
106 | ); | 112 | ); |
107 | } | 113 | } |
108 | 114 | ||
109 | private static searchTagsFromFilter(tagsIndex: Tag.Index, operation: Operation, filter: string, strict: boolean): Tag.Search[] { | 115 | private static searchTagsFromFilter( |
116 | tagsIndex: Tag.Index, | ||
117 | operation: Operation, | ||
118 | filter: string, | ||
119 | strict: boolean | ||
120 | ): Tag.Search[] { | ||
110 | filter = Navigation.normalize(filter); | 121 | filter = Navigation.normalize(filter); |
111 | return Object.values(tagsIndex) | 122 | return Object.values(tagsIndex) |
112 | .filter(node => IndexFactory.matches(node, filter, strict)) | 123 | .filter(node => IndexFactory.matches(node, filter, strict)) |
@@ -115,7 +126,7 @@ export default class IndexFactory { | |||
115 | 126 | ||
116 | private static matches(node: Tag.Node, filter: string, strict: boolean): boolean { | 127 | private static matches(node: Tag.Node, filter: string, strict: boolean): boolean { |
117 | if (strict) return node.tagfiltered === filter; | 128 | if (strict) return node.tagfiltered === filter; |
118 | return node.tagfiltered.includes(filter) | 129 | return node.tagfiltered.includes(filter); |
119 | } | 130 | } |
120 | 131 | ||
121 | // --- | 132 | // --- |
diff --git a/viewer/src/services/indexsearch.ts b/viewer/src/services/indexsearch.ts index a55a829..e6d7eed 100644 --- a/viewer/src/services/indexsearch.ts +++ b/viewer/src/services/indexsearch.ts | |||
@@ -20,7 +20,6 @@ | |||
20 | import { Operation } from "@/@types/Operation"; | 20 | import { Operation } from "@/@types/Operation"; |
21 | 21 | ||
22 | export default class IndexSearch { | 22 | export default class IndexSearch { |
23 | |||
24 | // Results of the search (by tags) | 23 | // Results of the search (by tags) |
25 | public static search(searchTags: Tag.Search[]): Gallery.Item[] { | 24 | public static search(searchTags: Tag.Search[]): Gallery.Item[] { |
26 | const byOperation = this.extractTagsByOperation(searchTags); | 25 | const byOperation = this.extractTagsByOperation(searchTags); |
diff --git a/viewer/src/services/ldzoom.ts b/viewer/src/services/ldzoom.ts index ddf57c0..22d4699 100644 --- a/viewer/src/services/ldzoom.ts +++ b/viewer/src/services/ldzoom.ts | |||
@@ -33,9 +33,11 @@ export default class LdZoom { | |||
33 | scaleFactor: number = 0.0; | 33 | scaleFactor: number = 0.0; |
34 | 34 | ||
35 | constructor( | 35 | constructor( |
36 | containerElement: HTMLDivElement, imageElement: HTMLImageElement, | 36 | containerElement: HTMLDivElement, |
37 | imageElement: HTMLImageElement, | ||
37 | pictureProperties: Gallery.PictureProperties, | 38 | pictureProperties: Gallery.PictureProperties, |
38 | maxScaleFactor: number, scrollZoomSpeed: number | 39 | maxScaleFactor: number, |
40 | scrollZoomSpeed: number | ||
39 | ) { | 41 | ) { |
40 | this.containerElement = containerElement; | 42 | this.containerElement = containerElement; |
41 | this.imageElement = imageElement; | 43 | this.imageElement = imageElement; |
diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts index a7e752c..5b0716d 100644 --- a/viewer/src/services/navigation.ts +++ b/viewer/src/services/navigation.ts | |||
@@ -20,6 +20,15 @@ | |||
20 | import { ItemType } from "@/@types/ItemType"; | 20 | import { ItemType } from "@/@types/ItemType"; |
21 | 21 | ||
22 | export default class Navigation { | 22 | export default class Navigation { |
23 | static readonly ICON_BY_TYPE: Record<ItemType, string> = { | ||
24 | directory: "folder", | ||
25 | picture: "image", | ||
26 | plaintext: "file-alt", | ||
27 | pdf: "file-pdf", | ||
28 | video: "file-video", | ||
29 | audio: "file-audio", | ||
30 | other: "file", | ||
31 | }; | ||
23 | 32 | ||
24 | // Searches for an item by path from a root item (navigation) | 33 | // Searches for an item by path from a root item (navigation) |
25 | public static searchCurrentItemPath(root: Gallery.Item, path: string): Gallery.Item[] { | 34 | public static searchCurrentItemPath(root: Gallery.Item, path: string): Gallery.Item[] { |
@@ -61,25 +70,14 @@ export default class Navigation { | |||
61 | .filter(child => Navigation.checkType(child, ItemType.DIRECTORY)) | 70 | .filter(child => Navigation.checkType(child, ItemType.DIRECTORY)) |
62 | .sort((a, b) => a.title.localeCompare(b.title)), | 71 | .sort((a, b) => a.title.localeCompare(b.title)), |
63 | 72 | ||
64 | ...items | 73 | ...items.filter(child => !Navigation.checkType(child, ItemType.DIRECTORY)), |
65 | .filter(child => !Navigation.checkType(child, ItemType.DIRECTORY)), | ||
66 | ]; | 74 | ]; |
67 | } | 75 | } |
68 | 76 | ||
69 | // Get the icon for an item | 77 | // Get the icon for an item |
70 | public static getIcon(item: Gallery.Item): string { | 78 | public static getIcon(item: Gallery.Item): string { |
71 | if (item.path.length <= 1) return "home"; | 79 | if (item.path.length <= 1) return "home"; |
72 | switch (item.properties.type) { | 80 | return Navigation.ICON_BY_TYPE[item.properties.type]; |
73 | case ItemType.PICTURE: return "image"; | ||
74 | case ItemType.PLAINTEXT: return "file-alt"; | ||
75 | case ItemType.PDF: return "file-pdf"; | ||
76 | case ItemType.VIDEO: return "file-video"; | ||
77 | case ItemType.AUDIO: return "file-audio"; | ||
78 | case ItemType.DIRECTORY: return "folder"; | ||
79 | case ItemType.OTHER: | ||
80 | default: | ||
81 | return "file"; | ||
82 | } | ||
83 | } | 81 | } |
84 | 82 | ||
85 | // Get the file name of an item, without its cache timestamp | 83 | // Get the file name of an item, without its cache timestamp |