forked from MapComplete/MapComplete
		
	Fixed part of the special renderings
This commit is contained in:
		
							parent
							
								
									eec762b71f
								
							
						
					
					
						commit
						e480c97676
					
				
					 11 changed files with 156 additions and 147 deletions
				
			
		|  | @ -1,9 +1,10 @@ | |||
| import BaseUIElement from "../BaseUIElement"; | ||||
| import {InputElement} from "../Input/InputElement"; | ||||
| import {InputElement} from "./InputElement"; | ||||
| import {UIEventSource} from "../../Logic/UIEventSource"; | ||||
| 
 | ||||
| export default class FileSelectorButton extends InputElement<FileList> { | ||||
| 
 | ||||
|     private static _nextid; | ||||
|     IsSelected: UIEventSource<boolean>; | ||||
|     private readonly _value = new UIEventSource(undefined); | ||||
|     private readonly _label: BaseUIElement; | ||||
|  | @ -13,6 +14,8 @@ export default class FileSelectorButton extends InputElement<FileList> { | |||
|         super(); | ||||
|         this._label = label; | ||||
|         this._acceptType = acceptType; | ||||
|         this.SetClass("block cursor-pointer") | ||||
|         label.SetClass("cursor-pointer") | ||||
|     } | ||||
| 
 | ||||
|     GetValue(): UIEventSource<FileList> { | ||||
|  | @ -26,36 +29,37 @@ export default class FileSelectorButton extends InputElement<FileList> { | |||
|     protected InnerConstructElement(): HTMLElement { | ||||
|         const self = this; | ||||
|         const el = document.createElement("form") | ||||
|         { | ||||
|             const label = document.createElement("label") | ||||
|             label.appendChild(this._label.ConstructElement()) | ||||
|             el.appendChild(label) | ||||
|         } | ||||
|         { | ||||
|             const actualInputElement = document.createElement("input"); | ||||
|             actualInputElement.style.cssText = "display:none"; | ||||
|             actualInputElement.type = "file"; | ||||
|             actualInputElement.accept = this._acceptType; | ||||
|             actualInputElement.name = "picField"; | ||||
|             actualInputElement.multiple = true; | ||||
|         const label = document.createElement("label") | ||||
|         label.appendChild(this._label.ConstructElement()) | ||||
|         el.appendChild(label) | ||||
| 
 | ||||
|             actualInputElement.onchange = () => { | ||||
|                 if (actualInputElement.files !== null) { | ||||
|                     self._value.setData(actualInputElement.files) | ||||
|                 } | ||||
|         const actualInputElement = document.createElement("input"); | ||||
|         actualInputElement.style.cssText = "display:none"; | ||||
|         actualInputElement.type = "file"; | ||||
|         actualInputElement.accept = this._acceptType; | ||||
|         actualInputElement.name = "picField"; | ||||
|         actualInputElement.multiple = true; | ||||
|         actualInputElement.id = "fileselector" + FileSelectorButton._nextid; | ||||
|         FileSelectorButton._nextid++; | ||||
| 
 | ||||
|         label.htmlFor = actualInputElement.id; | ||||
| 
 | ||||
|         actualInputElement.onchange = () => { | ||||
|             if (actualInputElement.files !== null) { | ||||
|                 self._value.setData(actualInputElement.files) | ||||
|             } | ||||
| 
 | ||||
|             el.addEventListener('submit', e => { | ||||
|                 if (actualInputElement.files !== null) { | ||||
|                     self._value.setData(actualInputElement.files) | ||||
|                 } | ||||
|                 e.preventDefault() | ||||
|             }) | ||||
| 
 | ||||
|             el.appendChild(actualInputElement) | ||||
|         } | ||||
| 
 | ||||
|         return undefined; | ||||
|         el.addEventListener('submit', e => { | ||||
|             if (actualInputElement.files !== null) { | ||||
|                 self._value.setData(actualInputElement.files) | ||||
|             } | ||||
|             e.preventDefault() | ||||
|         }) | ||||
| 
 | ||||
|         el.appendChild(actualInputElement) | ||||
| 
 | ||||
|         return el; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue