forked from leftypol/leftypol
Prevent blur-images.js interfereing with regular hiding images
This commit is contained in:
parent
bfb51c66a4
commit
0250d59fb7
|
@ -17,36 +17,36 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var hide_images = localStorage['hideimages'] ? true : false;
|
var blur_images = localStorage['blurimages'] ? true : false;
|
||||||
|
|
||||||
$('<style type="text/css"> img.hidden{ opacity: 1 !important; filter: blur(20px); } </style>').appendTo($('head'));
|
$('<style type="text/css"> img.blur{ filter: blur(20px); } </style>').appendTo($('head'));
|
||||||
|
|
||||||
var hideImage = function() {
|
var blurImage = function() {
|
||||||
if ($(this).parent().data('expanded') == 'true') {
|
if ($(this).parent().data('expanded') == 'true') {
|
||||||
$(this).parent().click();
|
$(this).parent().click();
|
||||||
}
|
}
|
||||||
$(this).addClass('hidden');
|
$(this).addClass('blur');
|
||||||
};
|
};
|
||||||
|
|
||||||
var restoreImage = function() {
|
var restoreImage = function() {
|
||||||
$(this)
|
$(this)
|
||||||
.attr('src', $(this).attr('data-orig'))
|
.attr('src', $(this).attr('data-orig'))
|
||||||
.removeClass('hidden');
|
.removeClass('blur');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fix for hide-images.js
|
// Fix for hide-images.js
|
||||||
var show_hide_hide_images_buttons = function() {
|
var show_hide_blur_images_buttons = function() {
|
||||||
if (hide_images) {
|
if (blur_images) {
|
||||||
$('a.hide-image-link').each(function() {
|
$('a.blur-image-link').each(function() {
|
||||||
if ($(this).next().hasClass('show-image-link')) {
|
if ($(this).next().hasClass('unblur-image-link')) {
|
||||||
$(this).next().hide();
|
$(this).next().hide();
|
||||||
}
|
}
|
||||||
$(this).hide().after('<span class="toggle-images-placeholder">'+_('hidden')+'</span>');
|
$(this).hide().after('<span class="blur-images-placeholder">'+_('hidden')+'</span>');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$('span.toggle-images-placeholder').remove();
|
$('span.blur-images-placeholder').remove();
|
||||||
$('a.hide-image-link').each(function() {
|
$('a.blur-image-link').each(function() {
|
||||||
if ($(this).next().hasClass('show-image-link')) {
|
if ($(this).next().hasClass('unblur-image-link')) {
|
||||||
$(this).next().show();
|
$(this).next().show();
|
||||||
} else {
|
} else {
|
||||||
$(this).show();
|
$(this).show();
|
||||||
|
@ -57,37 +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 = '#toggle-images>input';
|
selector = '#blur-images>input';
|
||||||
event = 'change';
|
event = 'change';
|
||||||
Options.extend_tab("general", "<label id='toggle-images'><input type='checkbox' />"+_('Blur images')+"</label>");
|
Options.extend_tab("general", "<label id='blur-images'><input type='checkbox' />"+_('Blur images')+"</label>");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selector = '#toggle-images a';
|
selector = '#blur-images a';
|
||||||
event = 'click';
|
event = 'click';
|
||||||
$('hr:first').before('<div id="toggle-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#toggle-images a')
|
$('div#blur-images a')
|
||||||
.text(hide_images ? _('Show images') : _('Hide images'));
|
.text(blur_images ? _('Unblur images') : _('Blur images'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$(selector)
|
$(selector)
|
||||||
.on(event, function() {
|
.on(event, function() {
|
||||||
hide_images = !hide_images;
|
blur_images = !blur_images;
|
||||||
if (hide_images) {
|
if (blur_images) {
|
||||||
$('img.post-image, .theme-catalog .thread>a>img').each(hideImage);
|
$('img.post-image, .theme-catalog .thread>a>img').each(blurImage);
|
||||||
localStorage.hideimages = 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.hideimages;
|
delete localStorage.blurimages;
|
||||||
}
|
}
|
||||||
|
|
||||||
show_hide_hide_images_buttons();
|
show_hide_blur_images_buttons();
|
||||||
|
|
||||||
$(this).text(hide_images ? _('Show images') : _('Hide images'))
|
$(this).text(blur_images ? _('Unblur images') : _('Blur images'))
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hide_images) {
|
if (blur_images) {
|
||||||
$('img.post-image, .theme-catalog .thread>a>img').each(hideImage);
|
$('img.post-image, .theme-catalog .thread>a>img').each(blurImage);
|
||||||
show_hide_hide_images_buttons();
|
show_hide_blur_images_buttons();
|
||||||
|
|
||||||
if (window.Options && Options.get_tab('general')) {
|
if (window.Options && Options.get_tab('general')) {
|
||||||
$('#toggle-images>input').prop('checked', true);
|
$('#toggle-images>input').prop('checked', true);
|
||||||
|
@ -95,8 +95,8 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('new_post', function(e, post) {
|
$(document).on('new_post', function(e, post) {
|
||||||
if (hide_images) {
|
if (blur_images) {
|
||||||
$(post).find('img.post-image').each(hideImage);
|
$(post).find('img.post-image').each(blurImage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user