diff options
Diffstat (limited to 'public/assets/js/lib/views/UploadView.js')
| -rw-r--r-- | public/assets/js/lib/views/UploadView.js | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/public/assets/js/lib/views/UploadView.js b/public/assets/js/lib/views/UploadView.js index 89ebac4..5f51324 100644 --- a/public/assets/js/lib/views/UploadView.js +++ b/public/assets/js/lib/views/UploadView.js @@ -1,14 +1,11 @@ -var WebcamView = View.extend({ +var UploadView = View.extend({ - el: "#photobooth", - events: { - "change #upload-btn input": "handleFileSelect", + "change input": "handleFileSelect", }, initialize: function(){ - this.$input = this.$('#file') - this.$snapBtn = this.$("#snap-btn") + this.$input = this.$('input') }, loaded: false, @@ -26,36 +23,21 @@ var WebcamView = View.extend({ var files = e.dataTransfer ? e.dataTransfer.files : e.target.files var file = files[0] + if (! file) return if ( ! file.type.match('image.*')) return - // this.upload(file) - var img = new Image - img.onload = function() { - var w, h - var ratio = img.naturalWidth / img.naturalHeight - if (ratio >= 4/3) { - h = 480 - w = 480 * ratio - } - else { - w = 640 - h = 640 / ratio - } - ctx.drawImage(img, 0, 0, w, h) - }.bind(this) - img.src = URL.createObjectURL(file) + + app.views.home.PhotoView.load( URL.createObjectURL(file) ) }, - upload: function(file){ - var _csrf = $("meta[name=_csrf]").attr("value") + upload: function(data){ var fd = new FormData() - fd.append('image', file) + fd.append('image', data) var request = $.ajax({ - url: "/irc/image?_csrf=" + _csrf, + url: "/_irc/image", type: "post", - data: fd, - dataType: "json", + data: data, processData: false, contentType: false, }) |
