File: src/components/UI.ts

Recommend this page to a friend!
  Classes of Dom Hastings   JS Webdav Client   src/components/UI.ts   Download  
File: src/components/UI.ts
Role: Class source
Content type: text/plain
Description: Class source
Class: JS Webdav Client
Access files of a Webdav server
Author: By
Last change:
Date: 7 months ago
Size: 1,168 bytes


Class file image Download
import supportsEvent, { supportsEvents } from '../lib/supportsEvent'; import AbstractUI from '../lib/AbstractUI'; import handleFileUpload from '../lib/handleFileUpload'; export class UI extends AbstractUI { protected bindEvents(): void { const isTouch = supportsEvent('touchstart'), supportsDragDrop = supportsEvents('dragstart', 'drop'); // DOM events if (isTouch) { this.addClass('is-touch'); } if (!supportsDragDrop) { this.addClass('no-drag-drop'); } if (supportsDragDrop) { this.onEach(['dragenter', 'dragover'], (event: DragEvent): void => { event.preventDefault(); event.stopPropagation(); this.addClass('active'); }); this.onEach(['dragleave', 'drop'], (event: DragEvent): void => { event.preventDefault(); event.stopPropagation(); this.removeClass('active'); }); this.on('drop', async (event: DragEvent): Promise<void> => { const { files } = event.dataTransfer; for (const file of files) { await handleFileUpload(this.dav(), this.state(), file); } }); } } } export default UI;