Created
November 28, 2011 16:40
-
-
Save enriclluelles/1401020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uploads.setup = function (options) { | |
var defaults = { | |
runtimes: 'html5, flash, html4', | |
url: '/', | |
browse_button : 'pickfiles', | |
container : 'container', | |
max_file_size : '10mb', | |
filters : [ | |
{title : "Image files", extensions : "jpg,jpeg,gif,png"} | |
], | |
resize : {width : 320, height : 240, quality : 90}, | |
headers: { | |
'X-CSRF-Token': $('meta[name=csrf-token]').attr('content') | |
} | |
}; | |
settings = $.extend(defaults, options); | |
var uploader = new plupload.Uploader(settings); | |
uploader.init(); | |
uploader.bind('FilesAdded', function(up, files) { | |
uploader.start(); | |
}); | |
uploader.bind('FileUploaded', function(up, file, response) { | |
var presponse = $.parseJSON(response.response); | |
var view; | |
if (!presponse.error) { | |
view = Views.render('accommodation_picture_thumb', presponse); | |
$('#accommodation_pictures').append(view); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment