| 237 | |
| 238 | if (this.clickableElements.length) { |
| 239 | let setupHiddenFileInput = () => { |
| 240 | if (this.hiddenFileInput) { |
| 241 | this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput); |
| 242 | } |
| 243 | this.hiddenFileInput = document.createElement("input"); |
| 244 | this.hiddenFileInput.setAttribute("type", "file"); |
| 245 | if (this.options.maxFiles === null || this.options.maxFiles > 1) { |
| 246 | this.hiddenFileInput.setAttribute("multiple", "multiple"); |
| 247 | } |
| 248 | this.hiddenFileInput.className = "dz-hidden-input"; |
| 249 | |
| 250 | if (this.options.acceptedFiles !== null) { |
| 251 | this.hiddenFileInput.setAttribute( |
| 252 | "accept", |
| 253 | this.options.acceptedFiles |
| 254 | ); |
| 255 | } |
| 256 | if (this.options.capture !== null) { |
| 257 | this.hiddenFileInput.setAttribute("capture", this.options.capture); |
| 258 | } |
| 259 | |
| 260 | // Making sure that no one can "tab" into this field. |
| 261 | this.hiddenFileInput.setAttribute("tabindex", "-1"); |
| 262 | |
| 263 | // Not setting `display="none"` because some browsers don't accept clicks |
| 264 | // on elements that aren't displayed. |
| 265 | this.hiddenFileInput.style.visibility = "hidden"; |
| 266 | this.hiddenFileInput.style.position = "absolute"; |
| 267 | this.hiddenFileInput.style.top = "0"; |
| 268 | this.hiddenFileInput.style.left = "0"; |
| 269 | this.hiddenFileInput.style.height = "0"; |
| 270 | this.hiddenFileInput.style.width = "0"; |
| 271 | Dropzone.getElement( |
| 272 | this.options.hiddenInputContainer, |
| 273 | "hiddenInputContainer" |
| 274 | ).appendChild(this.hiddenFileInput); |
| 275 | this.hiddenFileInput.addEventListener("change", () => { |
| 276 | let { files } = this.hiddenFileInput; |
| 277 | if (files.length) { |
| 278 | for (let file of files) { |
| 279 | this.addFile(file); |
| 280 | } |
| 281 | } |
| 282 | this.emit("addedfiles", files); |
| 283 | setupHiddenFileInput(); |
| 284 | }); |
| 285 | }; |
| 286 | setupHiddenFileInput(); |
| 287 | } |
| 288 | |