npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dropify

v0.2.2

Published

Override your input files with style.

Downloads

10,686

Readme

Dropify

Dropify

Override your input files with style.

Demo here : http://jeremyfagis.github.io/dropify

Dependency

jQuery is required to do the magic.

Installation

Clone the project in your workspace

$ git clone [email protected]:JeremyFagis/dropify.git
$ cd dropify

Download packages

$ npm install

Compile assets

$ gulp build

Compilation

# All compilations and watch. You will have minified and not minified files.
$ gulp

# Dev compilation (watch & no-minification)
$ gulp --dev

# Prod compilation, you will have minified and not minified files
$ gulp build

# Prod compilation, you will have only minified files
$ gulp build --dev

NPM Package

www.npmjs.com/package/dropify

$ npm install dropify

Bower Package

$ bower install dropify

Usage

You have to include dist/js/dropify.js, dist/css/dropify.css and dist/fonts/* to your project, then you just have to init the jQuery plugin like that :

$('.dropify').dropify();

Options

  • defaultFile: If there is a default file on the input. You can use options when you use the plugin or directly data-default-file="url_of_your_file" on you DOM element (it's recommended).
<input type="file" class="dropify" data-default-file="url_of_your_file" />
  • height: Set the height of your dropify element. For exemple you want 300px height, you have to add the attribute data-height="300" on your DOM element.
<input type="file" class="dropify" data-height="300" />
  • maxFileSize: Set the max filesize of the uploaded document. An error will be display if the file size is bigger than the option. You can use unit like K, M and G.
<input type="file" class="dropify" data-max-file-size="3M" />
  • minWidth: Set the min width allowed. An error will be display if the width is smaller than the option.
<input type="file" class="dropify" data-min-width="400" />
  • maxWidth: Set the max width allowed. An error will be display if the width is bigger than the option.
<input type="file" class="dropify" data-max-width="1000" />
  • minHeight: Set the min height allowed. An error will be display if the height is smaller than the option.
<input type="file" class="dropify" data-min-height="400" />
  • maxHeight: Set the max height allowed. An error will be display if the height is bigger than the option.
<input type="file" class="dropify" data-max-height="1000" />
  • disabled: You can disable the input if you add the attr disabled="disabled".
<input type="file" class="dropify" disabled="disabled" />
  • showRemove: You can hide the remove button if you add the attr data-show-remove="false". Default: true.
<input type="file" class="dropify" data-show-remove="false" />
  • showLoader: You can hide the loader if you add the attr data-show-loader="false". Default: true.
<input type="file" class="dropify" data-show-loader="false" />
  • showErrors: You can hide errors if you add the attr data-show-loader="false". Default: true.
<input type="file" class="dropify" data-show-errors="true" />
  • errorsPosition: You can choose where you want to display the errors, overlay or outside. Default: overlay.
<input type="file" class="dropify" data-errors-position="outside" />
  • allowedFormats: You can allow/deny pictures formats. If you add the attr data-allowed-formats="portrait square" only portrait and square picture will be allowed. Default: ['portrait', 'square', 'landscape'].
<input type="file" class="dropify" data-allowed-formats="portrait square" />
  • allowedFileExtensions: You can allow only some file extensions. If you add the attr data-allowed-file-extensions="pdf png psd" only PDF, PNG and PSD files will be allowed. By default, everything is allowed. Default: ['*'].
<input type="file" class="dropify" data-allowed-file-extensions="pdf png psd" />
  • maxFileSizePreview: Set the max filesize of the previewed document (if it's an image). If the file size is bigger than the option, it will be only the file icon and disabled the preview. You can use unit like K, M and G.
<input type="file" class="dropify" data-max-file-size-preview="3M" />
  • messages: You can translate default messages. You just have to add an options array when you init the plugin. This messages will be replaced in the tpl option.
$('.dropify').dropify({
    messages: {
        'default': 'Drag and drop a file here or click',
        'replace': 'Drag and drop or click to replace',
        'remove':  'Remove',
        'error':   'Ooops, something wrong happended.'
    }
});
  • error: You can translate default errors messages. You just have to add an options array when you init the plugin. {{ value }} text will be replaced by the option.
$('.dropify').dropify({
    error: {
        'fileSize': 'The file size is too big ({{ value }} max).',
        'minWidth': 'The image width is too small ({{ value }}}px min).',
        'maxWidth': 'The image width is too big ({{ value }}}px max).',
        'minHeight': 'The image height is too small ({{ value }}}px min).',
        'maxHeight': 'The image height is too big ({{ value }}px max).',
        'imageFormat': 'The image format is not allowed ({{ value }} only).'
    }
});
  • tpl: You can update default template. You just have to add an options array when you init the plugin.
$('.dropify').dropify({
    tpl: {
        wrap:            '<div class="dropify-wrapper"></div>',
        loader:          '<div class="dropify-loader"></div>',
        message:         '<div class="dropify-message"><span class="file-icon" /> <p>{{ default }}</p></div>',
        preview:         '<div class="dropify-preview"><span class="dropify-render"></span><div class="dropify-infos"><div class="dropify-infos-inner"><p class="dropify-infos-message">{{ replace }}</p></div></div></div>',
        filename:        '<p class="dropify-filename"><span class="file-icon"></span> <span class="dropify-filename-inner"></span></p>',
        clearButton:     '<button type="button" class="dropify-clear">{{ remove }}</button>',
        errorLine:       '<p class="dropify-error">{{ error }}</p>',
        errorsContainer: '<div class="dropify-errors-container"><ul></ul></div>'
    }
});

Events

  • dropify.beforeClear: This event is called when you click on the "remove" button, just before clearing the Dropify. You can access to all the Dropify object properties using element.xxxx. See how to use it.
var drEvent = $('.dropify').dropify();

drEvent.on('dropify.beforeClear', function(event, element){
    return confirm("Do you really want to delete \"" + element.filename + "\" ?");
});
  • dropify.afterClear: This event is called after the Dropify is clear. You can access to all the Dropify object properties using element.xxxx. See how to use it.
var drEvent = $('.dropify').dropify();

drEvent.on('dropify.afterClear', function(event, element){
    alert('File deleted');
});
  • dropify.errors: This event is called when there is one or more error during process. See how to use it.
var drEvent = $('.dropify').dropify();

drEvent.on('dropify.errors', function(event, element){
    alert('Has Errors!');
});
  • dropify.error.xxxxx: In addition to the event dropify.errors:, you can bind errors events one by one. See how to use it.
var drEvent = $('.dropify').dropify();

drEvent.on('dropify.error.fileSize', function(event, element){
    alert('Filesize error message!');
});
drEvent.on('dropify.error.minWidth', function(event, element){
    alert('Min width error message!');
});
drEvent.on('dropify.error.maxWidth', function(event, element){
    alert('Max width error message!');
});
drEvent.on('dropify.error.minHeight', function(event, element){
    alert('Min height error message!');
});
drEvent.on('dropify.error.maxHeight', function(event, element){
    alert('Max height error message!');
});
drEvent.on('dropify.error.imageFormat', function(event, element){
    alert('Image format error message!');
});