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