<commit_before>;(function(Darkroom, fabric, window) {
  'use strict';

  var _this = null;

  Darkroom.plugins['dragndrop'] = Darkroom.Plugin.extend({
    defaults: {
      maxFileSize: (5 * 1024 * 1024),
      maxHeight:   720,
      minHeight:   300,
      maxWidth:    1270,
      minWidth:    400,
    },
    initialize: function initDarkroomDragnDropPlugin() {

      _this = this;

      var container = this.darkroom.container,
          darkroom  = this.darkroom,
          options   = this.options,
          canvas    = this.darkroom.canvas,
          image     = this.darkroom.image;

      container.addEventListener('dragover', function(event) {
        event.preventDefault();
      });

      window.webkitRequestFileSystem(TEMPORARY, options.maxFileSize, function(fs) {

        container.addEventListener('drop', function(event) {

          event.preventDefault();

          Array.prototype.forEach.call(event.dataTransfer.files, function(file) {

            fs.root.getFile(file.name, {create: true, exclusive: false}, function(fileEntry) {

              fabric.Image.fromURL(fileEntry.toURL(), function(img) {

                var height = Math.min(Math.max(options.minHeight, img.height), options.maxHeight),
                    width  = Math.min(Math.max(options.minWidth, img.width),   options.maxWidth);

                canvas.remove(image);
                canvas.setHeight(height);
                canvas.setWidth(width);

                img.set({
                  // options to make the image static
                  selectable: false,
                  evented: false,
                  lockMovementX: true,
                  lockMovementY: true,
                  lockRotation: true,
                  lockScalingX: true,
                  lockScalingY: true,
                  lockUniScaling: true,
                  hasControls: false,
                  hasBorders: false,
                  width: width,
                  height: height
                });
                canvas.add(img);

                darkroom.image = img;
                image          = img;
              });
            });
          });
        });
      });
    }
  });
})(Darkroom, fabric, window);
<commit_msg>add: drag and drop plugin now works in Firefox<commit_after>;(function(Darkroom, fabric, window) {
  'use strict';

  var _this = null,
      root  = null;

  var requestFileSystem = (window.webkitRequestFileSystem || window.requestFileSystem);

  var helpers = {

    getOptions: function(img) {

      var OPTS = [
        'lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY',
        'lockUniScaling', 'hasControls', 'hasBorders', 'selectable', 'evented'
      ];

      return OPTS.reduce(

        function(acc, opt) {

          acc[opt] = img.get('name');
          return acc;
        },
        {}
      );
    }
  };

  var eventListeners = {

    dragover: function(event) { event.preventDefault(); },

    drop: function(event) {

      var currentImage = _this.image,
          darkroom     = _this.darkroom,
          options      = _this.options,
          canvas       = _this.canvas;

      event.preventDefault();

      Array.prototype.forEach.call(event.dataTransfer.files, function(file) {

        root.getFile(file.name, {create: true, exclusive: false}, function(fileEntry) {

          fabric.Image.fromURL(window.URL.createObjectURL(file), function(img) {

            var height = Math.min(Math.max(options.minHeight, img.height), options.maxHeight),
                width  = Math.min(Math.max(options.minWidth, img.width),   options.maxWidth);

            canvas.remove(currentImage);
            canvas.setHeight(height);
            canvas.setWidth(width);

            img
              .set(helpers.getOptions(currentImage))
              .set({height: height, width: width});

            canvas.add(img);

            darkroom.image = img;
            currentImage   = img;
          });
        });
      });
    }
  };





  Darkroom.plugins['dragndrop'] = Darkroom.Plugin.extend({
    defaults: {
      maxFileSize: (5 * 1024 * 1024),
      maxHeight:   720,
      minHeight:   300,
      maxWidth:    1270,
      minWidth:    400,
    },
    initialize: function initDarkroomDragnDropPlugin() {

      _this = this;

      var container = this.darkroom.container,
          options   = this.options;

      this.darkroom = this.darkroom,
      this.canvas   = this.darkroom.canvas,
      this.image    = this.darkroom.image;

      container.addEventListener('dragover', eventListeners.dragover);

      requestFileSystem(TEMPORARY, options.maxFileSize, function(fs) {

        root = fs.root;
        container.addEventListener('drop', eventListeners.drop);
      });
    }
  });
})(Darkroom, fabric, window);

{'fraction_non_alphanumeric': 0.11748804325223539, 'fraction_numerical': 0.009149511332917446, 'mean_word_length': 1.8750747160789, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1670775', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1312, 'n_words': 248}