blur-images.js: trim

This commit is contained in:
Zankaria 2024-09-29 23:54:58 +02:00
parent 8fce7e5d4d
commit f180940296

View file

@ -10,13 +10,13 @@
* //$config['additional_javascript'][] = 'js/options.js'; * //$config['additional_javascript'][] = 'js/options.js';
* //$config['additional_javascript'][] = 'js/style-select.js'; * //$config['additional_javascript'][] = 'js/style-select.js';
* //$config['additional_javascript'][] = 'js/options/general.js'; * //$config['additional_javascript'][] = 'js/options/general.js';
* $config['additional_javascript'][] = 'js/toggle-images.js'; * $config['additional_javascript'][] = 'js/blur-images.js';
* *
* Note: I put it immediately under options/general and make the opacity !important to ensure fast loading time * Note: I put it immediately under options/general and make the opacity !important to ensure fast loading time
* Intended for anti-raid protection * Intended for anti-raid protection
*/ */
$(document).ready(function(){ $(document).ready(function() {
var blur_images = localStorage['blurimages'] ? true : false; var blur_images = localStorage['blurimages'] ? true : false;
$('<style type="text/css"> img.blur{ filter: blur(20px); } </style>').appendTo($('head')); $('<style type="text/css"> img.blur{ filter: blur(20px); } </style>').appendTo($('head'));
@ -57,40 +57,37 @@ $(document).ready(function(){
var selector, event; var selector, event;
if (window.Options && Options.get_tab('general')) { if (window.Options && Options.get_tab('general')) {
selector = '#blur-images>input'; selector = '#blur-images>input';
event = 'change'; event = 'change';
Options.extend_tab("general", "<label id='blur-images'><input type='checkbox' />"+_('Blur images')+"</label>"); Options.extend_tab("general", "<label id='blur-images'><input type='checkbox' />"+_('Blur images')+"</label>");
} } else {
else { selector = '#blur-images a';
selector = '#blur-images a'; event = 'click';
event = 'click'; $('hr:first').before('<div id="blur-images" style="text-align:right"><a class="unimportant" href="javascript:void(0)">-</a></div>');
$('hr:first').before('<div id="blur-images" style="text-align:right"><a class="unimportant" href="javascript:void(0)">-</a></div>'); $('div#blur-images a').text(blur_images ? _('Unblur images') : _('Blur images'));
$('div#blur-images a')
.text(blur_images ? _('Unblur images') : _('Blur images'));
} }
$(selector) $(selector).on(event, function() {
.on(event, function() { blur_images = !blur_images;
blur_images = !blur_images; if (blur_images) {
if (blur_images) { $('img.post-image, .theme-catalog .thread>a>img').each(blurImage);
$('img.post-image, .theme-catalog .thread>a>img').each(blurImage); localStorage.blurimages = true;
localStorage.blurimages = true; } else {
} else { $('img.post-image, .theme-catalog .thread>a>img').each(restoreImage);
$('img.post-image, .theme-catalog .thread>a>img').each(restoreImage); delete localStorage.blurimages;
delete localStorage.blurimages; }
}
show_hide_blur_images_buttons(); show_hide_blur_images_buttons();
$(this).text(blur_images ? _('Unblur images') : _('Blur images')) $(this).text(blur_images ? _('Unblur images') : _('Blur images'))
}); });
if (blur_images) { if (blur_images) {
$('img.post-image, .theme-catalog .thread>a>img').each(blurImage); $('img.post-image, .theme-catalog .thread>a>img').each(blurImage);
show_hide_blur_images_buttons(); show_hide_blur_images_buttons();
if (window.Options && Options.get_tab('general')) { if (window.Options && Options.get_tab('general')) {
$('#blur-images>input').prop('checked', true); $('#blur-images>input').prop('checked', true);
} }
} }