-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Description
In github comment box, you have the option to drag/drop, paste or select file/images. This plugin lacks the "select" using file input.
I achieved this by directly modifying a dist js (jquery version) by adding the option bindedFileInput. This should trigger the upload when change event occurs on the input element. I'm not that familiar with grunt/npm and don't have the time implement a build so if your kind enough to add this bits of code for me that would be awesome.
init (jquery)
if (typeof options.bindedFileInput != 'undefined') {
var $input = typeof options.bindedFileInput === 'string' ? $(options.bindedFileInput) : options.bindedFileInput;
$input.bind('change', function(e) {
inlineattach.onBindedFileInputChange(e.originalEvent);
});
}inside class definition
/**
* called on bindedFileInput change event occured
* @param {Event} e
* @return {Boolean} if the event was handled
*/
inlineAttachment.prototype.onBindedFileInputChange = function(e) {
var result = false,
files = e.target.files || [];
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (this.isFileAllowed(file)) {
result = true;
this.onFileInserted(file);
this.uploadFile(file);
}
}
if (result) { e.preventDefault(); }
return result;
}add the option to defaults
/**
* Binded File Input element to trigger uploaded when changed
*/
bindedFileInput: undefined,great plugin btw.
Reactions are currently unavailable