Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback_id is now fallback_input and added binded_input (binded trigger outside dropbox) #163

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions jquery.filedrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
jQuery.event.props.push("dataTransfer");

var default_opts = {
fallback_id: '',
fallback_input: null,
binded_input: null,
fallbackClick: true,
url: '',
refresh: 1000,
paramname: 'userfile',
Expand Down Expand Up @@ -70,27 +72,46 @@
global_progress = [],
doc_leave_timer, stop_loop = false,
files_count = 0,
files;
files,
binded_input,
fallback_input

$('#' + opts.fallback_id).css({
display: 'none',
width: 0,
height: 0
});
binded_input = typeof opts.binded_input === 'string' ? $('#' + opts.binded_input) : opts.binded_input;
fallback_input = typeof opts.fallback_input === 'string' ? $('#' + opts.fallback_input) : opts.fallback_input;

this.on('drop', drop).on('dragstart', opts.dragStart).on('dragenter', dragEnter).on('dragover', dragOver).on('dragleave', dragLeave);
$(document).on('drop', docDrop).on('dragenter', docEnter).on('dragover', docOver).on('dragleave', docLeave);

this.on('click', function(e){
$('#' + opts.fallback_id).trigger(e);
});

$('#' + opts.fallback_id).change(function(e) {
var trigger = function(e) {
opts.drop(e);
files = e.target.files;
files_count = files.length;
upload();
});
}

if (fallback_input) {
fallback_input.css({
display: 'none',
width: 0,
height: 0
});

if (opts.fallbackClick) {
this.on('click', function(e){
fallback_input.trigger(e);
});

$(fallback_input).change(function(e) {
trigger(e);
});
}
}

if (binded_input) {
$(binded_input).change(function(e) {
trigger(e);
});
}

function drop(e) {
if( opts.drop.call(this, e) === false ) return false;
Expand Down