Sha256: 2888924c28cbeb7585401b71d65231a58235416dd0cc87f310d47448f6927fdd

Contents?: true

Size: 894 Bytes

Versions: 149

Compression:

Stored size: 894 Bytes

Contents

Spree.Views.Images.UploadZone = Backbone.View.extend({
  events: {
    "dragover" : "onDragOver",
    "dragleave" : "onDragLeave",
    "drop" : "onDrop",
    'change input[type="file"]' : "onFileBrowserSelect"
  },

  upload: function(file) {
    var progressModel = new Spree.Models.ImageUpload({file: file});

    this.collection.add(progressModel);

    progressModel.previewFile();
    progressModel.uploadFile();
  },

  dragClass: 'with-images',

  onDragOver: function(e) {
    this.el.classList.add(this.dragClass);
    e.preventDefault();
  },

  onDragLeave: function() {
    this.el.classList.remove(this.dragClass);
  },

  onDrop: function(e) {
    this.el.classList.remove(this.dragClass);
    e.preventDefault();

    _.each(e.originalEvent.dataTransfer.files, this.upload, this);
  },

  onFileBrowserSelect: function(e) {
    _.each(e.target.files, this.upload, this);
  }
});

Version data entries

149 entries across 149 versions & 2 rubygems

Version Path
solidus_backend-4.4.2 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.4.1 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.4.0 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.3.4 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.2.4 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.1.5 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.3.3 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.3.2 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.1.4 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.3.1 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.3.0 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.2.3 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.1.3 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.0.4 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-3.4.6 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.0.3 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.1.2 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.2.2 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-3.4.5 app/assets/javascripts/spree/backend/views/images/upload_zone.js
solidus_backend-4.2.1 app/assets/javascripts/spree/backend/views/images/upload_zone.js