Implement 'Stretch to Fit' option.
This commit is contained in:
parent
b291e8deae
commit
81712c5cd9
@ -585,6 +585,9 @@ Config =
|
|||||||
'Fit Height': [
|
'Fit Height': [
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
|
'Stretch to Fit': [
|
||||||
|
false
|
||||||
|
]
|
||||||
'Scroll to Post': [
|
'Scroll to Post': [
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
|
|||||||
@ -169,6 +169,7 @@ Gallery =
|
|||||||
ImageCommon.addControls file if Conf['Show Controls']
|
ImageCommon.addControls file if Conf['Show Controls']
|
||||||
|
|
||||||
doc.classList.toggle 'gal-pdf', file.nodeName is 'IFRAME'
|
doc.classList.toggle 'gal-pdf', file.nodeName is 'IFRAME'
|
||||||
|
Gallery.cb.setHeight()
|
||||||
nodes.count.textContent = +thumb.dataset.id + 1
|
nodes.count.textContent = +thumb.dataset.id + 1
|
||||||
nodes.name.download = nodes.name.textContent = thumb.title
|
nodes.name.download = nodes.name.textContent = thumb.title
|
||||||
nodes.name.href = thumb.href
|
nodes.name.href = thumb.href
|
||||||
@ -316,6 +317,14 @@ Gallery =
|
|||||||
setFitness: ->
|
setFitness: ->
|
||||||
(if @checked then $.addClass else $.rmClass) doc, "gal-#{@name.toLowerCase().replace /\s+/g, '-'}"
|
(if @checked then $.addClass else $.rmClass) doc, "gal-#{@name.toLowerCase().replace /\s+/g, '-'}"
|
||||||
|
|
||||||
|
setHeight: ->
|
||||||
|
{current, frame} = Gallery.nodes
|
||||||
|
current.style.minHeight = if Conf['Stretch to Fit'] and (dim = g.posts[current.dataset.post]?.file.dimensions)
|
||||||
|
[width, height] = dim.split 'x'
|
||||||
|
Math.min(doc.clientHeight - 25, height / width * frame.clientWidth) + 'px'
|
||||||
|
else
|
||||||
|
null
|
||||||
|
|
||||||
setDelay: -> Gallery.delay = +@value
|
setDelay: -> Gallery.delay = +@value
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
@ -334,14 +343,14 @@ Gallery =
|
|||||||
createSubEntry: (name) ->
|
createSubEntry: (name) ->
|
||||||
label = UI.checkbox name, name
|
label = UI.checkbox name, name
|
||||||
input = label.firstElementChild
|
input = label.firstElementChild
|
||||||
if name in ['Fit Width', 'Fit Height', 'Hide Thumbnails']
|
$.on input, 'change', Gallery.cb.setFitness if name in ['Hide Thumbnails', 'Fit Width', 'Fit Height']
|
||||||
$.on input, 'change', Gallery.cb.setFitness
|
|
||||||
$.event 'change', null, input
|
$.event 'change', null, input
|
||||||
$.on input, 'change', $.cb.checked
|
$.on input, 'change', $.cb.checked
|
||||||
|
$.on input, 'change', Gallery.cb.setHeight if name in ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Stretch to Fit']
|
||||||
el: label
|
el: label
|
||||||
|
|
||||||
createSubEntries: ->
|
createSubEntries: ->
|
||||||
subEntries = (Gallery.menu.createSubEntry item for item in ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Scroll to Post'])
|
subEntries = (Gallery.menu.createSubEntry item for item in ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Stretch to Fit', 'Scroll to Post'])
|
||||||
|
|
||||||
delayLabel = $.el 'label', <%= html('Slide Delay: <input type="number" name="Slide Delay" min="0" step="any" class="field">') %>
|
delayLabel = $.el 'label', <%= html('Slide Delay: <input type="number" name="Slide Delay" min="0" step="any" class="field">') %>
|
||||||
delayInput = delayLabel.firstElementChild
|
delayInput = delayLabel.firstElementChild
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user