Remove contract button; work around controls by estimating their position.
This commit is contained in:
parent
6061b3ac46
commit
bed88c3324
@ -242,7 +242,7 @@ Config =
|
|||||||
]
|
]
|
||||||
'Show Controls': [
|
'Show Controls': [
|
||||||
true
|
true
|
||||||
'Show controls on videos expanded inline. Turn this off if you want to contract videos by clicking on them.'
|
'Show controls on videos expanded inline.'
|
||||||
]
|
]
|
||||||
'Loop in New Tab': [
|
'Loop in New Tab': [
|
||||||
true
|
true
|
||||||
|
|||||||
@ -60,7 +60,6 @@ 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
|
|
||||||
|
|
||||||
# Contract thumbnails in quote preview
|
# Contract thumbnails in quote preview
|
||||||
ImageExpand.contract @ if contractThumb
|
ImageExpand.contract @ if contractThumb
|
||||||
|
|||||||
@ -209,7 +209,7 @@ Gallery =
|
|||||||
when 'Right'
|
when 'Right'
|
||||||
Gallery.cb.next
|
Gallery.cb.next
|
||||||
when 'Enter'
|
when 'Enter'
|
||||||
Gallery.cb.enterKey
|
Gallery.cb.advance
|
||||||
when 'Left', ''
|
when 'Left', ''
|
||||||
Gallery.cb.prev
|
Gallery.cb.prev
|
||||||
when Conf['Pause']
|
when Conf['Pause']
|
||||||
@ -239,8 +239,11 @@ Gallery =
|
|||||||
Gallery.cb.open.call(
|
Gallery.cb.open.call(
|
||||||
Gallery.images[+Gallery.nodes.current.dataset.id + 1] or Gallery.images[0]
|
Gallery.images[+Gallery.nodes.current.dataset.id + 1] or Gallery.images[0]
|
||||||
)
|
)
|
||||||
enterKey: -> if Gallery.nodes.current.paused then Gallery.nodes.current.play() else Gallery.cb.next()
|
click: (e) ->
|
||||||
click: -> Gallery.cb[if Gallery.nodes.current.controls then 'stop' else 'enterKey']()
|
return if ImageCommon.onControls e
|
||||||
|
e.preventDefault()
|
||||||
|
Gallery.cb.advance()
|
||||||
|
advance: -> if Gallery.nodes.current.paused then Gallery.nodes.current.play() else Gallery.cb.next()
|
||||||
toggle: -> (if Gallery.nodes then Gallery.cb.close else Gallery.build)()
|
toggle: -> (if Gallery.nodes then Gallery.cb.close else Gallery.build)()
|
||||||
blank: (e) -> Gallery.cb.close() if e.target is @
|
blank: (e) -> Gallery.cb.close() if e.target is @
|
||||||
toggleSlideshow: -> Gallery.cb[if Gallery.slideshow then 'stop' else 'start']()
|
toggleSlideshow: -> Gallery.cb[if Gallery.slideshow then 'stop' else 'start']()
|
||||||
|
|||||||
@ -79,3 +79,7 @@ ImageCommon =
|
|||||||
$.asap (-> chrome? or (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or new Date().getTime() >= t + 1000), ->
|
$.asap (-> chrome? or (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or new Date().getTime() >= t + 1000), ->
|
||||||
video.controls = true
|
video.controls = true
|
||||||
$.on video, 'mouseover', handler
|
$.on video, 'mouseover', handler
|
||||||
|
|
||||||
|
# XXX Estimate whether clicks are on the video controls and should be ignored.
|
||||||
|
onControls: (e) ->
|
||||||
|
e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35
|
||||||
|
|||||||
@ -10,8 +10,6 @@ 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'
|
||||||
@ -27,7 +25,6 @@ ImageExpand =
|
|||||||
ImageExpand.contract @
|
ImageExpand.contract @
|
||||||
ImageExpand.expand @
|
ImageExpand.expand @
|
||||||
else if @file.isExpanded and @file.isVideo
|
else if @file.isExpanded and @file.isVideo
|
||||||
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
|
||||||
(Conf['Expand spoilers'] or !@file.isSpoiler) and
|
(Conf['Expand spoilers'] or !@file.isSpoiler) and
|
||||||
@ -39,9 +36,12 @@ ImageExpand =
|
|||||||
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
||||||
post = Get.postFromNode @
|
post = Get.postFromNode @
|
||||||
{file} = post
|
{file} = post
|
||||||
return if file.isExpanded and file.isVideo and file.fullImage.controls
|
return if file.isExpanded and ImageCommon.onControls e
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
ImageExpand.toggle post
|
if file.fullImage?.paused
|
||||||
|
file.fullImage.play()
|
||||||
|
else
|
||||||
|
ImageExpand.toggle post
|
||||||
|
|
||||||
toggleAll: ->
|
toggleAll: ->
|
||||||
$.event 'CloseMenu'
|
$.event 'CloseMenu'
|
||||||
@ -110,10 +110,9 @@ 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', 'videoControls', 'wasPlaying', 'scrollIntoView']
|
for x in ['isExpanding', 'isExpanded', 'wasPlaying', 'scrollIntoView']
|
||||||
delete file[x]
|
delete file[x]
|
||||||
|
|
||||||
return unless el
|
return unless el
|
||||||
@ -133,8 +132,6 @@ 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 ->
|
||||||
@ -170,17 +167,11 @@ ImageExpand =
|
|||||||
$.after thumb, el
|
$.after thumb, el
|
||||||
|
|
||||||
if isVideo
|
if isVideo
|
||||||
# add contract link to file info
|
|
||||||
if Conf['Show Controls'] 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
|
||||||
ImageExpand.setupVideoCB post
|
|
||||||
|
|
||||||
if !isVideo
|
if !isVideo
|
||||||
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
|
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
|
||||||
@ -230,24 +221,6 @@ 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
|
|
||||||
click: (e) ->
|
|
||||||
if @paused and not @controls
|
|
||||||
@play()
|
|
||||||
e.stopPropagation()
|
|
||||||
|
|
||||||
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