Implement 'Click Passthrough' option, restore button and left-dragging.
This commit is contained in:
parent
b7b18d1e2a
commit
769dec0b50
@ -245,6 +245,11 @@ Config =
|
|||||||
true
|
true
|
||||||
'Show controls on videos expanded inline.'
|
'Show controls on videos expanded inline.'
|
||||||
]
|
]
|
||||||
|
'Click Passthrough': [
|
||||||
|
false
|
||||||
|
'Clicks on videos trigger your browser\'s default behavior. Videos can be contracted with button / dragging to the left.'
|
||||||
|
1
|
||||||
|
]
|
||||||
'Allow Sound': [
|
'Allow Sound': [
|
||||||
true
|
true
|
||||||
'Allow sound in videos.'
|
'Allow sound in videos.'
|
||||||
|
|||||||
@ -60,6 +60,7 @@ class Clone extends Post
|
|||||||
@file.text = file.firstElementChild
|
@file.text = file.firstElementChild
|
||||||
@file.thumb = $ '.fileThumb > [data-md5]', file
|
@file.thumb = $ '.fileThumb > [data-md5]', file
|
||||||
@file.fullImage = $ '.full-image', file
|
@file.fullImage = $ '.full-image', file
|
||||||
|
@file.videoControls = $ '.video-controls', @file.text
|
||||||
|
|
||||||
@file.thumb.muted = true if @file.videoThumb
|
@file.thumb.muted = true if @file.videoThumb
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,8 @@ ImageCommon =
|
|||||||
|
|
||||||
# XXX Estimate whether clicks are on the video controls and should be ignored.
|
# XXX Estimate whether clicks are on the video controls and should be ignored.
|
||||||
onControls: (e) ->
|
onControls: (e) ->
|
||||||
e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35
|
(Conf['Show Controls'] and Conf['Click Passthrough']) or
|
||||||
|
(e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35)
|
||||||
|
|
||||||
download: (e) ->
|
download: (e) ->
|
||||||
return true if @protocol is 'blob:'
|
return true if @protocol is 'blob:'
|
||||||
|
|||||||
@ -11,6 +11,8 @@ ImageExpand =
|
|||||||
$.on @EAI, 'click', @cb.toggleAll
|
$.on @EAI, 'click', @cb.toggleAll
|
||||||
Header.addShortcut @EAI, 3
|
Header.addShortcut @EAI, 3
|
||||||
$.on d, 'scroll visibilitychange', @cb.playVideos
|
$.on d, 'scroll visibilitychange', @cb.playVideos
|
||||||
|
@videoControls = $.el 'span', className: 'video-controls'
|
||||||
|
$.extend @videoControls, <%= html('\u00A0<a href="javascript:;" title="You can also contract the video by dragging it to the left.">contract</a>') %>
|
||||||
|
|
||||||
Post.callbacks.push
|
Post.callbacks.push
|
||||||
name: 'Image Expansion'
|
name: 'Image Expansion'
|
||||||
@ -29,6 +31,7 @@ ImageExpand =
|
|||||||
|
|
||||||
else if @file.isExpanded and @file.isVideo
|
else if @file.isExpanded and @file.isVideo
|
||||||
@file.fullImage.muted = !Conf['Allow Sound']
|
@file.fullImage.muted = !Conf['Allow Sound']
|
||||||
|
ImageExpand.setupVideoCB @
|
||||||
ImageExpand.setupVideo @, !@origin.file.fullImage?.paused or @origin.file.wasPlaying, @file.fullImage.controls
|
ImageExpand.setupVideo @, !@origin.file.fullImage?.paused or @origin.file.wasPlaying, @file.fullImage.controls
|
||||||
|
|
||||||
else if ImageExpand.on and !@isHidden and !@isFetchedQuote and
|
else if ImageExpand.on and !@isHidden and !@isFetchedQuote and
|
||||||
@ -116,9 +119,10 @@ ImageExpand =
|
|||||||
|
|
||||||
$.rmClass post.nodes.root, 'expanded-image'
|
$.rmClass post.nodes.root, 'expanded-image'
|
||||||
$.rmClass file.thumb, 'expanding'
|
$.rmClass file.thumb, 'expanding'
|
||||||
|
$.rm file.videoControls if file.videoControls
|
||||||
file.thumb.parentNode.href = file.URL
|
file.thumb.parentNode.href = file.URL
|
||||||
file.thumb.parentNode.target = '_blank'
|
file.thumb.parentNode.target = '_blank'
|
||||||
for x in ['isExpanding', 'isExpanded', 'wasPlaying', 'scrollIntoView']
|
for x in ['isExpanding', 'isExpanded', 'videoControls', 'wasPlaying', 'scrollIntoView']
|
||||||
delete file[x]
|
delete file[x]
|
||||||
|
|
||||||
return unless el
|
return unless el
|
||||||
@ -138,6 +142,8 @@ ImageExpand =
|
|||||||
ImageCommon.pushCache el
|
ImageCommon.pushCache el
|
||||||
if file.isVideo
|
if file.isVideo
|
||||||
el.pause()
|
el.pause()
|
||||||
|
for eventName, cb of ImageExpand.videoCB
|
||||||
|
$.off el, eventName, cb
|
||||||
ImageCommon.rewind file.thumb if Conf['Restart when Opened']
|
ImageCommon.rewind file.thumb if Conf['Restart when Opened']
|
||||||
delete file.fullImage
|
delete file.fullImage
|
||||||
$.queueTask ->
|
$.queueTask ->
|
||||||
@ -173,12 +179,18 @@ ImageExpand =
|
|||||||
$.after thumb, el
|
$.after thumb, el
|
||||||
|
|
||||||
if isVideo
|
if isVideo
|
||||||
|
# add contract link to file info
|
||||||
|
if Conf['Show Controls'] and Conf['Click Passthrough'] and !file.videoControls
|
||||||
|
file.videoControls = ImageExpand.videoControls.cloneNode true
|
||||||
|
$.add file.text, file.videoControls
|
||||||
|
|
||||||
# disable link to file so native controls can work
|
# disable link to file so native controls can work
|
||||||
thumb.parentNode.removeAttribute 'href'
|
thumb.parentNode.removeAttribute 'href'
|
||||||
thumb.parentNode.removeAttribute 'target'
|
thumb.parentNode.removeAttribute 'target'
|
||||||
|
|
||||||
el.loop = true
|
el.loop = true
|
||||||
el.muted = !Conf['Allow Sound']
|
el.muted = !Conf['Allow Sound']
|
||||||
|
ImageExpand.setupVideoCB post
|
||||||
|
|
||||||
if !isVideo
|
if !isVideo
|
||||||
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
|
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
|
||||||
@ -228,6 +240,20 @@ ImageExpand =
|
|||||||
if controls
|
if controls
|
||||||
ImageCommon.addControls fullImage
|
ImageCommon.addControls fullImage
|
||||||
|
|
||||||
|
videoCB: do ->
|
||||||
|
# dragging to the left contracts the video
|
||||||
|
mousedown = false
|
||||||
|
mouseover: -> mousedown = false
|
||||||
|
mousedown: (e) -> mousedown = true if e.button is 0
|
||||||
|
mouseup: (e) -> mousedown = false if e.button is 0
|
||||||
|
mouseout: (e) -> ImageExpand.toggle(Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
|
||||||
|
|
||||||
|
setupVideoCB: (post) ->
|
||||||
|
for eventName, cb of ImageExpand.videoCB
|
||||||
|
$.on post.file.fullImage, eventName, cb
|
||||||
|
if post.file.videoControls
|
||||||
|
$.on post.file.videoControls.firstElementChild, 'click', -> ImageExpand.toggle post
|
||||||
|
|
||||||
error: ->
|
error: ->
|
||||||
post = Get.postFromNode @
|
post = Get.postFromNode @
|
||||||
$.rm @
|
$.rm @
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user