Rice gallery a little harder
Focus frame on open()
This commit is contained in:
parent
19631dee68
commit
fa44526c54
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2246,7 +2246,8 @@ article li {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
display: <%= flex %>;
|
display: <%= flex %>;
|
||||||
<%= flex %>-direction: column;
|
<%= flex %>-direction: column;
|
||||||
<%= align %>-items: flex-start;
|
<%= align %>-items: stretch;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
.gal-thumbnails img {
|
.gal-thumbnails img {
|
||||||
max-width: 125px;
|
max-width: 125px;
|
||||||
@ -2256,7 +2257,12 @@ article li {
|
|||||||
}
|
}
|
||||||
.gal-thumbnails a {
|
.gal-thumbnails a {
|
||||||
<%= flex %>: 0 0 auto;
|
<%= flex %>: 0 0 auto;
|
||||||
margin: 3px auto;
|
padding: 3px;
|
||||||
|
line-height: 0;
|
||||||
|
transition: background .3s linear;
|
||||||
|
}
|
||||||
|
.gal-highlight {
|
||||||
|
background: rgb(190, 190, 255);
|
||||||
}
|
}
|
||||||
.gal-prev {
|
.gal-prev {
|
||||||
order: 0;
|
order: 0;
|
||||||
|
|||||||
@ -19,10 +19,12 @@ Gallery =
|
|||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
return unless Gallery.el and @file?.isImage
|
return unless Gallery.el and @file?.isImage
|
||||||
|
|
||||||
Gallery.generateThumb $ '.file', @nodes.root
|
Gallery.generateThumb $ '.file', @nodes.root
|
||||||
|
|
||||||
build: ->
|
unless Conf['Image Expansion']
|
||||||
|
$.on @file.thumb.parentNode, 'click', Gallery.cb.image
|
||||||
|
|
||||||
|
build: (image) ->
|
||||||
Gallery.el = dialog = $.el 'div',
|
Gallery.el = dialog = $.el 'div',
|
||||||
id: 'a-gallery'
|
id: 'a-gallery'
|
||||||
innerHTML: """
|
innerHTML: """
|
||||||
@ -36,8 +38,9 @@ Gallery =
|
|||||||
</div>
|
</div>
|
||||||
<div class=gal-thumbnails></div>
|
<div class=gal-thumbnails></div>
|
||||||
"""
|
"""
|
||||||
Gallery.current = $ '.gal-image img', dialog
|
Gallery.frame = $ '.gal-image', dialog
|
||||||
Gallery.url = $ '.gal-image a', dialog
|
Gallery.url = $ 'a', Gallery.frame
|
||||||
|
Gallery.current = $ 'img', Gallery.url
|
||||||
Gallery.thumbs = $ '.gal-thumbnails', dialog
|
Gallery.thumbs = $ '.gal-thumbnails', dialog
|
||||||
Gallery.images = []
|
Gallery.images = []
|
||||||
|
|
||||||
@ -59,8 +62,8 @@ Gallery =
|
|||||||
Gallery.thumbs.scrollTop = 0
|
Gallery.thumbs.scrollTop = 0
|
||||||
Gallery.current.parentElement.scrollTop = 0
|
Gallery.current.parentElement.scrollTop = 0
|
||||||
|
|
||||||
Gallery.cb.open.call if @ isnt Gallery
|
Gallery.cb.open.call if image
|
||||||
$ "[href=#{@href}]", Gallery.thumbs
|
$ "[href=#{image.href}]", Gallery.thumbs
|
||||||
else
|
else
|
||||||
Gallery.images[0]
|
Gallery.images[0]
|
||||||
|
|
||||||
@ -85,20 +88,25 @@ Gallery =
|
|||||||
cb:
|
cb:
|
||||||
keybinds: (e) ->
|
keybinds: (e) ->
|
||||||
return unless key = Keybinds.keyCode e
|
return unless key = Keybinds.keyCode e
|
||||||
e.stopPropagation()
|
cb = switch key
|
||||||
switch key
|
when 'Esc', Conf['Open Gallery']
|
||||||
when 'Esc'
|
Gallery.cb.close
|
||||||
e.stopPropagation()
|
|
||||||
Gallery.cb.close()
|
|
||||||
when 'Right', 'Enter'
|
when 'Right', 'Enter'
|
||||||
Gallery.cb.next()
|
Gallery.cb.next
|
||||||
when 'Left', ''
|
when 'Left', ''
|
||||||
Gallery.cb.prev()
|
Gallery.cb.prev
|
||||||
when Conf['Open Gallery']
|
|
||||||
Gallery.cb.close()
|
return unless cb
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
cb()
|
||||||
|
|
||||||
open: (e) ->
|
open: (e) ->
|
||||||
if e
|
if e
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
|
$.rmClass el, 'gal-highlight' if el = $ '.gal-highlight', Gallery.thumbs
|
||||||
|
$.addClass @, 'gal-highlight'
|
||||||
|
|
||||||
img = $.el 'img',
|
img = $.el 'img',
|
||||||
src: Gallery.url.href = @href
|
src: Gallery.url.href = @href
|
||||||
@ -107,14 +115,17 @@ Gallery =
|
|||||||
img.dataset.id = @dataset.id
|
img.dataset.id = @dataset.id
|
||||||
$.replace Gallery.current, img
|
$.replace Gallery.current, img
|
||||||
Gallery.current = img
|
Gallery.current = img
|
||||||
Gallery.url.parentElement.scrollTop = 0
|
Gallery.frame.scrollTop = 0
|
||||||
|
Gallery.url.focus()
|
||||||
prev: ->
|
prev: ->
|
||||||
Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id - 1]
|
Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id - 1]
|
||||||
next: ->
|
next: ->
|
||||||
Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id + 1]
|
Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id + 1]
|
||||||
|
image: ->
|
||||||
|
Gallery.build @
|
||||||
toggle: ->
|
toggle: ->
|
||||||
if Gallery.el
|
if Gallery.el
|
||||||
return Gallery.close()
|
return Gallery.cb.close()
|
||||||
Gallery.build()
|
Gallery.build()
|
||||||
close: ->
|
close: ->
|
||||||
$.rm Gallery.el
|
$.rm Gallery.el
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user