fix hide-images.js interactions (should be STI-safe)

Conflicts:
	js/expand.js
This commit is contained in:
czaks 2013-12-25 18:12:00 +01:00 committed by Michael Foster
parent bb3f3db0cd
commit 22869ce015
2 changed files with 15 additions and 9 deletions

View File

@ -28,6 +28,7 @@ $(document).ready(function(){
success: function(data) { success: function(data) {
var last_expanded = false; var last_expanded = false;
$(data).find('div.post.reply').each(function() { $(data).find('div.post.reply').each(function() {
thread.find('div.hidden').remove();
var post_in_doc = thread.find('#' + $(this).attr('id')); var post_in_doc = thread.find('#' + $(this).attr('id'));
if(post_in_doc.length == 0) { if(post_in_doc.length == 0) {
if(last_expanded) { if(last_expanded) {

View File

@ -16,8 +16,6 @@
$(document).ready(function(){ $(document).ready(function(){
$('<style type="text/css"> img.hidden{ opacity: 0.1; background: grey; border: 1px solid #000; } </style>').appendTo($('head')); $('<style type="text/css"> img.hidden{ opacity: 0.1; background: grey; border: 1px solid #000; } </style>').appendTo($('head'));
var board = $('form input[name="board"]').val().toString();
if (!localStorage.hiddenimages) if (!localStorage.hiddenimages)
localStorage.hiddenimages = '{}'; localStorage.hiddenimages = '{}';
@ -38,15 +36,17 @@ $(document).ready(function(){
} }
} }
if (!hidden_data[board]) { var handle_images = function() {
hidden_data[board] = {}; // id : timestamp
}
$('div.post > a > img, div > a > img').each(function() {
var img = this; var img = this;
var fileinfo = $(this).parent().prev(); var fileinfo = $(this).parent().prev();
var id = $(this).parent().parent().find('>p.intro>a.post_no:eq(1),>div.post.op>p.intro>a.post_no:eq(1)').text(); var id = $(this).parent().parent().find('>p.intro>a.post_no:eq(1),>div.post.op>p.intro>a.post_no:eq(1)').text();
var board = $(this).parents('[id^="thread_"]').data("board");
if (!hidden_data[board]) {
hidden_data[board] = {}; // id : timestamp
}
var replacement = $('<span>'+_('File')+' <small>(<a class="hide-image-link" href="javascript:void(0)">'+_('hide')+'</a>)</small>: </span>'); var replacement = $('<span>'+_('File')+' <small>(<a class="hide-image-link" href="javascript:void(0)">'+_('hide')+'</a>)</small>: </span>');
replacement.find('a').click(function() { replacement.find('a').click(function() {
@ -79,6 +79,11 @@ $(document).ready(function(){
if (hidden_data[board][id]) if (hidden_data[board][id])
$(this).parent().prev().find('.hide-image-link').click(); $(this).parent().prev().find('.hide-image-link').click();
};
}); $('div.post > a > img, div > a > img').each(handle_images);
$(document).bind('new_post', function(e, post) {
$(post).find('> a > img').each(handle_images);
});
}); });