{:uriI"file:///Users/tvd/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/solidus-710d2d8be942/backend/app/assets/javascripts/spree/backend/models/image_upload.js?type=application/javascript&pipeline=self&id=33dc3652fd3cef19f209acd6cc95c61a76fd74ddd1adfa6d538e09d596e8d4d9:ET:load_pathI"z/Users/tvd/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/solidus-710d2d8be942/backend/app/assets/javascripts;T: filenameI"/Users/tvd/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/solidus-710d2d8be942/backend/app/assets/javascripts/spree/backend/models/image_upload.js;T: nameI"&spree/backend/models/image_upload;T:logical_pathI".spree/backend/models/image_upload.self.js;T:content_typeI"application/javascript;T: sourceI"^Spree.Models.ImageUpload = Backbone.Model.extend({ initialize: function() { var file = this.get("file"); this.set({ filename: file.name, size: file.size ? (file.size/1024|0) + 'K' : '' }); }, defaults: function() { return { file: null, imgSrc: '', progress: 0, serverError: false, filename: '', size: '' } }, acceptedTypes: { 'image/png': true, 'image/jpeg': true, 'image/gif': true }, previewFile: function () { var file = this.get('file'), that = this; if (FileReader && this.acceptedTypes[file.type] === true) { var reader = new FileReader(); reader.onload = function (event) { that.set({imgSrc: event.target.result}); }; reader.readAsDataURL(file); } }, uploadFile: function () { var formData = new FormData(), that = this; formData.append('image[attachment]', this.get('file')); formData.append('image[viewable_id]', this.get('variant_id')); formData.append('upload_id', this.cid); // send the image to the server Spree.ajax({ url: window.location.pathname, type: "POST", dataType: 'script', data: formData, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType xhr: function () { var xhr = $.ajaxSettings.xhr(); if (xhr.upload) { xhr.upload.onprogress = function (event) { if (event.lengthComputable) { var complete = (event.loaded / event.total * 100 | 0); that.set({progress: complete}) } }; } return xhr; } }).done(function() { that.set({progress: 100}) }).error(function(jqXHR, textStatus, errorThrown) { that.set({serverError: true}); }); } }); ;T: metadata{ :dependencieso:Set: @hash} I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"file-digest:///Users/tvd/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/solidus-710d2d8be942/backend/app/assets/javascripts/spree/backend/models/image_upload.js;TTF: requiredo;;}F: stubbedo;;}F: linkso;;}F: charsetI" utf-8;F: digest"%hwz"5Y$$9, .6*|P: lengthi^:dependencies_digest"%IJkkP\jR asf0l:idI"E33dc3652fd3cef19f209acd6cc95c61a76fd74ddd1adfa6d538e09d596e8d4d9;F: mtimel+"[