Valums-File-Uploader / file-uploader

Multiple file upload plugin for HTML forms. User-friendly progress-bar + uploads via drag-and-drop. Coded in Javascript + AJAX, not Flash. Server-side PHP, Java, & ColdFusion examples included.
http://valums-file-uploader.github.com/file-uploader/
Other
320 stars 141 forks source link

Allow a hook in _onInputChange #54

Closed reeteshranjan closed 9 years ago

reeteshranjan commented 9 years ago

There was a need of controlling number of images that can be uploaded, and the logic needed to take number of images selected using the file input as well as application state of existing number of images. After studying the logic, it appeared that the _onInputChange event handler is the best place for calling an application-provided hook/callback like onComplete and others.

Changes are as follows: 1 In _onInputChange, proceed as usual if application specific this._options.onInputChange is not provided 2 If this._options.onInputChange is provided, call it as this._options.onInputChange(input) and expect a boolean return value 3 If the return value is true proceed with usual flow of uploading, otherwise do not.

How users are impacted/can use this:

1 Existing client applications are not impacted 2 To use this hook, add the onInputChange option to the options provided to create the uploader object as follows:

onInputChange: function(input) {
    // .. your app logic
    if(...) {
        return(true);
    } else {
        return(false);
    }
}
reeteshranjan commented 9 years ago

Thanks!