diff options
Diffstat (limited to 'js')
| -rw-r--r-- | js/expand.js | 20 | ||||
| -rw-r--r-- | js/hide-images.js | 84 | ||||
| -rw-r--r-- | js/hide-threads.js | 83 | ||||
| -rw-r--r-- | js/imgcaptcha.js | 12 | ||||
| -rw-r--r-- | js/inline-expanding-filename.js | 33 | ||||
| -rw-r--r-- | js/inline-expanding.js | 57 | ||||
| -rw-r--r-- | js/local-time.js | 14 | ||||
| l---------[-rw-r--r--] | js/post-hider.js | 54 | ||||
| -rw-r--r-- | js/post-hover.js | 65 | ||||
| -rw-r--r-- | js/quick-post-controls.js | 8 | ||||
| -rw-r--r-- | js/show-backlinks.js | 7 | ||||
| -rw-r--r-- | js/style-select.js | 44 | ||||
| -rw-r--r-- | js/toggle-images.js | 77 |
13 files changed, 443 insertions, 115 deletions
diff --git a/js/expand.js b/js/expand.js index 6371f92c..44f5ae80 100644 --- a/js/expand.js +++ b/js/expand.js @@ -3,7 +3,7 @@ * https://github.com/savetheinternet/Tinyboard/blob/master/js/expand.js * * Released under the MIT license - * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> + * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org> * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; @@ -14,8 +14,8 @@ $(document).ready(function(){ if($('div.banner').length != 0) return; // not index - - $('div.post.op span.omitted').each(function() { + + var do_expand = function() { $(this) .html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">'+_("Click to expand")+'</a>.')) .find('a').click(function() { @@ -27,15 +27,17 @@ $(document).ready(function(){ success: function(data) { var last_expanded = false; $(data).find('div.post.reply').each(function() { - if($('#' + $(this).attr('id')).length == 0) { + var post_in_doc = thread.find('#' + $(this).attr('id')); + if(post_in_doc.length == 0) { if(last_expanded) { $(this).addClass('expanded').insertAfter(last_expanded).before('<br class="expanded">'); } else { $(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('<br class="expanded">'); } last_expanded = $(this); - $(document).trigger('new_post', this); + } else { + last_expanded = post_in_doc; } }); $('<span class="omitted"><a href="javascript:void(0)">' + _('Hide expanded replies') + '</a>.</span>') @@ -48,5 +50,13 @@ $(document).ready(function(){ } }); }); + } + + $('div.post.op span.omitted').each(do_expand); + + $(document).bind("new_post", function(e, post) { + if (!$(post).hasClass("reply")) { + $(post).find('div.post.op span.omitted').each(do_expand); + } }); }); diff --git a/js/hide-images.js b/js/hide-images.js new file mode 100644 index 00000000..365ebac6 --- /dev/null +++ b/js/hide-images.js @@ -0,0 +1,84 @@ +/* + * hide-images.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/hide-images.js + * + * Hide individual images. + * + * Released under the MIT license + * Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/hide-images.js'; + * + */ + +$(document).ready(function(){ + $('<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) + localStorage.hiddenimages = '{}'; + + // Load data from HTML5 localStorage + var hidden_data = JSON.parse(localStorage.hiddenimages); + + var store_data = function() { + localStorage.hiddenimages = JSON.stringify(hidden_data); + }; + + // Delete old hidden images (30+ days old) + for (var key in hidden_data) { + for (var id in hidden_data[key]) { + if (hidden_data[key][id] < Math.round(Date.now() / 1000) - 60 * 60 * 24 * 30) { + delete hidden_data[key][id]; + store_data(); + } + } + } + + if (!hidden_data[board]) { + hidden_data[board] = {}; // id : timestamp + } + + $('div.post > a > img, div > a > img').each(function() { + var img = this; + 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 replacement = $('<span>'+_('File')+' <small>(<a class="hide-image-link" href="javascript:void(0)">'+_('hide')+'</a>)</small>: </span>'); + + replacement.find('a').click(function() { + hidden_data[board][id] = Math.round(Date.now() / 1000); + store_data(); + + var show_link = $('<a class="show-image-link" href="javascript:void(0)">'+_('show')+'</a>').click(function() { + delete hidden_data[board][id]; + store_data(); + + $(img) + .removeClass('hidden') + .attr('src', $(img).data('orig')); + $(this).prev().show(); + $(this).remove(); + }); + + $(this).hide().after(show_link); + + if ($(img).parent()[0].dataset.expanded == 'true') { + $(img).parent().click(); + } + $(img) + .data('orig', img.src) + .attr('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==') + .addClass('hidden'); + }); + + $(this).parent().prev().contents().first().replaceWith(replacement); + + if (hidden_data[board][id]) + $(this).parent().prev().find('.hide-image-link').click(); + + }); +}); diff --git a/js/hide-threads.js b/js/hide-threads.js new file mode 100644 index 00000000..44bd829b --- /dev/null +++ b/js/hide-threads.js @@ -0,0 +1,83 @@ +/* + * hide-threads.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/hide-threads.js + * + * Released under the MIT license + * Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/hide-threads.js'; + * + */ + +$(document).ready(function(){ + if (active_page != "index" && active_page != "ukko") + return; // not index + + if (!localStorage.hiddenthreads) + localStorage.hiddenthreads = '{}'; + + // Load data from HTML5 localStorage + var hidden_data = JSON.parse(localStorage.hiddenthreads); + + var store_data = function() { + localStorage.hiddenthreads = JSON.stringify(hidden_data); + }; + + // Delete old hidden threads (7+ days old) + for (var key in hidden_data) { + for (var id in hidden_data[key]) { + if (hidden_data[key][id] < Math.round(Date.now() / 1000) - 60 * 60 * 24 * 7) { + delete hidden_data[key][id]; + store_data(); + } + } + } + + var do_hide_threads = function() { + var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); + var thread_container = $(this).parent(); + + var board = thread_container.data("board"); + + if (!hidden_data[board]) { + hidden_data[board] = {}; // id : timestamp + } + + $('<a class="hide-thread-link" style="float:left;margin-right:5px" href="javascript:void(0)">[–]</a><span> </span>') + .insertBefore(thread_container.find(':not(h2,h2 *):first')) + .click(function() { + hidden_data[board][id] = Math.round(Date.now() / 1000); + store_data(); + + thread_container.find('div.post,img,p.fileinfo,a.hide-thread-link,br').hide(); + + var hidden_div = thread_container.find('div.post.op > p.intro').clone(); + hidden_div.addClass('thread-hidden'); + hidden_div.find('a[href]:not([href$=".html"]),input').remove(); + hidden_div.html(hidden_div.html().replace(' [] ', ' ')); + hidden_div.html(hidden_div.html().replace(' [] ', ' ')); + + $('<a class="unhide-thread-link" style="float:left;margin-right:5px;margin-left:0px;" href="javascript:void(0)">[+]</a><span> </span>') + .insertBefore(hidden_div.find(':first')) + .click(function() { + delete hidden_data[board][id]; + store_data(); + thread_container.find('div.post,img,p.fileinfo,a.hide-thread-link,br').show(); + $(this).remove(); + hidden_div.remove(); + }); + + hidden_div.insertAfter(thread_container.find(':not(h2,h2 *):first')); + }); + if (hidden_data[board][id]) + thread_container.find('.hide-thread-link').click(); + } + + $('div.post.op').each(do_hide_threads); + + $(document).bind('new_post', function(e, post) { + do_hide_threads.call($(post).find('div.post.op')[0]); + }); +}); diff --git a/js/imgcaptcha.js b/js/imgcaptcha.js deleted file mode 100644 index 99aad414..00000000 --- a/js/imgcaptcha.js +++ /dev/null @@ -1,12 +0,0 @@ -function ic_odswiezKapcze() { - $.get(configRoot + "imgcaptcha_p.php", function(data) { - $("#imgcaptcha_hash").val(data); - $("#imgcaptcha_img").prop("src",configRoot + "imgcaptcha_im.php?cr=" + data); - }); -} -//function resetujKapcze() { -// $("#imgcaptcha_img").prop("src",configRoot + "zakrytek.png"); -//} -//$(document).ready(function(){ -// //resetujKapcze(); - to nie powinno byc na razie potrzebne -//}); diff --git a/js/inline-expanding-filename.js b/js/inline-expanding-filename.js new file mode 100644 index 00000000..048a0e1a --- /dev/null +++ b/js/inline-expanding-filename.js @@ -0,0 +1,33 @@ +/* + * inline-expanding-filename.js + * Binds image filename link to expanding, to make kusaba x users somewhat more accustomed. + * https://github.com/vichan-devel/Tinyboard/blob/master/js/inline-expanding.js + * + * Released under the MIT license + * Copyright (c) 2012-2013 Marcin Łabanowski <marcin@6irc.net> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/inline-expanding.js'; + * $config['additional_javascript'][] = 'js/inline-expanding-filename.js'; + * + */ + +onready(function(){ + var inline_expanding_filename = function() { + $(this).find(".fileinfo > a").click(function(){ + var imagelink = $(this).parent().parent().find('a[target="_blank"]:first'); + if(imagelink.length > 0) { + imagelink.click(); + return false; + } + }); + }; + + $('div[id^="thread_"]').each(inline_expanding_filename); + + // allow to work with auto-reload.js, etc. + $(document).bind('new_post', function(e, post) { + inline_expanding_filename.call(post); + }); +}); diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 7c9923fa..398db181 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -3,10 +3,10 @@ * https://github.com/savetheinternet/Tinyboard/blob/master/js/inline-expanding.js * * Released under the MIT license - * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> + * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org> * * Usage: - * $config['additional_javascript'][] = 'js/jquery.min.js'; + * // $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/inline-expanding.js'; * */ @@ -14,30 +14,40 @@ onready(function(){ var inline_expand_post = function() { var link = this.getElementsByTagName('a'); - - for(var i = 0; i < link.length; i++) { - if(typeof link[i] == "object" && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].className != 'file') { + + for (var i = 0; i < link.length; i++) { + if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].className != 'file') { + if (window.jQuery && !$(link).prev().hasClass('fileinfo')) { + continue; + } link[i].childNodes[0].style.maxWidth = '95%'; link[i].onclick = function(e) { - if(e.which == 2) { + if (this.childNodes[0].className == 'hidden') + return false; + if (e.which == 2 || e.metaKey) return true; - } - if(!this.tag) { - this.tag = this.childNodes[0].src; + if (!this.dataset.src) { + this.dataset.expanded = 'true'; + this.dataset.src= this.childNodes[0].src; + this.dataset.width = this.childNodes[0].style.width; + this.dataset.height = this.childNodes[0].style.height; this.childNodes[0].src = this.href; this.childNodes[0].style.width = 'auto'; this.childNodes[0].style.height = 'auto'; this.childNodes[0].style.opacity = '0.4'; this.childNodes[0].style.filter = 'alpha(opacity=40)'; this.childNodes[0].onload = function() { - this.style.opacity = '1'; - this.style.filter = ''; + this.style.opacity = ''; + delete this.style.filter; } } else { - this.childNodes[0].src = this.tag; - this.childNodes[0].style.width = 'auto'; - this.childNodes[0].style.height = 'auto'; - this.tag = ''; + this.childNodes[0].src = this.dataset.src; + this.childNodes[0].style.width = this.dataset.width; + this.childNodes[0].style.height = this.dataset.height; + delete this.dataset.expanded; + delete this.dataset.src; + delete this.childNodes[0].style.opacity; + delete this.childNodes[0].style.filter; } return false; } @@ -45,11 +55,14 @@ onready(function(){ } } - $('div[id^="thread_"]').each(inline_expand_post); - - // allow to work with auto-reload.js, etc. - $(document).bind('new_post', function(e, post) { - inline_expand_post.call(post); - }); -}); + if (window.jQuery) { + $('div[id^="thread_"]').each(inline_expand_post); + // allow to work with auto-reload.js, etc. + $(document).bind('new_post', function(e, post) { + inline_expand_post.call(post); + }); + } else { + inline_expand_post.call(document); + } +}); diff --git a/js/local-time.js b/js/local-time.js index a4e2fb51..d581e304 100644 --- a/js/local-time.js +++ b/js/local-time.js @@ -6,7 +6,7 @@ * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> * * Usage: - * $config['additional_javascript'][] = 'js/jquery.min.js'; + * // $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/local-time.js'; * */ @@ -44,10 +44,12 @@ onready(function(){ }; do_localtime(document); - - // allow to work with auto-reload.js, etc. - $(document).bind('new_post', function(e, post) { - do_localtime(post); - }); + + if (window.jQuery) { + // allow to work with auto-reload.js, etc. + $(document).bind('new_post', function(e, post) { + do_localtime(post); + }); + } }); diff --git a/js/post-hider.js b/js/post-hider.js index 742c21bc..693c14d6 100644..120000 --- a/js/post-hider.js +++ b/js/post-hider.js @@ -1,53 +1 @@ -function phGetCookieName(board, id) { - return "ph_hide_" + board + "_" + id; -} -function phPostHidden(board, id) { - return (localStorage.getItem(phGetCookieName(board, id)) != null); -} -function phPostToggle(board, id) { - if(phPostHidden(board, id)) { localStorage.removeItem(phGetCookieName(board, id)); } - else { localStorage.setItem(phGetCookieName(board, id),"yes"); } -} -function phGetInnerText(board, id) { - if(phPostHidden(board, id)) { return "[+]"; } - else { return "[–]"; } -} -function phGetOpID(element) { - return Number(element.children("div.post.op").children("p.intro").children("a.post_no.p2").text()); -} -function phGetOpBoard(element) { - return element.data("board"); -} -function phPostHandle(element) { - var id = phGetOpID(element); - var board = phGetOpBoard(element); - var preplies = element.children("div.post.reply"); - var pbody = element.children("div.post.op").children("div.body"); - var pimage = element.children("a:first").children("img"); - var pbutton = element.children("div.post.op").children("p.intro").children("a.posthider"); - var pomitted = element.children("div.post.op").children("span.omitted"); - if(phPostHidden(board, id)) { element.addClass("thread-hidden"); pomitted.hide(); preplies.hide(); pbody.hide(); pimage.hide(); pbutton.text("[+]"); } - else { element.removeClass("thread-hidden"); pomitted.show(); preplies.show(); pbody.show(); pimage.show(); pbutton.text("[–]"); } -} - -function phHandleThread(index, element) { - // Get thread ID. - var pin = $(this).children("div.post.op").children("p.intro"); - var tid = phGetOpID($(this)); - if(tid != NaN) { - $("<a href='javascript:;' class='posthider'>[?]</a>").insertAfter(pin.children('a:last')).click(function(e) { - var eO = $(e.target); - var par = eO.parent().parent().parent(); - phPostToggle(phGetOpBoard(par), phGetOpID(par)); - phPostHandle(par); - return false; - }); - phPostHandle($(this)); - } -} - -$(document).ready(function(){ - if (active_page != "thread") { - $('form[name="postcontrols"] > div[id^="thread"]').each(phHandleThread); - } -}); +hide-threads.js
\ No newline at end of file diff --git a/js/post-hover.js b/js/post-hover.js index 48f0ed96..040b6a73 100644 --- a/js/post-hover.js +++ b/js/post-hover.js @@ -17,13 +17,28 @@ onready(function(){ var $link = $(this); var id; - - if(id = $link.text().match(/^>>(\d+)$/)) { - id = id[1]; + var matches; + + if(matches = $link.text().match(/^>>(?:>\/([^\/]+)\/)?(\d+)$/)) { + id = matches[2]; } else { return; } + var board = $(this); + while (board.data('board') === undefined) { + board = board.parent(); + } + var threadid = board.attr('id').replace("thread_", ""); + board = board.data('board'); + + var parentboard = board; + + if (matches[1] !== undefined) { + board = matches[1]; + } + + var $post = false; var hovering = false; var hovered_at; @@ -32,28 +47,34 @@ onready(function(){ hovered_at = {'x': e.pageX, 'y': e.pageY}; var start_hover = function($link) { - if($post.is(':visible') && + if($.contains($post[0], $link[0])) { + // link links to itself or to op; ignore + } + else if($post.is(':visible') && $post.offset().top + $post.height() >= $(window).scrollTop() && - $post.offset().top <= $(window).scrollTop() + $(window).height() - ) { + $post.offset().top <= $(window).scrollTop() + $(window).height()) { // post is in view $post.attr('style', 'border-style: none dashed dashed none; background: ' + $post.css('border-right-color')); } else { var $newPost = $post.clone(); + $newPost.find('>.reply, >br').remove(); $newPost.find('span.mentioned').remove(); + $newPost .attr('id', 'post-hover-' + id) + .attr('data-board', board) .addClass('post-hover') .css('position', 'absolute') .css('border-style', 'solid') .css('box-shadow', '1px 1px 1px #999') .css('display', 'block') - .insertAfter($link.parent()); + .addClass('reply').addClass('post') + .insertAfter($link.parent()) $link.trigger('mousemove'); } }; - $post = $('div.post#reply_' + id); + $post = $('[data-board="' + board + '"] div.post#reply_' + id + ', [data-board="' + board + '"]div#thread_' + id); if($post.length > 0) { start_hover($(this)); } else { @@ -68,13 +89,27 @@ onready(function(){ url: url, context: document.body, success: function(data) { - $(data).find('div.post.reply').each(function() { - if($('#' + $(this).attr('id')).length == 0) - $('div.post:first').prepend($(this).css('display', 'none').addClass('hidden')); + var mythreadid = $(data).find('div[id^="thread_"]').attr('id').replace("thread_", ""); - }); + if (mythreadid == threadid && parentboard == board) { + $(data).find('div.post.reply').each(function() { + if($('[data-board="' + board + '"] #' + $(this).attr('id')).length == 0) { + $('[data-board="' + board + '"]#thread_' + threadid + " .post.reply:first").before($(this).hide().addClass('hidden')); + } + }); + } + else if ($('[data-board="' + board + '"]#thread_'+mythreadid).length > 0) { + $(data).find('div.post.reply').each(function() { + if($('[data-board="' + board + '"] #' + $(this).attr('id')).length == 0) { + $('[data-board="' + board + '"]#thread_' + mythreadid + " .post.reply:first").before($(this).hide().addClass('hidden')); + } + }); + } + else { + $(data).find('div[id^="thread_"]').hide().attr('data-cached', 'yes').prependTo('form[name="postcontrols"]'); + } - $post = $('div.post#reply_' + id); + $post = $('[data-board="' + board + '"] div.post#reply_' + id + ', [data-board="' + board + '"]div#thread_' + id); if(hovering && $post.length > 0) { start_hover($link); } @@ -87,14 +122,14 @@ onready(function(){ return; $post.attr('style', ''); - if($post.hasClass('hidden')) + if($post.hasClass('hidden') || $post.data('cached') == 'yes') $post.css('display', 'none'); $('.post-hover').remove(); }).mousemove(function(e) { if(!$post) return; - var $hover = $('#post-hover-' + id); + var $hover = $('#post-hover-' + id + '[data-board="' + board + '"]'); if($hover.length == 0) return; diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js index c28f874f..1cbc0711 100644 --- a/js/quick-post-controls.js +++ b/js/quick-post-controls.js @@ -71,10 +71,16 @@ $(document).ready(function(){ } }; - $('div.post input[type=checkbox].delete').each(function() { + var init_qpc = function() { $(this).change(open_form); if(this.checked) $(this).trigger('change'); + }; + + $('div.post input[type=checkbox].delete').each(init_qpc); + + $(document).bind('new_post', function(e, post) { + $(post).find('input[type=checkbox].delete').each(init_qpc); }); }); diff --git a/js/show-backlinks.js b/js/show-backlinks.js index 4ead494b..f23cfc38 100644 --- a/js/show-backlinks.js +++ b/js/show-backlinks.js @@ -48,7 +48,12 @@ onready(function(){ $('div.post.reply').each(showBackLinks); $(document).bind('new_post', function(e, post) { - showBackLinks.call(post); + if ($(post).hasClass("reply")) { + showBackLinks.call(post); + } + else { + $(post).find('div.post.reply').each(showBackLinks); + } }); }); diff --git a/js/style-select.js b/js/style-select.js new file mode 100644 index 00000000..6dcb11e4 --- /dev/null +++ b/js/style-select.js @@ -0,0 +1,44 @@ +/* + * style-select.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/style-select.js + * + * Changes the stylesheet chooser links to a <select> + * + * Released under the MIT license + * Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/style-select.js'; + * + */ + +onready(function(){ + var stylesDiv = $('div.styles'); + var stylesSelect = $('<select></select>'); + + var i = 1; + stylesDiv.children().each(function() { + var opt = $('<option></option>') + .html(this.innerHTML.replace(/(^\[|\]$)/g, '')) + .val(i); + if ($(this).hasClass('selected')) + opt.attr('selected', true); + stylesSelect.append(opt); + $(this).attr('id', 'style-select-' + i); + i++; + }); + + stylesSelect.change(function() { + $('#style-select-' + $(this).val()).click(); + }); + + stylesDiv.hide(); + + stylesDiv.after( + $('<div id="style-select" style="float:right;margin-bottom:10px"></div>') + .text(_('Style: ')) + .append(stylesSelect) + ); +}); + diff --git a/js/toggle-images.js b/js/toggle-images.js new file mode 100644 index 00000000..de1d47b3 --- /dev/null +++ b/js/toggle-images.js @@ -0,0 +1,77 @@ +/* + * toggle-images.js + * + * Released under the MIT license + * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/toggle-images.js'; + * + */ + +$(document).ready(function(){ + var hide_images = localStorage['hideimages'] ? true : false; + + $('<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==') + .addClass('hidden'); + }; + + var restoreImage = function() { + $(this) + .attr('src', $(this).attr('data-orig')) + .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 images') : _('Hide images')) + .click(function() { + hide_images = !hide_images; + if (hide_images) { + $('div > a > img').each(hideImage); + localStorage.hideimages = true; + } else { + $('div > a > img').each(restoreImage); + delete localStorage.hideimages; + } + + show_hide_hide_images_buttons(); + + $(this).text(hide_images ? _('Show images') : _('Hide images')) + }); + + if (hide_images) { + $('div > a > img').each(hideImage); + show_hide_hide_images_buttons(); + } +}); |
