summaryrefslogtreecommitdiff
path: root/js/toggle-images.js
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-07-27 00:14:43 -0400
committerMichael Foster <savetheinternet@tinyboard.org>2013-07-27 00:14:43 -0400
commitc0a45ba1237fd54c0d5050d3a70abdea022ff6c3 (patch)
treeea9b74634501315b419bca1ca29ba3f7e9701a77 /js/toggle-images.js
parenta11c8981fe87f58d7205fc478c8ba68dca9aa3c2 (diff)
Allow hide-images.js, toggle-images.js and inline-expanding.js to work together
Diffstat (limited to 'js/toggle-images.js')
-rw-r--r--js/toggle-images.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/js/toggle-images.js b/js/toggle-images.js
index 006b3622..74f2fab4 100644
--- a/js/toggle-images.js
+++ b/js/toggle-images.js
@@ -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();
}
});