text: // Generated by CoffeeScript 1.10.0
  (function() {
    var $, async, electron, handle_files, hbs_render, modal, open_files_added_modal, prettysize, sharp;
  
    $ = require('jquery');
  
    hbs_render = require(__dirname + "/../javascripts/hbs_render");
  
    sharp = require('sharp');
  
    async = require('async');
  
    modal = null;
  
    prettysize = require('prettysize');
  
    electron = require('electron');
  
    handle_files = function(files) {
      var file, file_list, i, image_number, index, j, len, len1, line, ref;
      image_number = $('.image_number').html();
      index = image_number !== '' ? parseInt(image_number) : 0;
      $('.image_number').html(files.length);
      file_list = [];
      for (i = 0, len = files.length; i < len; i++) {
        file = files[i];
        file_list.push(file);
      }
      ref = file_list.reverse();
      for (j = 0, len1 = ref.length; j < len1; j++) {
        file = ref[j];
        line = hbs_render('file_row', {
          path: file.path,
          filesize: prettysize(file.size)
        });
        $('#container').prepend(line);
        modal.close();
      }
      new Notification(files.length + " image(s) added and ready to be processed!");
      $('#commands').show();
      return async.eachSeries(files, function(file, async_callback) {
        console.log(file);
        return sharp(file.path).limitInputPixels(2147483647).resize(null, 100).toFormat('png').toBuffer().then(function(output) {
          var image, img, path;
          image = output.toString('base64');
          path = file.path;
          img = $(".path-to-file:contains(" + path + ")").parent('.file-row').find('img');
          $(img[0]).prop('src', "data:image/png;base64," + image);
          return async_callback();
        });
      }, function() {});
    };
  
    open_files_added_modal = function(number) {
      $("#files-added-modal-number").html(number);
      modal = new Foundation.Reveal($('#files-added-modal'));
      return modal.open();
    };
  
    $(document).ready(function() {
      $(document).on('dragover,drop', function(e) {
        e.preventDefault();
        return false;
      });
      $('#dropzone').on('drop', function(e) {
        var files;
        e.preventDefault();
        console.log('dropped');
        files = e.originalEvent.dataTransfer.files;
        open_files_added_modal(files.length);
        handle_files(files);
        return $('#dropzone').removeClass('dragover');
      });
      $('#dropzone').on('dragover', function(e) {
        e.preventDefault();
        return false;
      });
      $('#dropzone').on('dragenter', function(e) {
        e.preventDefault();
        return $('#dropzone').addClass('dragover');
      });
      $('#dropzone').on('dragleave,dragend', function() {
        return false;
      });
      $('#file-select-trigger').on('click', function(e) {
        var input;
        e.preventDefault();
        input = $('#file-select-input');
        return input.click();
      });
      $('#file-select-input').on('change', function(e) {
        var files, input;
        input = $('#file-select-input');
        files = input[0].files;
        open_files_added_modal(files.length);
        return handle_files(files);
      });
      return $('#restart').on('click', function(e) {
        electron.remote.getCurrentWindow().reload();
        return e.preventDefault();
      });
    });
  
  }).call(this);
  