forked from leftypol/leftypol
Allow hide-images.js, toggle-images.js and inline-expanding.js to work together
This commit is contained in:
parent
a11c8981fe
commit
c0a45ba123
3 changed files with 52 additions and 15 deletions
|
@ -16,6 +16,9 @@ $(document).ready(function(){
|
|||
$('<style type="text/css"> img.hidden{ opacity: 0.1; background: grey; border: 1px solid #000; } </style>').appendTo($('head'));
|
||||
|
||||
var hideImage = function() {
|
||||
if ($(this).parent()[0].dataset.expanded == 'true') {
|
||||
$(this).parent().click();
|
||||
}
|
||||
$(this)
|
||||
.attr('data-orig', this.src)
|
||||
.attr('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==')
|
||||
|
@ -28,6 +31,27 @@ $(document).ready(function(){
|
|||
.removeClass('hidden');
|
||||
};
|
||||
|
||||
// Fix for hide-images.js
|
||||
var show_hide_hide_images_buttons = function() {
|
||||
if (hide_images) {
|
||||
$('a.hide-image-link').each(function() {
|
||||
if ($(this).next().hasClass('show-image-link')) {
|
||||
$(this).next().hide();
|
||||
}
|
||||
$(this).hide().after('<span class="toggle-images-placeholder">hidden</span>');
|
||||
});
|
||||
} else {
|
||||
$('span.toggle-images-placeholder').remove();
|
||||
$('a.hide-image-link').each(function() {
|
||||
if ($(this).next().hasClass('show-image-link')) {
|
||||
$(this).next().show();
|
||||
} else {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$('hr:first').before('<div id="toggle-images" style="text-align:right"><a class="unimportant" href="javascript:void(0)">-</a></div>');
|
||||
$('div#toggle-images a')
|
||||
.text((hide_images ? 'Show' : 'Hide') + ' images')
|
||||
|
@ -40,11 +64,14 @@ $(document).ready(function(){
|
|||
$('div > a > img').each(restoreImage);
|
||||
delete localStorage.hideimages;
|
||||
}
|
||||
|
||||
|
||||
show_hide_hide_images_buttons();
|
||||
|
||||
$(this).text((hide_images ? 'Show' : 'Hide') + ' images')
|
||||
});
|
||||
|
||||
if (hide_images) {
|
||||
$('div > a > img').each(hideImage);
|
||||
show_hide_hide_images_buttons();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue