get new hover working in catalog

Conflicts:
	builds/4chan-X.user.js
	builds/crx/script.js
	src/General/UI.coffee
	src/Images/ImageHover.coffee
This commit is contained in:
ccd0 2014-04-05 21:59:29 -07:00
parent 74ef633fd7
commit 0f770459c0
7 changed files with 67 additions and 45 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

@ -308,7 +308,7 @@ UI = do ->
$.off d, 'mouseup', @up $.off d, 'mouseup', @up
$.set "#{@id}.position", @style.cssText $.set "#{@id}.position", @style.cssText
hoverstart = ({root, el, latestEvent, endEvents, asapTest, cb}) -> hoverstart = ({root, el, latestEvent, endEvents, asapTest, cb, noRemove}) ->
o = { o = {
root root
el el
@ -318,6 +318,7 @@ UI = do ->
latestEvent latestEvent
clientHeight: doc.clientHeight clientHeight: doc.clientHeight
clientWidth: doc.clientWidth clientWidth: doc.clientWidth
noRemove
} }
o.hover = hover.bind o o.hover = hover.bind o
o.hoverend = hoverend.bind o o.hoverend = hoverend.bind o
@ -333,7 +334,7 @@ UI = do ->
$.on root, 'mousemove', o.hover $.on root, 'mousemove', o.hover
<% if (type === 'userscript') { %> <% if (type === 'userscript') { %>
# Workaround for https://github.com/MayhemYDG/4chan-x/issues/377 # Workaround for https://github.com/MayhemYDG/4chan-x/issues/377
o.workaround = (e) -> o.hoverend() unless root.contains e.target o.workaround = (e) -> o.hoverend(e) unless root.contains e.target
$.on doc, 'mousemove', o.workaround $.on doc, 'mousemove', o.workaround
<% } %> <% } %>
@ -362,7 +363,7 @@ UI = do ->
hoverend = (e) -> hoverend = (e) ->
return if e.type is 'keydown' and e.keyCode isnt 13 or e.target.nodeName is "TEXTAREA" return if e.type is 'keydown' and e.keyCode isnt 13 or e.target.nodeName is "TEXTAREA"
$.rm @el if @el.parentNode is Header.hover $.rm @el unless @noRemove
$.off @root, @endEvents, @hoverend $.off @root, @endEvents, @hoverend
$.off d, 'keydown', @hoverend $.off d, 'keydown', @hoverend
$.off @root, 'mousemove', @hover $.off @root, 'mousemove', @hover

View File

@ -713,10 +713,15 @@ span.hide-announcement {
/* File */ /* File */
.fileText:hover .fntrunc, .fileText:hover .fntrunc,
.fileText:not(:hover) .fnfull, .fileText:not(:hover) .fnfull,
.expanded-image > .post > .file > .fileThumb > img[data-md5], .expanded-image > .post > .file > .fileThumb > img[data-md5] {
:not(.expanded-image) > .post > .file .full-image:not(#ihover) {
display: none; display: none;
} }
.full-image:not(#ihover) {
display: none;
}
.expanded-image > .post > .file .full-image:not(#ihover) {
display: inline;
}
.expanding { .expanding {
opacity: .5; opacity: .5;
} }

View File

@ -94,7 +94,7 @@ ImageExpand =
video.pause() video.pause()
for eventName, cb of ImageExpand.videoCB for eventName, cb of ImageExpand.videoCB
$.off video, eventName, cb $.off video, eventName, cb
TrashQueue.add video TrashQueue.add video, post
post.file.videoControls?.map($.rm) post.file.videoControls?.map($.rm)
delete post.file.videoControls delete post.file.videoControls
$.rmClass post.nodes.root, 'expanded-image' $.rmClass post.nodes.root, 'expanded-image'

View File

@ -20,7 +20,10 @@ ImageHover =
src: post.file.URL src: post.file.URL
post.file.fullImage = el post.file.fullImage = el
{thumb} = post.file {thumb} = post.file
$.after (if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb), el if d.body.contains thumb
$.after (if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb), el
else
$.add Header.hover, el
el.id = 'ihover' el.id = 'ihover'
el.dataset.fullID = post.fullID el.dataset.fullID = post.fullID
if isVideo if isVideo
@ -35,10 +38,11 @@ ImageHover =
latestEvent: e latestEvent: e
endEvents: 'mouseout click' endEvents: 'mouseout click'
asapTest: -> el[naturalHeight] asapTest: -> el[naturalHeight]
noRemove: true
cb: -> cb: ->
if isVideo if isVideo
el.pause() el.pause()
TrashQueue.add el TrashQueue.add el, post
el.removeAttribute 'id' el.removeAttribute 'id'
$.on el, 'error', ImageHover.error $.on el, 'error', ImageHover.error
error: -> error: ->

View File

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