| 
									
										
										
										
											2020-11-06 01:58:26 +01:00
										 |  |  | import Translations from "../i18n/Translations"; | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  | import BaseUIElement from "../BaseUIElement"; | 
					
						
							|  |  |  | import {UIEventSource} from "../../Logic/UIEventSource"; | 
					
						
							| 
									
										
										
										
											2020-11-05 12:28:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  | export default class Link extends BaseUIElement { | 
					
						
							|  |  |  |     private readonly _element: HTMLElement; | 
					
						
							| 
									
										
										
										
											2020-11-05 12:28:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |     constructor(embeddedShow: BaseUIElement | string, href: string | UIEventSource<string>, newTab: boolean = false) { | 
					
						
							| 
									
										
										
										
											2020-11-05 12:28:02 +01:00
										 |  |  |         super(); | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |         const _embeddedShow = Translations.W(embeddedShow); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const el = document.createElement("a") | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |         if(typeof href === "string"){ | 
					
						
							|  |  |  |             el.href = href | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |         }else{ | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |             href.addCallbackAndRun(href => { | 
					
						
							|  |  |  |                 el.href = href; | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |             }) | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-11-05 12:28:02 +01:00
										 |  |  |         if (newTab) { | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |             el.target = "_blank" | 
					
						
							| 
									
										
										
										
											2020-11-05 12:28:02 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |         el.appendChild(_embeddedShow.ConstructElement()) | 
					
						
							|  |  |  |         this._element = el | 
					
						
							| 
									
										
										
										
											2020-11-05 12:28:02 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |     protected InnerConstructElement(): HTMLElement { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return this._element; | 
					
						
							| 
									
										
										
										
											2020-11-05 12:28:02 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |