Gallery reflows.

This commit is contained in:
Zixaphir 2014-04-10 23:25:46 -07:00
parent 28eebe0183
commit 88b0b0b32f
4 changed files with 60 additions and 93 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

@ -1498,7 +1498,7 @@ div.boardTitle {
padding-right: 7px;
top: 5px;
}
:root.gal-pdf .gal-buttons {
.gal-pdf .gal-buttons {
top: 40px;
background: rgba(0,0,0,0.6) !important;
border-radius: 3px;

View File

@ -15,7 +15,7 @@ Gallery =
Post.callbacks.push
name: 'Gallery'
cb: @node
cb: @node
node: ->
return unless @file
@ -63,11 +63,11 @@ Gallery =
nodes.menu = new UI.Menu 'gallery'
{cb} = Gallery
$.on nodes.frame, 'click', cb.blank
$.on nodes.next, 'click', cb.advance
$.on ($ '.gal-prev', dialog), 'click', cb.prev
$.on ($ '.gal-next', dialog), 'click', cb.next
$.on ($ '.gal-close', dialog), 'click', cb.close
$.on nodes.frame, 'click', cb.blank
$.on nodes.next, 'click', cb.advance
$.on $('.gal-prev', dialog), 'click', cb.prev
$.on $('.gal-next', dialog), 'click', cb.next
$.on $('.gal-close', dialog), 'click', cb.close
$.on menuButton, 'click', (e) ->
nodes.menu.toggle e, @, g
@ -83,12 +83,7 @@ Gallery =
$.on d, 'keydown', cb.keybinds
$.off d, 'keydown', Keybinds.keydown
i = 0
files = $$ '.post .file'
while file = files[i++]
continue if $ '.fileDeletedRes, .fileDeleted', file
Gallery.generateThumb file
Gallery.generateThumb file for file, i in $$ '.post .file' when !$ '.fileDeletedRes, .fileDeleted', file
$.add d.body, dialog
nodes.thumbs.scrollTop = 0
@ -156,27 +151,19 @@ Gallery =
$.addClass @, 'gal-highlight'
elType = if @dataset.isVideo then 'video' else if /\.pdf$/.test(@href) then 'iframe' else 'img'
(if elType is 'iframe' then $.addClass else $.rmClass) doc, 'gal-pdf'
$[if elType is 'iframe' then 'addClass' else 'rmClass'] nodes.el, 'gal-pdf'
file = $.el elType,
src: name.href = @href
title: name.download = name.textContent = @title
if elType is 'video'
img.loop = true
img.autoplay = Conf['Autoplay']
img.muted = !Conf['Allow Sound']
if @dataset.isVideo
file.muted = !Conf['Allow Sound']
file.controls = Conf['Show Controls']
file.autoplay = Conf['Autoplay']
file.loop = true
$.extend file.dataset, @dataset
nodes.current.pause?()
$.replace nodes.current, file
Video.configure file if @dataset.isVideo
nodes.count.textContent = +@dataset.id + 1
nodes.current = file
nodes.frame.scrollTop = 0
nodes.current = file
nodes.frame.scrollTop = 0
nodes.next.focus()
# Scroll
@ -214,7 +201,7 @@ Gallery =
return
# XXX CORS for images.4chan.org WHEN?
$.ajax "//api.4chan.org/#{post.board}/res/#{post.thread}.json", onload: ->
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
return if @status isnt 200
i = 0
{posts} = @response
@ -225,14 +212,16 @@ Gallery =
if postObj.filedeleted
post.kill true
prev: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id - 1]
next: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id + 1]
advance:-> if Gallery.nodes.current.paused then Gallery.nodes.current.play() else Gallery.cb.next()
pause: -> if Gallery.nodes.current.nodeType is 'VIDEO'
if Gallery.nodes.current.paused then Gallery.nodes.current.play() else Gallery.nodes.current.pause()
toggle: -> (if Gallery.nodes then Gallery.cb.close else Gallery.build)()
prev: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id - 1]
next: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id + 1]
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)()
blank: (e) -> Gallery.cb.close() if e.target is @
pause: ->
{current} = Gallery.nodes
current[if current.paused then 'play' else 'pause']() if current.nodeType is 'VIDEO'
close: ->
Gallery.nodes.current.pause?()
$.rm Gallery.nodes.el