| 
									
										
										
										
											2020-10-14 12:15:09 +02:00
										 |  |  | import {SlideShow} from "./SlideShow"; | 
					
						
							| 
									
										
										
										
											2020-08-17 17:23:15 +02:00
										 |  |  | import {UIEventSource} from "../../Logic/UIEventSource"; | 
					
						
							| 
									
										
										
										
											2020-09-13 03:29:44 +02:00
										 |  |  | import Combine from "../Base/Combine"; | 
					
						
							|  |  |  | import DeleteImage from "./DeleteImage"; | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  | import {AttributedImage} from "./AttributedImage"; | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  | import BaseUIElement from "../BaseUIElement"; | 
					
						
							|  |  |  | import Img from "../Base/Img"; | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  | import Toggle from "../Input/Toggle"; | 
					
						
							| 
									
										
										
										
											2021-06-22 14:21:32 +02:00
										 |  |  | import {Wikimedia} from "../../Logic/ImageProviders/Wikimedia"; | 
					
						
							|  |  |  | import {Imgur} from "../../Logic/ImageProviders/Imgur"; | 
					
						
							|  |  |  | import {Mapillary} from "../../Logic/ImageProviders/Mapillary"; | 
					
						
							| 
									
										
										
										
											2020-07-14 20:18:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  | export class ImageCarousel extends Toggle { | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  |     constructor(images: UIEventSource<{ key: string, url: string }[]>, tags: UIEventSource<any>) { | 
					
						
							|  |  |  |         const uiElements = images.map((imageURLS: { key: string, url: string }[]) => { | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  |             const uiElements: BaseUIElement[] = []; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             for (const url of imageURLS) { | 
					
						
							| 
									
										
										
										
											2021-01-29 03:23:53 +01:00
										 |  |  |                 let image = ImageCarousel.CreateImageElement(url.url) | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  |                 if (url.key !== undefined) { | 
					
						
							| 
									
										
										
										
											2020-09-13 03:29:44 +02:00
										 |  |  |                     image = new Combine([ | 
					
						
							|  |  |  |                         image, | 
					
						
							| 
									
										
										
										
											2021-02-06 00:05:38 +01:00
										 |  |  |                         new DeleteImage(url.key, tags).SetClass("delete-image-marker absolute top-0 left-0 pl-3") | 
					
						
							|  |  |  |                     ]).SetClass("relative"); | 
					
						
							| 
									
										
										
										
											2020-09-13 03:29:44 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  |                 image | 
					
						
							|  |  |  |                     .SetClass("w-full block") | 
					
						
							|  |  |  |                     .SetStyle("min-width: 50px; background: grey;") | 
					
						
							| 
									
										
										
										
											2020-07-07 15:08:52 +02:00
										 |  |  |                 uiElements.push(image); | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             return uiElements; | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-07-07 15:08:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  |         super( | 
					
						
							|  |  |  |             new SlideShow(uiElements).SetClass("w-full"), | 
					
						
							|  |  |  |             undefined, | 
					
						
							|  |  |  |             uiElements.map(els => els.length > 0) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2021-02-06 00:05:38 +01:00
										 |  |  |         this.SetClass("block w-full"); | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /*** | 
					
						
							|  |  |  |      * Creates either a 'simpleimage' or a 'wikimediaimage' based on the string | 
					
						
							|  |  |  |      * @param url | 
					
						
							|  |  |  |      * @constructor | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  |     private static CreateImageElement(url: string): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         // @ts-ignore
 | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |         let attrSource : ImageAttributionSource = undefined; | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         if (url.startsWith("File:")) { | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |             attrSource = Wikimedia.singleton | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         } else if (url.toLowerCase().startsWith("https://commons.wikimedia.org/wiki/")) { | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |             attrSource = Wikimedia.singleton; | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         } else if (url.toLowerCase().startsWith("https://i.imgur.com/")) { | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |             attrSource = Imgur.singleton | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         } else if (url.toLowerCase().startsWith("https://www.mapillary.com/map/im/")) { | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |             attrSource = Mapillary.singleton | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  |             return new Img(url); | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |          | 
					
						
							|  |  |  |         return new AttributedImage(url, attrSource) | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | } |