forked from MapComplete/MapComplete
		
	Further work on infobox, styling everything, removing clutter
This commit is contained in:
		
							parent
							
								
									2acd53d150
								
							
						
					
					
						commit
						0b4016b65d
					
				
					 48 changed files with 1283 additions and 454 deletions
				
			
		
							
								
								
									
										58
									
								
								UI/MessageBoxHandler.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								UI/MessageBoxHandler.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,58 @@ | |||
| /** | ||||
|  * Keeps 'messagebox' and 'messageboxmobile' in sync, shows a 'close' button on the latter one | ||||
|  */ | ||||
| import {UIEventSource} from "./UIEventSource"; | ||||
| import {UIElement} from "./UIElement"; | ||||
| import {FixedUiElement} from "./FixedUiElement"; | ||||
| import {VariableUiElement} from "./VariableUIElement"; | ||||
| 
 | ||||
| export class MessageBoxHandler { | ||||
|     private _uielement: UIEventSource<() => UIElement>; | ||||
| 
 | ||||
|     constructor(uielement: UIEventSource<() => UIElement>, | ||||
|                 onClear: (() => void)) { | ||||
|         this._uielement = uielement; | ||||
|         this.listenTo(uielement); | ||||
|         this.update(); | ||||
| 
 | ||||
|         new VariableUiElement(new UIEventSource<string>("<h2>Naar de kaart > </h2>"), | ||||
|             (htmlElement) => { | ||||
|                 htmlElement.onclick = function () { | ||||
|                     uielement.setData(undefined); | ||||
|                     onClear(); | ||||
|                 } | ||||
|             } | ||||
|         ).AttachTo("to-the-map"); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     listenTo(uiEventSource: UIEventSource<any>) { | ||||
|         const self = this; | ||||
|         uiEventSource.addCallback(function () { | ||||
|             self.update(); | ||||
|         }) | ||||
|     } | ||||
| 
 | ||||
|     update() { | ||||
|         const wrapper = document.getElementById("messagesboxmobilewrapper"); | ||||
|         const gen = this._uielement.data; | ||||
|         console.log("Generator: ", gen); | ||||
|         if (gen === undefined) { | ||||
|             wrapper.classList.add("hidden"); | ||||
|             return; | ||||
|         } | ||||
|         wrapper.classList.remove("hidden"); | ||||
|         gen() | ||||
|             ?.HideOnEmpty(true) | ||||
|             ?.AttachTo("messagesbox") | ||||
|             ?.Activate(); | ||||
| 
 | ||||
|         gen() | ||||
|             ?.HideOnEmpty(true) | ||||
|             ?.AttachTo("messagesboxmobile") | ||||
|             ?.Activate(); | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue