(function(){
    var app = window.app;
    var jsonReader = app('json-reader');
    var dragAndDrop = app('drag-and-drop', init);

    function cleanHover() {
        this.className = ''; 
        return false;
    }

    function init(holder, next) {
        holder.ondragover = function () { 
            this.className = 'hover'; 
            return false; 
        };

        holder.ondragleave = cleanHover;
        holder.ondragend = cleanHover;

        holder.ondrop = function (e) {
            this.className = '';
            e.preventDefault();

            var f = e.dataTransfer.files[0];
            var jsonReader = window.app('json-reader');
            jsonReader.read(f, function(json) {
                (json && next) && next(json);
            });
        };
    }

})();
