Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pure-upload

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-upload - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

76

index.js

@@ -71,5 +71,5 @@ function castFiles(fileList, status) {

this.fileInput.accept = this.options.accept;
this.fileInput.addEventListener("change", function (e) {
_this.putFilesToQueue(e.target.files);
});
var onChange = function (e) { return _this.onChange(e); };
this.fileInput.addEventListener("change", onChange);
this.unregisterOnChange = function () { return _this.fileInput.removeEventListener("onChange", onchange); };
if (this.options.multiple) {

@@ -79,27 +79,13 @@ this.fileInput.setAttribute("multiple", "");

if (this.options.clickable) {
this.targetElement.addEventListener("click", function (e) {
_this.fileInput.click();
});
var onClick = function () { return _this.onClick(); };
this.targetElement.addEventListener("click", onClick);
this.unregisterOnClick = function () { return _this.targetElement.removeEventListener("click", onClick); };
}
if (this.options.allowDragDrop) {
this.targetElement.addEventListener("dragover", function (e) {
var efct;
try {
efct = e.dataTransfer.effectAllowed;
}
catch (_error) { }
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
_this.stopEventPropagation(e);
});
this.targetElement.addEventListener("drop", function (e) {
if (!e.dataTransfer) {
return;
}
var files = e.dataTransfer.files;
if (files.length) {
var items = e.dataTransfer.files;
_this.putFilesToQueue(items);
}
_this.stopEventPropagation(e);
});
var onDrag = function (e) { return _this.onDrag(e); };
this.targetElement.addEventListener("dragover", onDrag);
this.unregisterOnDragOver = function () { return _this.targetElement.removeEventListener("dragover", onDrag); };
var onDrop = function (e) { return _this.onDrop(e); };
this.targetElement.addEventListener("drop", onDrop);
this.unregisterOnDrop = function () { return _this.targetElement.removeEventListener("drop", onDrop); };
}

@@ -109,2 +95,29 @@ // attach to body

};
UploadArea.prototype.onChange = function (e) {
this.putFilesToQueue(e.target.files);
};
UploadArea.prototype.onDrag = function (e) {
var efct;
try {
efct = e.dataTransfer.effectAllowed;
}
catch (_error) { }
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
this.stopEventPropagation(e);
};
UploadArea.prototype.onDrop = function (e) {
if (!e.dataTransfer) {
return;
}
var files = e.dataTransfer.files;
if (files.length) {
var items = e.dataTransfer.files;
this.putFilesToQueue(items);
}
this.stopEventPropagation(e);
};
UploadArea.prototype.onClick = function () {
this.fileInput.value = '';
this.fileInput.click();
};
UploadArea.prototype.stopEventPropagation = function (e) {

@@ -117,2 +130,12 @@ e.stopPropagation();

UploadArea.prototype.destroy = function () {
if (this.unregisterOnClick)
this.unregisterOnClick();
if (this.unregisterOnDrop)
this.unregisterOnDrop();
if (this.unregisterOnChange)
this.unregisterOnChange();
if (this.unregisterOnDragOver)
this.unregisterOnDragOver();
this.targetElement.removeEventListener("dragover", this.onDrag);
this.targetElement.removeEventListener("drop", this.onDrop);
document.body.removeChild(this.fileInput);

@@ -261,2 +284,3 @@ };

this.uploadAreas.push(uploadArea);
return uploadArea;
};

@@ -263,0 +287,0 @@ Uploader.prototype.unregisterArea = function (area) {

@@ -120,2 +120,7 @@ export function castFiles(fileList: File[]| Object, status?:IUploadStatus): IUploadFile[] {

private unregisterOnClick: () => void;
private unregisterOnDrop: () => void;
private unregisterOnDragOver: () => void;
private unregisterOnChange: () => void;
constructor(public targetElement: Element, public options: IUploadAreaOptions, public uploader: Uploader) {

@@ -129,6 +134,6 @@ this.uploadCore = getUploadCore(this.options, this.uploader.queue.callbacks);

uploadFiles.forEach((file: IUploadFile) => {
file.start = () => {
this.uploadCore.upload([file]);
file.start = () => { };
};
file.start = () => {
this.uploadCore.upload([file]);
file.start = () => { };
};
});

@@ -143,5 +148,7 @@ this.uploader.queue.addFiles(uploadFiles);

this.fileInput.accept = this.options.accept;
this.fileInput.addEventListener("change", (e: any) => {
this.putFilesToQueue(e.target.files);
});
var onChange = (e) => this.onChange(e);
this.fileInput.addEventListener("change", onChange);
this.unregisterOnChange = () => this.fileInput.removeEventListener("onChange", onchange)
if (this.options.multiple) {

@@ -151,27 +158,15 @@ this.fileInput.setAttribute("multiple", "");

if (this.options.clickable) {
this.targetElement.addEventListener("click", (e) => {
this.fileInput.click();
});
var onClick = () => this.onClick();
this.targetElement.addEventListener("click", onClick);
this.unregisterOnClick = () => this.targetElement.removeEventListener("click", onClick)
}
if (this.options.allowDragDrop) {
this.targetElement.addEventListener("dragover", (e: DragEvent) => {
var efct;
try {
efct = e.dataTransfer.effectAllowed;
} catch (_error) { }
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
this.stopEventPropagation(e);
});
var onDrag = (e) => this.onDrag(e);
this.targetElement.addEventListener("dragover", onDrag);
this.unregisterOnDragOver = () => this.targetElement.removeEventListener("dragover", onDrag);
this.targetElement.addEventListener("drop", (e: DragEvent) => {
if (!e.dataTransfer) {
return;
}
var files = e.dataTransfer.files;
if (files.length) {
var items = e.dataTransfer.files;
this.putFilesToQueue(items);
}
this.stopEventPropagation(e);
});
var onDrop = (e) => this.onDrop(e);
this.targetElement.addEventListener("drop", onDrop);
this.unregisterOnDrop = () => this.targetElement.removeEventListener("drop", onDrop);
// this.targetElement.addEventListener("dragenter", (e) => {

@@ -194,2 +189,32 @@ // console.log("dragenter");

private onChange(e): void {
this.putFilesToQueue(e.target.files);
}
private onDrag(e: DragEvent): void {
var efct;
try {
efct = e.dataTransfer.effectAllowed;
} catch (_error) { }
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
this.stopEventPropagation(e);
}
private onDrop(e: DragEvent): void {
if (!e.dataTransfer) {
return;
}
var files = e.dataTransfer.files;
if (files.length) {
var items = e.dataTransfer.files;
this.putFilesToQueue(items);
}
this.stopEventPropagation(e);
}
private onClick(): void {
this.fileInput.value = '';
this.fileInput.click();
}
private stopEventPropagation(e) {

@@ -202,3 +227,18 @@ e.stopPropagation();

destroy() : void {
destroy(): void {
if (this.unregisterOnClick)
this.unregisterOnClick();
if (this.unregisterOnDrop)
this.unregisterOnDrop();
if (this.unregisterOnChange)
this.unregisterOnChange();
if (this.unregisterOnDragOver)
this.unregisterOnDragOver();
this.targetElement.removeEventListener("dragover", this.onDrag);
this.targetElement.removeEventListener("drop", this.onDrop);
document.body.removeChild(this.fileInput);

@@ -362,5 +402,6 @@ }

registerArea(element: Element, options: IUploadAreaOptions) : void {
registerArea(element: Element, options: IUploadAreaOptions) : UploadArea {
var uploadArea = new UploadArea(element, options, this);
this.uploadAreas.push(uploadArea);
return uploadArea;
}

@@ -367,0 +408,0 @@

{
"name": "pure-upload",
"version": "1.0.2",
"version": "1.0.3",
"description": "The pure upload library without dependencies",

@@ -5,0 +5,0 @@ "contributors": [

@@ -74,5 +74,13 @@ declare module "pure-upload" {

private fileInput;
private unregisterOnClick;
private unregisterOnDrop;
private unregisterOnDragOver;
private unregisterOnChange;
constructor(targetElement: Element, options: IUploadAreaOptions, uploader: Uploader);
private putFilesToQueue(fileList);
private setupHiddenInput();
private onChange(e);
private onDrag(e);
private onDrop(e);
private onClick();
private stopEventPropagation(e);

@@ -106,3 +114,3 @@ destroy(): void;

setOptions(options: IUploadQueueOptions): void;
registerArea(element: Element, options: IUploadAreaOptions): void;
registerArea(element: Element, options: IUploadAreaOptions): UploadArea;
unregisterArea(area: UploadArea): void;

@@ -109,0 +117,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc