
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@danielgindi/dropzone
Advanced tools
A simple lib for creating styleable dropzones for files
new DropZone(myElement)
to initialize (On any element, event the body
)drop-available
class to the dropzone element when a file is being dragged to the window. This is useful if you want to style your element to show that it is possible to drop the file on it.drop-over
class to the dropzone when the file is being dragged right over it.npm install jquery.dropzone
.Remember, you need to preventDefault()
on the 'drop' event, or the browser will use the default action on the dropped file, which is to download it or redirect to the file.
It's possible to instruct it to add an extra element inside the dropzone when a file is being dragged to the window,
which will also receive the drop-over
class.
This is useful for creating a dropzone on body
, and having a styled dropzone element float above everything else.
This is done by passing an append
option:
const myZone = new DropZone(document.body, { append: '<div class="dropzone-inner">' })
Now just listen to 'drop' event and take the file:
const myZone = new DropZone(document.body, {
// This is optional, to add an internal element that you can style
append: '<div class="full-drop-zone"><div class="description-wrapper"><div class="description">Release the file here...</div></div></div>',
// This is optional, to selectively allow dropping
allowDrop: (event) => {
return dataTransfer.items.length > 0 && dataTransfer.items[0].kind === 'file';
}
});
document.body.addEventListener('drop', function (event) {
event.preventDefault();
// Do something with the files
console.log(event.originalEvent.dataTransfer.files);
});
.full-drop-zone {
display: block;
position: absolute;
left: 20px;
top: 20px;
right: 20px;
bottom: 20px;
border: 2px dashed rgba(0,0,0,.3);
border-radius: 20px;
text-align: center;
z-index: 20;
background: rgba(255,255,255,0.7);
color: rgba(0,0,0,.3);
font-size: 20px;
&.drop-over {
border-color: rgba(0,0,0,0.5);
color: rgba(0,0,0,0.5);
}
.description-wrapper {
position: relative;
width: 100%;
height: 100%;
}
.description {
position: absolute;
left: 50%;
top: 50%;
max-width: 100%;
max-height: 100%;
text-align: center;
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
}
myZone.dropzone('destroy');
I have invested, and investing, a lot of time in this project. If you want to help, you could:
All the code here is under MIT license. Which means you could do virtually anything with the code. I will appreciate it very much if you keep an attribution where appropriate.
The MIT License (MIT)
Copyright (c) 2013 Daniel Cohen Gindi (danielgindi@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FAQs
A simple lib for creating styleable dropzones for files
The npm package @danielgindi/dropzone receives a total of 16 weekly downloads. As such, @danielgindi/dropzone popularity was classified as not popular.
We found that @danielgindi/dropzone demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.