{"size": 1187, "ext": "js", "max_stars_repo_path": "src/app/directives/dropzone.js", "max_stars_repo_name": "buiniyslavik/ProtonMail-WebClient", "max_stars_repo_stars_event_min_datetime": "2016-10-12T18:58:34.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-12T18:58:34.000Z", "max_issues_repo_path": "src/app/directives/dropzone.js", "max_issues_repo_name": "SevInf/Charge", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/app/directives/dropzone.js", "max_forks_repo_name": "SevInf/Charge", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.9512195122, "max_line_length": 112, "alphanum_fraction": 0.5113732098}
/**
 *
 * Usage:
 *
 * <div ng-app="app" ng-controller="SomeCtrl">
 *   <button dropzone="dropzoneConfig">
 *     Drag and drop files here or click to upload
 *   </button>
 * </div>
 */

angular.module('proton.dropzone', [])
    .directive('dropzone', function($parse) {
        return {
            scope: {
                dropzoneConfig: '&dropzone'
            },
            restrict: 'A',
            link: function(scope, element, attrs) {
                var config, dropzone;

                Dropzone.autoDiscover = false;

                config = (angular.isFunction(scope.dropzoneConfig))?scope.dropzoneConfig():scope.dropzoneConfig;

                // create a Dropzone for the element with the given options
                dropzone = new Dropzone(element[0], config.options);

                // bind the given event handlers
                angular.forEach(config.eventHandlers, function(handler, event) {
                    dropzone.on(event, handler);
                });

                // remove the dropzone instance
                scope.$on('$destroy', function() {
                    dropzone.disable();
                });
            }
        };
    });
