Make metadata for files selected in Quick Reply available as data-type, data-height, data-width, and data-duration attributes on thumbnail.
This commit is contained in:
parent
7c030f9324
commit
150b03e6b8
@ -213,6 +213,8 @@ QR.post = class
|
|||||||
@showFileData()
|
@showFileData()
|
||||||
else
|
else
|
||||||
@updateFilename()
|
@updateFilename()
|
||||||
|
@rmMetadata()
|
||||||
|
@nodes.el.dataset.type = @file.type
|
||||||
@nodes.el.style.backgroundImage = ''
|
@nodes.el.style.backgroundImage = ''
|
||||||
unless @file.type in QR.mimeTypes
|
unless @file.type in QR.mimeTypes
|
||||||
@fileError 'Unsupported file type.'
|
@fileError 'Unsupported file type.'
|
||||||
@ -249,12 +251,17 @@ QR.post = class
|
|||||||
checkDimensions: (el) ->
|
checkDimensions: (el) ->
|
||||||
if el.tagName is 'IMG'
|
if el.tagName is 'IMG'
|
||||||
{height, width} = el
|
{height, width} = el
|
||||||
|
@nodes.el.dataset.height = height
|
||||||
|
@nodes.el.dataset.width = width
|
||||||
if height > QR.max_height or width > QR.max_width
|
if height > QR.max_height or width > QR.max_width
|
||||||
@fileError "Image too large (image: #{height}x#{width}px, max: #{QR.max_height}x#{QR.max_width}px)"
|
@fileError "Image too large (image: #{height}x#{width}px, max: #{QR.max_height}x#{QR.max_width}px)"
|
||||||
if height < QR.min_height or width < QR.min_width
|
if height < QR.min_height or width < QR.min_width
|
||||||
@fileError "Image too small (image: #{height}x#{width}px, min: #{QR.min_height}x#{QR.min_width}px)"
|
@fileError "Image too small (image: #{height}x#{width}px, min: #{QR.min_height}x#{QR.min_width}px)"
|
||||||
else
|
else
|
||||||
{videoHeight, videoWidth, duration} = el
|
{videoHeight, videoWidth, duration} = el
|
||||||
|
@nodes.el.dataset.height = videoHeight
|
||||||
|
@nodes.el.dataset.width = videoWidth
|
||||||
|
@nodes.el.dataset.duration = duration
|
||||||
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)
|
||||||
if videoHeight > max_height or videoWidth > max_width
|
if videoHeight > max_height or videoWidth > max_width
|
||||||
@ -310,6 +317,7 @@ QR.post = class
|
|||||||
delete @filesize
|
delete @filesize
|
||||||
@nodes.el.removeAttribute 'title'
|
@nodes.el.removeAttribute 'title'
|
||||||
QR.nodes.filename.removeAttribute 'title'
|
QR.nodes.filename.removeAttribute 'title'
|
||||||
|
@rmMetadata()
|
||||||
@nodes.el.style.backgroundImage = ''
|
@nodes.el.style.backgroundImage = ''
|
||||||
$.rmClass @nodes.el, 'has-file'
|
$.rmClass @nodes.el, 'has-file'
|
||||||
@showFileData()
|
@showFileData()
|
||||||
@ -317,6 +325,12 @@ QR.post = class
|
|||||||
@dismissErrors (error) -> $.hasClass error, 'file-error'
|
@dismissErrors (error) -> $.hasClass error, 'file-error'
|
||||||
@preventAutoPost()
|
@preventAutoPost()
|
||||||
|
|
||||||
|
rmMetadata: ->
|
||||||
|
for attr in ['type', 'height', 'width', 'duration']
|
||||||
|
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=1021289
|
||||||
|
@nodes.el.removeAttribute "data-#{attr}"
|
||||||
|
return
|
||||||
|
|
||||||
saveFilename: ->
|
saveFilename: ->
|
||||||
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
||||||
unless QR.validExtension.test @filename
|
unless QR.validExtension.test @filename
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user