Fat arrows aren't needed here

This commit is contained in:
Zixaphir 2014-05-03 02:16:53 -07:00 committed by ccd0
parent ed0d768dfb
commit 77f65fd349

View File

@ -344,8 +344,9 @@ QR =
$.addClass QR.nodes.el, 'dump' unless files.length is 1
handleFile: (file, index, nfiles) ->
isSingle = nfiles is 1
if /^text\//.test file.type
if nfiles is 1
if isSingle
post = QR.selected
else if index isnt 0 or (post = QR.posts[QR.posts.length - 1]).com
post = new QR.post()
@ -353,20 +354,20 @@ QR =
return
unless file.type in QR.mimeTypes
QR.error "#{file.name}: Unsupported file type."
return unless nfiles is 1
return unless isSingle
max = QR.nodes.fileInput.max
max = Math.min(max, QR.max_size_video) if /^video\//.test file.type
if file.size > max
QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})."
return unless nfiles is 1
return unless isSingle
isNewPost = false
if nfiles is 1
if isSingle
post = QR.selected
else if index isnt 0 or (post = QR.posts[QR.posts.length - 1]).file
isNewPost = true
post = new QR.post()
QR.checkDimensions file, (pass) ->
if pass or nfiles is 1
if pass or isSingle
post.setFile file
else if isNewPost
post.rm()
@ -374,7 +375,7 @@ QR =
checkDimensions: (file, cb) ->
if /^image\//.test file.type
img = new Image()
img.onload = =>
img.onload = ->
{height, width} = img
pass = true
if height > QR.max_height or width > QR.max_width
@ -387,8 +388,8 @@ QR =
img.src = URL.createObjectURL file
else if /^video\//.test file.type
video = $.el 'video'
$.on video, 'loadedmetadata', =>
return unless cb?
$.on video, 'loadedmetadata', ->
return unless cb
{videoHeight, videoWidth, duration} = video
max_height = Math.min(QR.max_height, QR.max_height_video)
max_width = Math.min(QR.max_width, QR.max_width_video)
@ -412,8 +413,8 @@ QR =
<% } %>
cb pass
cb = null
$.on video, 'error', =>
return unless cb?
$.on video, 'error', ->
return unless cb
if file.type in QR.mimeTypes
# only report error here if we should have been able to play the video
# otherwise "unsupported type" should already have been shown