Conflicts:
	LICENSE
	builds/4chan-X-beta.user.js
	builds/4chan-X.user.js
	src/Images/ImageExpand.coffee
	src/Images/ImageHover.coffee
This commit is contained in:
Zixaphir 2014-04-10 22:28:27 -07:00 committed by ccd0
parent 4ce8589e44
commit b0941f4ae4
2 changed files with 14 additions and 14 deletions

View File

@ -50,8 +50,8 @@ ImageExpand =
return unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root
if ImageExpand.on and
(!Conf['Expand spoilers'] and file.isSpoiler or
!Conf['Expand videos'] and file.isVideo or
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
!Conf['Expand videos'] and file.isVideo or
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
return
$.queueTask func, post
@ -72,8 +72,7 @@ ImageExpand =
(if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'
toggle: (post) ->
{thumb} = post.file
unless post.file.isExpanded or $.hasClass thumb, 'expanding'
unless post.file.isExpanded or $.hasClass post.file.thumb, 'expanding'
ImageExpand.expand post
return
@ -102,17 +101,18 @@ ImageExpand =
ImageExpand.contract post
contract: (post) ->
{thumb} = post.file
if post.file.isVideo and video = post.file.fullImage
video.pause()
TrashQueue.add video, post
post.file.thumb.parentNode.href = video.src
post.file.thumb.parentNode.target = '_blank'
thumb.parentNode.href = video.src
thumb.parentNode.target = '_blank'
for eventName, cb of ImageExpand.videoCB
$.off video, eventName, cb
$.rm post.file.videoControls
$.rm post.file.videoControls
delete post.file.videoControls
$.rmClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
$.rmClass thumb, 'expanding'
post.file.isExpanded = false
expand: (post, src, disableAutoplay) ->
@ -129,7 +129,7 @@ ImageExpand =
$.on el, 'error', ImageExpand.error
el.src = src or post.file.URL
$.after thumb, el unless el is thumb.nextSibling
$.asap (-> if isVideo then el.videoHeight else el.naturalHeight), ->
$.asap (-> el.videoHeight or el.naturalHeight), ->
ImageExpand.completeExpand post, disableAutoplay
completeExpand: (post, disableAutoplay) ->
@ -162,19 +162,19 @@ ImageExpand =
mouseout: (e) -> ImageExpand.contract(Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
click: (e) ->
if @paused and not @controls
e.stopPropagation()
@play()
e.preventDefault()
setupVideoControls: (post) ->
{file} = post
video = file.fullImage
{file} = post
{thumb} = file
video = file.fullImage
# disable link to file so native controls can work
file.thumb.parentNode.removeAttribute 'href'
file.thumb.parentNode.removeAttribute 'target'
# setup callbacks on video element
video.dataset.mousedown = 'false'
$.on video, eventName, cb for eventName, cb of ImageExpand.videoCB
# setup controls in file info

View File

@ -24,7 +24,7 @@ ImageHover =
el.src = file.URL
$.after file.thumb, el
if isVideo
el.loop = true
el.loop = true
el.controls = false
el.play() if Conf['Autoplay']
UI.hover