2013-08-17 00:54:41 -04:00
|
|
|
/*
|
|
|
|
* expand-all-images.js
|
|
|
|
* https://github.com/savetheinternet/Tinyboard/blob/master/js/expand-all-images.js
|
|
|
|
*
|
|
|
|
* Adds an "Expand all images" button to the top of the page.
|
|
|
|
*
|
|
|
|
* Released under the MIT license
|
|
|
|
* Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org>
|
2014-01-19 08:27:24 -05:00
|
|
|
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
|
2014-03-25 06:41:20 -04:00
|
|
|
* Copyright (c) 2014 sinuca <#55ch@rizon.net>
|
2013-08-17 00:54:41 -04:00
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
|
|
|
* $config['additional_javascript'][] = 'js/inline-expanding.js';
|
|
|
|
* $config['additional_javascript'][] = 'js/expand-all-images.js';
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-12-25 12:28:45 -05:00
|
|
|
if (active_page == 'ukko' || active_page == 'thread' || active_page == 'index')
|
2013-08-17 00:54:41 -04:00
|
|
|
onready(function(){
|
|
|
|
$('hr:first').before('<div id="expand-all-images" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>');
|
|
|
|
$('div#expand-all-images a')
|
|
|
|
.text(_('Expand all images'))
|
|
|
|
.click(function() {
|
|
|
|
$('a img.post-image').each(function() {
|
2014-12-20 17:02:03 -05:00
|
|
|
// Don't expand YouTube embeds
|
|
|
|
if ($(this).parent().parent().hasClass('video-container'))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// or WEBM
|
|
|
|
if (/^\/player\.php\?/.test($(this).parent().attr('href')))
|
|
|
|
return;
|
|
|
|
|
2013-08-17 00:54:41 -04:00
|
|
|
if (!$(this).parent()[0].dataset.expanded)
|
|
|
|
$(this).parent().click();
|
|
|
|
});
|
2014-03-25 06:41:20 -04:00
|
|
|
|
2014-09-26 20:44:55 -04:00
|
|
|
if (!$('#shrink-all-images').length) {
|
|
|
|
$('hr:first').before('<div id="shrink-all-images" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>');
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:41:20 -04:00
|
|
|
$('div#shrink-all-images a')
|
|
|
|
.text(_('Shrink all images'))
|
|
|
|
.click(function(){
|
2014-10-27 04:49:17 -04:00
|
|
|
$('a img.full-image').each(function() {
|
2014-03-25 06:41:20 -04:00
|
|
|
if ($(this).parent()[0].dataset.expanded)
|
|
|
|
$(this).parent().click();
|
|
|
|
});
|
|
|
|
$(this).parent().remove();
|
|
|
|
});
|
2013-08-17 00:54:41 -04:00
|
|
|
});
|
|
|
|
});
|