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; padding-right: 7px;
top: 5px; top: 5px;
} }
:root.gal-pdf .gal-buttons { .gal-pdf .gal-buttons {
top: 40px; top: 40px;
background: rgba(0,0,0,0.6) !important; background: rgba(0,0,0,0.6) !important;
border-radius: 3px; border-radius: 3px;

View File

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