2020-07-20 13:30:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import {UIElement} from "../UIElement";
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:49:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import Translations from "../../UI/i18n/Translations";
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-17 17:23:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {UIEventSource} from "../../Logic/UIEventSource";
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-20 13:30:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-02 19:00:24 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export default class CheckBox extends UIElement{
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-29 15:05:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public readonly isEnabled: UIEventSource<boolean>;
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-12 23:15:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    private readonly _showEnabled:  UIElement;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    private readonly _showDisabled: UIElement;
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:01:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-24 01:12:57 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    constructor(showEnabled: string | UIElement, showDisabled: string | UIElement, data: UIEventSource<boolean> | boolean = false) {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 12:17:06 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        super(undefined);
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-29 15:05:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        this.isEnabled =
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-24 01:12:57 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            data instanceof UIEventSource ? data : new UIEventSource(data ?? false);
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-29 15:05:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        this.ListenTo(this.isEnabled);
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-12 23:15:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        this._showEnabled = Translations.W(showEnabled);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        this._showDisabled =Translations.W(showDisabled);
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 12:05:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const self = this;
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:01:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        this.onClick(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-29 15:05:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            self.isEnabled.setData(!self.isEnabled.data);
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:01:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-24 01:12:57 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-20 13:30:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:05:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    InnerRender(): string {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-29 15:05:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if (this.isEnabled.data) {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:49:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            return Translations.W(this._showEnabled).Render();
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:01:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        } else {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:49:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            return Translations.W(this._showDisabled).Render();
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-22 11:01:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-20 13:30:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-21 05:52:36 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-20 13:30:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |