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