Source code of Leftypol imageboard
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

102 lines
3.0 KiB

/*
* blur-images.js (edit of toggle-images.js)
*
* Released under the MIT license
* Copyright (c) 2012 Michael Save <[email protected]>
* Copyright (c) 2013-2014 Marcin Łabanowski <[email protected]>
*
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* //$config['additional_javascript'][] = 'js/options.js';
* //$config['additional_javascript'][] = 'js/style-select.js';
* //$config['additional_javascript'][] = 'js/options/general.js';
* $config['additional_javascript'][] = 'js/toggle-images.js';
*
* Note: I put it immediately under options/general and make the opacity !important to ensure fast loading time
* Intended for anti-raid protection
*/
$(document).ready(function(){
var blur_images = localStorage['blurimages'] ? true : false;
$('<style type="text/css"> img.blur{ filter: blur(20px); } </style>').appendTo($('head'));
var blurImage = function() {
if ($(this).parent().data('expanded') == 'true') {
$(this).parent().click();
}
$(this).addClass('blur');
};
var restoreImage = function() {
$(this)
.attr('src', $(this).attr('data-orig'))
.removeClass('blur');
};
// Fix for hide-images.js
var show_hide_blur_images_buttons = function() {
if (blur_images) {
$('a.blur-image-link').each(function() {
if ($(this).next().hasClass('unblur-image-link')) {
$(this).next().hide();
}
$(this).hide().after('<span class="blur-images-placeholder">'+_('hidden')+'</span>');
});
} else {
$('span.blur-images-placeholder').remove();
$('a.blur-image-link').each(function() {
if ($(this).next().hasClass('unblur-image-link')) {
$(this).next().show();
} else {
$(this).show();
}
});
}
};
var selector, event;
if (window.Options && Options.get_tab('general')) {
selector = '#blur-images>input';
event = 'change';
Options.extend_tab("general", "<label id='blur-images'><input type='checkbox' />"+_('Blur images')+"</label>");
}
else {
selector = '#blur-images a';
event = 'click';
$('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'));
}
$(selector)
.on(event, function() {
blur_images = !blur_images;
if (blur_images) {
$('img.post-image, .theme-catalog .thread>a>img').each(blurImage);
localStorage.blurimages = true;
} else {
$('img.post-image, .theme-catalog .thread>a>img').each(restoreImage);
delete localStorage.blurimages;
}
show_hide_blur_images_buttons();
$(this).text(blur_images ? _('Unblur images') : _('Blur images'))
});
if (blur_images) {
$('img.post-image, .theme-catalog .thread>a>img').each(blurImage);
show_hide_blur_images_buttons();
if (window.Options && Options.get_tab('general')) {
$('#blur-images>input').prop('checked', true);
}
}
$(document).on('new_post', function(e, post) {
if (blur_images) {
$(post).find('img.post-image').each(blurImage);
}
});
});