Extend Mouse Wheel Volume to expanded videos and gallery.

This commit is contained in:
ccd0 2015-02-15 00:29:59 -08:00
parent 24a070489b
commit 2b8ce2c1a8
4 changed files with 32 additions and 15 deletions

View File

@ -183,10 +183,6 @@ Config =
false false
'Show full image / video on mouseover in <%= meta.name %> catalog.' 'Show full image / video on mouseover in <%= meta.name %> catalog.'
] ]
'Mouse Wheel Volume': [
true
'Adjust volume of hovering videos with mouse wheel.'
]
'Gallery': [ 'Gallery': [
true true
'Adds a simple and cute image gallery.' 'Adds a simple and cute image gallery.'
@ -262,6 +258,10 @@ Config =
true true
'Open videos with the sound unmuted.' 'Open videos with the sound unmuted.'
] ]
'Mouse Wheel Volume': [
true
'Adjust volume of videos with the mouse wheel over the thumbnail/filename/gallery.'
]
'Loop in New Tab': [ 'Loop in New Tab': [
true true
'Loop videos opened in their own tabs.' 'Loop videos opened in their own tabs.'

View File

@ -60,6 +60,7 @@ Gallery =
{cb} = Gallery {cb} = Gallery
$.on nodes.frame, 'click', cb.blank $.on nodes.frame, 'click', cb.blank
$.on nodes.frame, 'wheel', Volume.wheel if Conf['Mouse Wheel Volume']
$.on nodes.next, 'click', cb.click $.on nodes.next, 'click', cb.click
$.on nodes.name, 'click', ImageCommon.download $.on nodes.name, 'click', ImageCommon.download

View File

@ -13,13 +13,11 @@ ImageHover =
node: -> node: ->
return unless @file and (@file.isImage or @file.isVideo) return unless @file and (@file.isImage or @file.isVideo)
$.on @file.thumb, 'mouseover', ImageHover.mouseover @ $.on @file.thumb, 'mouseover', ImageHover.mouseover @
$.on @file.thumb, 'wheel', ImageHover.wheel if Conf['Mouse Wheel Volume'] and @file.isVideo
catalogNode: -> catalogNode: ->
{file} = @thread.OP {file} = @thread.OP
return unless file and (file.isImage or file.isVideo) return unless file and (file.isImage or file.isVideo)
$.on @nodes.thumb, 'mouseover', ImageHover.mouseover @thread.OP $.on @nodes.thumb, 'mouseover', ImageHover.mouseover @thread.OP
$.on @nodes.thumb, 'wheel', ImageHover.wheel if Conf['Mouse Wheel Volume'] and @thread.OP.file.isVideo
mouseover: (post) -> (e) -> mouseover: (post) -> (e) ->
return unless doc.contains @ return unless doc.contains @
@ -76,12 +74,3 @@ ImageHover =
@src = URL + if @src is URL then '?' + Date.now() else '' @src = URL + if @src is URL then '?' + Date.now() else ''
else else
$.rm @ $.rm @
wheel: (e) ->
return unless el = $.id 'ihover'
return if el.muted or not $.hasAudio el
volume = el.volume + 0.1
volume *= 1.1 if e.deltaY < 0
volume /= 1.1 if e.deltaY > 0
el.volume = $.minmax volume - 0.1, 0, 1
e.preventDefault()

View File

@ -31,6 +31,14 @@ Volume =
Header.menu.addEntry {el: unmuteEntry, order: 200} Header.menu.addEntry {el: unmuteEntry, order: 200}
Header.menu.addEntry {el: volumeEntry, order: 201} Header.menu.addEntry {el: volumeEntry, order: 201}
if Conf['Mouse Wheel Volume']
Post.callbacks.push
name: 'Mouse Wheel Volume'
cb: @node
CatalogThread.callbacks.push
name: 'Mouse Wheel Volume'
cb: @catalogNode
setup: (video) -> setup: (video) ->
video.muted = !Conf['Allow Sound'] video.muted = !Conf['Allow Sound']
video.volume = Conf['Default Volume'] video.volume = Conf['Default Volume']
@ -46,3 +54,22 @@ Volume =
if Volume.inputs if Volume.inputs
Volume.inputs.unmute.checked = !muted Volume.inputs.unmute.checked = !muted
Volume.inputs.volume.value = volume Volume.inputs.volume.value = volume
node: ->
return unless @file?.isVideo
$.on @file.thumb, 'wheel', Volume.wheel.bind(Header.hover)
$.on $('a', @file.text), 'wheel', Volume.wheel.bind(@file.thumb.parentNode)
catalogNode: ->
{file} = @thread.OP
return unless file?.isVideo
$.on @nodes.thumb, 'wheel', Volume.wheel.bind(Header.hover)
wheel: (e) ->
return unless el = $ 'video:not([data-md5])', @
return if el.muted or not $.hasAudio el
volume = el.volume + 0.1
volume *= 1.1 if e.deltaY < 0
volume /= 1.1 if e.deltaY > 0
el.volume = $.minmax volume - 0.1, 0, 1
e.preventDefault()