2020-06-23 22:35:19 +00:00
|
|
|
import {UIElement} from "../UIElement";
|
|
|
|
import {ImageSearcher} from "../../Logic/ImageSearcher";
|
|
|
|
import {SlideShow} from "../SlideShow";
|
2020-08-17 15:23:15 +00:00
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
2020-07-30 23:45:54 +00:00
|
|
|
import {
|
|
|
|
Dependencies,
|
|
|
|
TagDependantUIElement,
|
|
|
|
TagDependantUIElementConstructor
|
|
|
|
} from "../../Customizations/UIElementConstructor";
|
2020-08-29 23:13:18 +00:00
|
|
|
import Translation from "../i18n/Translation";
|
2020-09-13 01:29:44 +00:00
|
|
|
import Combine from "../Base/Combine";
|
|
|
|
import DeleteImage from "./DeleteImage";
|
2020-07-14 18:18:44 +00:00
|
|
|
|
2020-09-11 17:14:32 +00:00
|
|
|
export class ImageCarouselConstructor implements TagDependantUIElementConstructor {
|
2020-07-14 18:18:44 +00:00
|
|
|
IsKnown(properties: any): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
IsQuestioning(properties: any): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Priority(): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-30 23:45:54 +00:00
|
|
|
construct(dependencies: Dependencies): TagDependantUIElement {
|
|
|
|
return new ImageCarousel(dependencies.tags);
|
2020-07-14 18:18:44 +00:00
|
|
|
}
|
2020-07-20 15:30:02 +00:00
|
|
|
|
2020-08-29 23:13:18 +00:00
|
|
|
GetContent(tags: any): Translation {
|
|
|
|
return new Translation({"en":"Images without upload"});
|
2020-08-22 01:15:42 +00:00
|
|
|
}
|
|
|
|
|
2020-07-14 18:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class ImageCarousel extends TagDependantUIElement {
|
2020-06-23 22:35:19 +00:00
|
|
|
|
2020-06-27 22:06:23 +00:00
|
|
|
public readonly slideshow: SlideShow;
|
2020-06-23 22:35:19 +00:00
|
|
|
|
2020-09-12 22:53:24 +00:00
|
|
|
constructor(tags: UIEventSource<any>) {
|
2020-06-23 22:35:19 +00:00
|
|
|
super(tags);
|
2020-09-13 01:29:44 +00:00
|
|
|
const searcher : UIEventSource<{url:string}[]> = new ImageSearcher(tags);
|
|
|
|
const uiElements = searcher.map((imageURLS: {key: string, url:string}[]) => {
|
2020-06-23 22:35:19 +00:00
|
|
|
const uiElements: UIElement[] = [];
|
|
|
|
for (const url of imageURLS) {
|
2020-09-13 01:29:44 +00:00
|
|
|
let image = ImageSearcher.CreateImageElement(url.url);
|
|
|
|
if(url.key !== undefined){
|
|
|
|
image = new Combine([
|
|
|
|
image,
|
|
|
|
new DeleteImage(url.key, tags)
|
|
|
|
]);
|
|
|
|
}
|
2020-07-07 13:08:52 +00:00
|
|
|
uiElements.push(image);
|
2020-06-23 22:35:19 +00:00
|
|
|
}
|
|
|
|
return uiElements;
|
|
|
|
});
|
2020-07-07 13:08:52 +00:00
|
|
|
|
2020-09-12 22:53:24 +00:00
|
|
|
this.slideshow = new SlideShow(uiElements).HideOnEmpty(true);
|
2020-09-11 17:14:32 +00:00
|
|
|
|
2020-06-23 22:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
InnerRender(): string {
|
2020-09-12 22:53:24 +00:00
|
|
|
return this.slideshow.Render();
|
2020-07-07 13:08:52 +00:00
|
|
|
}
|
|
|
|
|
2020-07-14 18:18:44 +00:00
|
|
|
IsKnown(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
IsQuestioning(): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-24 23:07:02 +00:00
|
|
|
|
|
|
|
IsSkipped(): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-14 18:18:44 +00:00
|
|
|
|
|
|
|
Priority(): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-23 22:35:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|