.webm #1533
This commit is contained in:
parent
92ac7893d3
commit
0bc93400c1
@ -1,3 +1,5 @@
|
|||||||
|
- Add support for .webm files.
|
||||||
|
|
||||||
### 3.19.5 - *2014-04-03*
|
### 3.19.5 - *2014-04-03*
|
||||||
|
|
||||||
- Fix captcha submission:<br>
|
- Fix captcha submission:<br>
|
||||||
|
|||||||
@ -146,7 +146,8 @@ Filter =
|
|||||||
return post.file.name
|
return post.file.name
|
||||||
false
|
false
|
||||||
dimensions: (post) ->
|
dimensions: (post) ->
|
||||||
if post.file and post.file.isImage
|
{file} = post
|
||||||
|
if file and (file.isImage or file.isVideo)
|
||||||
return post.file.dimensions
|
return post.file.dimensions
|
||||||
false
|
false
|
||||||
filesize: (post) ->
|
filesize: (post) ->
|
||||||
|
|||||||
@ -7,8 +7,9 @@ Build =
|
|||||||
# OPs have a +10 characters threshold.
|
# OPs have a +10 characters threshold.
|
||||||
# The file extension is not taken into account.
|
# The file extension is not taken into account.
|
||||||
threshold = if isReply then 30 else 40
|
threshold = if isReply then 30 else 40
|
||||||
if filename.length - 4 > threshold
|
ext = filename.match(/\.[^.]+$/)[0]
|
||||||
"#{filename[...threshold - 5]}(...).#{filename[-3..]}"
|
if filename.length - ext.length > threshold
|
||||||
|
"#{filename[...threshold - 5]}(...)#{ext}"
|
||||||
else
|
else
|
||||||
filename
|
filename
|
||||||
thumbRotate: do ->
|
thumbRotate: do ->
|
||||||
|
|||||||
@ -113,7 +113,7 @@ class Post
|
|||||||
|
|
||||||
parseFile: (that) ->
|
parseFile: (that) ->
|
||||||
return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl
|
return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl
|
||||||
# Supports JPG/PNG/GIF/PDF.
|
# Supports JPG/PNG/GIF/WEBM/PDF.
|
||||||
# Flash files are not supported.
|
# Flash files are not supported.
|
||||||
anchor = thumb.parentNode
|
anchor = thumb.parentNode
|
||||||
fileText = fileEl.firstElementChild
|
fileText = fileEl.firstElementChild
|
||||||
@ -144,7 +144,9 @@ class Post
|
|||||||
# http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data
|
# http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data
|
||||||
@file.name = @file.name.replace /%22/g, '"'
|
@file.name = @file.name.replace /%22/g, '"'
|
||||||
<% } %>
|
<% } %>
|
||||||
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
|
@file.isImage = /(jpg|png|gif)$/i.test @file.name
|
||||||
|
@file.isVideo = /webm$/i.test @file.name
|
||||||
|
if @file.isImage or @file.isVideo
|
||||||
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]
|
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]
|
||||||
|
|
||||||
cleanup: (root, post) ->
|
cleanup: (root, post) ->
|
||||||
|
|||||||
@ -304,6 +304,7 @@ Settings =
|
|||||||
sizeInBytes: 276 * 1024
|
sizeInBytes: 276 * 1024
|
||||||
dimensions: '1280x720'
|
dimensions: '1280x720'
|
||||||
isImage: true
|
isImage: true
|
||||||
|
isVideo: false
|
||||||
isSpoiler: true
|
isSpoiler: true
|
||||||
funk = FileInfo.createFunc @value
|
funk = FileInfo.createFunc @value
|
||||||
@nextElementSibling.innerHTML = funk FileInfo, data
|
@nextElementSibling.innerHTML = funk FileInfo, data
|
||||||
|
|||||||
@ -32,4 +32,3 @@ AutoGIF =
|
|||||||
else
|
else
|
||||||
thumb.src = URL
|
thumb.src = URL
|
||||||
gif.src = URL
|
gif.src = URL
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ ImageExpand =
|
|||||||
name: 'Image Expansion'
|
name: 'Image Expansion'
|
||||||
cb: @node
|
cb: @node
|
||||||
node: ->
|
node: ->
|
||||||
return unless @file?.isImage
|
return unless @file and (@file.isImage or @file.isVideo)
|
||||||
{thumb} = @file
|
{thumb} = @file
|
||||||
$.on thumb.parentNode, 'click', ImageExpand.cb.toggle
|
$.on thumb.parentNode, 'click', ImageExpand.cb.toggle
|
||||||
if @isClone and $.hasClass thumb, 'expanding'
|
if @isClone and $.hasClass thumb, 'expanding'
|
||||||
@ -42,7 +42,7 @@ ImageExpand =
|
|||||||
for ID, post of g.posts
|
for ID, post of g.posts
|
||||||
for post in [post].concat post.clones
|
for post in [post].concat post.clones
|
||||||
{file} = post
|
{file} = post
|
||||||
continue unless file and file.isImage and doc.contains post.nodes.root
|
continue unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root
|
||||||
if ImageExpand.on and !post.isHidden and
|
if ImageExpand.on and !post.isHidden and
|
||||||
(!Conf['Expand spoilers'] and file.isSpoiler or
|
(!Conf['Expand spoilers'] and file.isSpoiler or
|
||||||
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
|
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
|
||||||
@ -72,6 +72,7 @@ ImageExpand =
|
|||||||
$.rmClass post.nodes.root, 'expanded-image'
|
$.rmClass post.nodes.root, 'expanded-image'
|
||||||
$.rmClass post.file.thumb, 'expanding'
|
$.rmClass post.file.thumb, 'expanding'
|
||||||
post.file.isExpanded = false
|
post.file.isExpanded = false
|
||||||
|
post.file.fullImage.pause() if post.file.isVideo
|
||||||
|
|
||||||
expand: (post, src) ->
|
expand: (post, src) ->
|
||||||
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
||||||
@ -80,21 +81,29 @@ ImageExpand =
|
|||||||
$.addClass thumb, 'expanding'
|
$.addClass thumb, 'expanding'
|
||||||
if post.file.fullImage
|
if post.file.fullImage
|
||||||
# Expand already-loaded/ing picture.
|
# Expand already-loaded/ing picture.
|
||||||
$.asap (-> post.file.fullImage.naturalHeight), ->
|
$.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), ->
|
||||||
ImageExpand.completeExpand post
|
ImageExpand.completeExpand post
|
||||||
return
|
return
|
||||||
post.file.fullImage = img = $.el 'img',
|
file = if post.file.isImage
|
||||||
className: 'full-image'
|
$.el 'img',
|
||||||
src: src or post.file.URL
|
className: 'full-image'
|
||||||
$.on img, 'error', ImageExpand.error
|
src: src or post.file.URL
|
||||||
$.asap (-> post.file.fullImage.naturalHeight), ->
|
else
|
||||||
|
$.el 'video',
|
||||||
|
className: 'full-image'
|
||||||
|
src: src or post.file.URL
|
||||||
|
loop: true
|
||||||
|
post.file.fullImage = file
|
||||||
|
$.on file, 'error', ImageExpand.error
|
||||||
|
$.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), ->
|
||||||
ImageExpand.completeExpand post
|
ImageExpand.completeExpand post
|
||||||
$.after thumb, img
|
$.after thumb, file
|
||||||
|
|
||||||
completeExpand: (post) ->
|
completeExpand: (post) ->
|
||||||
{thumb} = post.file
|
{thumb} = post.file
|
||||||
return unless $.hasClass thumb, 'expanding' # contracted before the image loaded
|
return unless $.hasClass thumb, 'expanding' # contracted before the image loaded
|
||||||
post.file.isExpanded = true
|
post.file.isExpanded = true
|
||||||
|
post.file.fullImage.play() if post.file.isVideo
|
||||||
unless post.nodes.root.parentNode
|
unless post.nodes.root.parentNode
|
||||||
# Image might start/finish loading before the post is inserted.
|
# Image might start/finish loading before the post is inserted.
|
||||||
# Don't scroll when it's expanded in a QP for example.
|
# Don't scroll when it's expanded in a QP for example.
|
||||||
|
|||||||
@ -9,19 +9,26 @@ ImageHover =
|
|||||||
name: 'Image Hover'
|
name: 'Image Hover'
|
||||||
cb: @catalogNode
|
cb: @catalogNode
|
||||||
node: ->
|
node: ->
|
||||||
return unless @file?.isImage
|
return unless @file and (@file.isImage or @file.isVideo)
|
||||||
$.on @file.thumb, 'mouseover', ImageHover.mouseover
|
$.on @file.thumb, 'mouseover', ImageHover.mouseover
|
||||||
catalogNode: ->
|
catalogNode: ->
|
||||||
return unless @thread.OP.file?.isImage
|
return unless @thread.OP.file and (@thread.OP.file.isImage @thread.OP.file.isVideo)
|
||||||
$.on @nodes.thumb, 'mouseover', ImageHover.mouseover
|
$.on @nodes.thumb, 'mouseover', ImageHover.mouseover
|
||||||
mouseover: (e) ->
|
mouseover: (e) ->
|
||||||
post = if $.hasClass @, 'thumb'
|
post = if $.hasClass @, 'thumb'
|
||||||
g.posts[@parentNode.dataset.fullID]
|
g.posts[@parentNode.dataset.fullID]
|
||||||
else
|
else
|
||||||
Get.postFromNode @
|
Get.postFromNode @
|
||||||
el = $.el 'img',
|
el = if post.file.isImage
|
||||||
id: 'ihover'
|
$.el 'img',
|
||||||
src: post.file.URL
|
id: 'ihover'
|
||||||
|
src: post.file.URL
|
||||||
|
else
|
||||||
|
$.el 'video',
|
||||||
|
id: 'ihover'
|
||||||
|
src: post.file.URL
|
||||||
|
autoplay: true
|
||||||
|
loop: true
|
||||||
el.dataset.fullID = post.fullID
|
el.dataset.fullID = post.fullID
|
||||||
$.add d.body, el
|
$.add d.body, el
|
||||||
UI.hover
|
UI.hover
|
||||||
@ -29,7 +36,7 @@ ImageHover =
|
|||||||
el: el
|
el: el
|
||||||
latestEvent: e
|
latestEvent: e
|
||||||
endEvents: 'mouseout click'
|
endEvents: 'mouseout click'
|
||||||
asapTest: -> el.naturalHeight
|
asapTest: -> post.file.isVideo or el.naturalHeight
|
||||||
$.on el, 'error', ImageHover.error
|
$.on el, 'error', ImageHover.error
|
||||||
error: ->
|
error: ->
|
||||||
return unless doc.contains @
|
return unless doc.contains @
|
||||||
|
|||||||
@ -47,4 +47,4 @@ FileInfo =
|
|||||||
B: -> FileInfo.convertUnit @file.sizeInBytes, 'B'
|
B: -> FileInfo.convertUnit @file.sizeInBytes, 'B'
|
||||||
K: -> FileInfo.convertUnit @file.sizeInBytes, 'KB'
|
K: -> FileInfo.convertUnit @file.sizeInBytes, 'KB'
|
||||||
M: -> FileInfo.convertUnit @file.sizeInBytes, 'MB'
|
M: -> FileInfo.convertUnit @file.sizeInBytes, 'MB'
|
||||||
r: -> if @file.isImage then @file.dimensions else 'PDF'
|
r: -> @file.dimensions or 'PDF'
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
QR =
|
QR =
|
||||||
# Add empty mimeType to avoid errors with URLs selected in Window's file dialog.
|
|
||||||
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', '']
|
|
||||||
init: ->
|
init: ->
|
||||||
return if !Conf['Quick Reply']
|
return if !Conf['Quick Reply']
|
||||||
|
|
||||||
@ -258,21 +256,14 @@ QR =
|
|||||||
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
|
return
|
||||||
unless file.type in QR.mimeTypes
|
|
||||||
unless /^text/.test file.type
|
|
||||||
QR.error "#{file.name}: Unsupported file type."
|
|
||||||
return
|
|
||||||
if isSingle
|
|
||||||
post = QR.selected
|
|
||||||
else if (post = QR.posts[QR.posts.length - 1]).com
|
|
||||||
post = new QR.post()
|
|
||||||
post.pasteText file
|
|
||||||
return
|
|
||||||
if isSingle
|
if isSingle
|
||||||
post = QR.selected
|
post = QR.selected
|
||||||
else if (post = QR.posts[QR.posts.length - 1]).file
|
else if (post = QR.posts[QR.posts.length - 1]).file
|
||||||
post = new QR.post()
|
post = new QR.post()
|
||||||
post.setFile file
|
if /^text/.test file.type
|
||||||
|
post.pasteText file
|
||||||
|
else
|
||||||
|
post.setFile file
|
||||||
openFileInput: ->
|
openFileInput: ->
|
||||||
QR.nodes.fileInput.click()
|
QR.nodes.fileInput.click()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user