forked from leftypol/leftypol
inline-expanding.js: fit expanded images into the screen's height (port of soyjak party feature)
This commit is contained in:
parent
3a44b68c41
commit
9746293fed
1 changed files with 27 additions and 6 deletions
|
@ -17,6 +17,10 @@ $(document).ready(function() {
|
||||||
// Default maximum image loads.
|
// Default maximum image loads.
|
||||||
const DEFAULT_MAX = 5;
|
const DEFAULT_MAX = 5;
|
||||||
|
|
||||||
|
if (localStorage.inline_expand_fit_height !== 'false') {
|
||||||
|
$('<style id="expand-fit-height-style">.full-image { max-height: ' + window.innerHeight + 'px; }</style>').appendTo($('head'));
|
||||||
|
}
|
||||||
|
|
||||||
let inline_expand_post = function() {
|
let inline_expand_post = function() {
|
||||||
let link = this.getElementsByTagName('a');
|
let link = this.getElementsByTagName('a');
|
||||||
|
|
||||||
|
@ -71,7 +75,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$(img).one('load', function() {
|
$(img).one('load', function() {
|
||||||
$.when($loadstart).done(function() {
|
$.when($loadstart).done(function() {
|
||||||
// Once fully loaded, update the waiting queue.
|
// once fully loaded, update the waiting queue
|
||||||
--loading;
|
--loading;
|
||||||
$(ele).data('imageLoading', 'false');
|
$(ele).data('imageLoading', 'false');
|
||||||
update();
|
update();
|
||||||
|
@ -202,6 +206,8 @@ $(document).ready(function() {
|
||||||
Options.extend_tab('general', '<span id="inline-expand-max">' +
|
Options.extend_tab('general', '<span id="inline-expand-max">' +
|
||||||
_('Number of simultaneous image downloads (0 to disable): ') +
|
_('Number of simultaneous image downloads (0 to disable): ') +
|
||||||
'<input type="number" step="1" min="0" size="4"></span>');
|
'<input type="number" step="1" min="0" size="4"></span>');
|
||||||
|
Options.extend_tab('general', '<label id="inline-expand-fit-height"><input type="checkbox">' + _('Fit expanded images into screen height') + '</label>');
|
||||||
|
|
||||||
$('#inline-expand-max input')
|
$('#inline-expand-max input')
|
||||||
.css('width', '50px')
|
.css('width', '50px')
|
||||||
.val(localStorage.inline_expand_max || DEFAULT_MAX)
|
.val(localStorage.inline_expand_max || DEFAULT_MAX)
|
||||||
|
@ -212,6 +218,21 @@ $(document).ready(function() {
|
||||||
|
|
||||||
localStorage.inline_expand_max = val;
|
localStorage.inline_expand_max = val;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#inline-expand-fit-height input').on('change', function() {
|
||||||
|
if (localStorage.inline_expand_fit_height !== 'false') {
|
||||||
|
localStorage.inline_expand_fit_height = 'false';
|
||||||
|
$('#expand-fit-height-style').remove();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
localStorage.inline_expand_fit_height = 'true';
|
||||||
|
$('<style id="expand-fit-height-style">.full-image { max-height: ' + window.innerHeight + 'px; }</style>').appendTo($('head'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (localStorage.inline_expand_fit_height !== 'false') {
|
||||||
|
$('#inline-expand-fit-height input').prop('checked', true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.jQuery) {
|
if (window.jQuery) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue