Spree.prepareAttachmentUploader = -> uploadZone = document.getElementById('attachment-upload-zone') if !uploadZone return attachmentUploads = new (Backbone.Collection) progressZone = document.getElementById('progress-zone') variantId = document.querySelector('input[name="attachment[viewable_id]"]').value new (Spree.Views.Attachments.UploadZone)( el: uploadZone collection: attachmentUploads ) attachmentUploads.on 'add', (progressModel) -> progressModel.set variant_id: variantId progressView = new (Spree.Views.Images.UploadProgress)(model: progressModel) progressZone.appendChild progressView.render().el return return Spree.ready -> Spree.prepareAttachmentUploader() return