implement length 1 queue of videos to be deleted

This commit is contained in:
ccd0 2014-04-04 22:11:17 -07:00
parent 337b43591b
commit 342672bab3
6 changed files with 89 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -325,6 +325,7 @@ Main =
['Reveal Spoiler Thumbnails', RevealSpoilers]
['Image Loading', ImageLoader]
['Image Hover', ImageHover]
['Trash Queue', TrashQueue]
['Thread Expansion', ExpandThread]
['Thread Excerpt', ThreadExcerpt]
['Favicon', Favicon]

View File

@ -90,7 +90,9 @@ ImageExpand =
ImageExpand.contract post
contract: (post) ->
post.file.fullImage?.pause() if post.file.isVideo
if post.file.isVideo and video = post.file.fullImage
video.pause()
TrashQueue.add video
$.rmClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
post.file.isExpanded = false
@ -105,6 +107,7 @@ ImageExpand =
naturalHeight = if isVideo then 'videoHeight' else 'naturalHeight'
if img = post.file.fullImage
# Expand already-loaded/ing picture.
TrashQueue.remove img
$.rmClass img, 'ihover'
$.addClass img, 'full-image'
img.controls = (img.parentNode isnt thumb.parentNode)

View File

@ -13,6 +13,7 @@ ImageHover =
{isVideo} = post.file
if post.file.fullImage
el = post.file.fullImage
TrashQueue.remove el
$.rmClass el, 'full-image'
$.addClass el, 'ihover'
else
@ -36,7 +37,9 @@ ImageHover =
endEvents: 'mouseout click'
asapTest: -> el[naturalHeight]
cb: ->
el.pause() if isVideo
if isVideo
el.pause()
TrashQueue.add el
$.rmClass el, 'ihover'
$.addClass el, 'full-image'
$.on el, 'error', ImageHover.error

View File

@ -0,0 +1,14 @@
TrashQueue =
init: -> return
add: (video) ->
if video isnt @killNext and @killNext
post = Get.postFromNode @killNext
delete post?.file?.fullImage
$.rm @killNext
@killNext = video
remove: (video) ->
if video is @killNext
delete @killNext