{"size": 2702, "ext": "js", "max_stars_repo_path": "src/dropzone.js", "max_stars_repo_name": "skylark-domx/skylark-domx-files", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/dropzone.js", "max_issues_repo_name": "skylark-domx/skylark-domx-files", "max_issues_repo_issues_event_min_datetime": "2020-07-20T15:43:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-11T08:09:45.000Z", "max_forks_repo_path": "dist/uncompressed/skylark-domx-files/dropzone.js", "max_forks_repo_name": "skylark-domx/skylark-domx-files", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 34.2025316456, "max_line_length": 80, "alphanum_fraction": 0.4581791266}
  define([
    "skylark-langx/arrays",
    "skylark-langx/deferred",
    "skylark-domx-styler",
    "skylark-domx-eventer",
    "skylark-domx-velm",
    "skylark-domx-query",   
    "skylark-io-diskfs/webentry",   
    "./files"
],function(arrays,Deferred, styler, eventer, velm, $, webentry, files){  /*
     * Make the specified element to could accept HTML5 file drag and drop.
     * @param {HTMLElement} elm
     * @param {PlainObject} params
     */
    function dropzone(elm, params) {
        params = params || {};
        var hoverClass = params.hoverClass || "hover",
            droppedCallback = params.dropped;

        var enterdCount = 0;
        eventer.on(elm, "dragenter", function(e) {
            if (e.dataTransfer && e.dataTransfer.types.indexOf("Files") > -1) {
                eventer.stop(e);
                enterdCount++;
                styler.addClass(elm, hoverClass)
            }
        });

        eventer.on(elm, "dragover", function(e) {
            if (e.dataTransfer && e.dataTransfer.types.indexOf("Files") > -1) {
                eventer.stop(e);
            }
        });

        eventer.on(elm, "dragleave", function(e) {
            if (e.dataTransfer && e.dataTransfer.types.indexOf("Files") > -1) {
                enterdCount--
                if (enterdCount == 0) {
                    styler.removeClass(elm, hoverClass);
                }
            }
        });

        eventer.on(elm, "drop", function(e) {
            if (e.dataTransfer && e.dataTransfer.types.indexOf("Files") > -1) {
                styler.removeClass(elm, hoverClass)
                eventer.stop(e);
                if (droppedCallback) {
                    var items = e.dataTransfer.items;
                    if (items && items.length && (items[0].webkitGetAsEntry ||
                            items[0].getAsEntry)) {
                        webentry.all(
                            arrays.map(items, function(item) {
                                if (item.webkitGetAsEntry) {
                                    return item.webkitGetAsEntry();
                                }
                                return item.getAsEntry();
                            })
                        ).then(droppedCallback);
                    } else {
                        droppedCallback(e.dataTransfer.files);
                    }
                }
            }
        });

        return this;
    }
    files.dropzone = dropzone;

    velm.delegate([
        "dropzone"
    ],files);


    $.fn.dropzone = $.wraps.wrapper_every_act(files.dropzone, files);

    return dropzone;
});