forked from leftypol/leftypol
blur-images.js: trim
This commit is contained in:
parent
8fce7e5d4d
commit
f180940296
1 changed files with 28 additions and 31 deletions
|
@ -3,20 +3,20 @@
|
|||
*
|
||||
* Released under the MIT license
|
||||
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
|
||||
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
|
||||
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
|
||||
*
|
||||
* 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';
|
||||
* $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
|
||||
* Intended for anti-raid protection
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function() {
|
||||
var blur_images = localStorage['blurimages'] ? true : false;
|
||||
|
||||
$('<style type="text/css"> img.blur{ filter: blur(20px); } </style>').appendTo($('head'));
|
||||
|
@ -56,44 +56,41 @@ $(document).ready(function(){
|
|||
};
|
||||
|
||||
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'));
|
||||
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'))
|
||||
});
|
||||
$(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);
|
||||
$('#blur-images>input').prop('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$(document).on('new_post', function(e, post) {
|
||||
if (blur_images) {
|
||||
$(post).find('img.post-image').each(blurImage);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue