From 77f65fd349b40e5687e5d77fc8246cf962809ebd Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 3 May 2014 02:16:53 -0700 Subject: [PATCH] Fat arrows aren't needed here --- src/Posting/QR.coffee | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 8f2b9521d..4ea1219fb 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -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