diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2013-01-27 19:01:31 +1100 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2013-01-27 19:01:31 +1100 |
| commit | bf792ae7b7dc2231405eaa163f17f2009481a57d (patch) | |
| tree | f9627964e98d200c677de54fca616a53246c8525 /js | |
| parent | b85b4a5a750aabda00c00051d1c41a2fb957bce1 (diff) | |
toggle-locked-threads.js: Don't hide thread if accessed directly (only on index)
Diffstat (limited to 'js')
| -rw-r--r-- | js/toggle-locked-threads.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/js/toggle-locked-threads.js b/js/toggle-locked-threads.js new file mode 100644 index 00000000..50c44eda --- /dev/null +++ b/js/toggle-locked-threads.js @@ -0,0 +1,63 @@ +/* + * toggle-locked-threads.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-locked-threads.js'; + * + */ + +$(document).ready(function(){ + if($('div.banner').length != 0) + return; // not index + + var hide_locked_threads = localStorage['hidelockedthreads'] ? true : false; + + $('<style type="text/css"> img.hidden{ opacity: 0.1; background: grey; border: 1px solid #000; } </style>').appendTo($('head')); + + var hideLockedThread = function($thread) { + $thread + .hide() + .addClass('hidden'); + }; + + var restoreLockedThread = function($thread) { + $thread + .show() + .removeClass('hidden'); + }; + + var getThreadFromIcon = function($icon) { + return $icon.parent().parent().parent() + }; + + $('hr:first').before('<div id="toggle-locked-threads" style="text-align:right"><a class="unimportant" href="javascript:void(0)">-</a></div>'); + $('div#toggle-locked-threads a') + .text((hide_locked_threads ? 'Show' : 'Hide') + ' locked threads') + .click(function() { + hide_locked_threads = !hide_locked_threads; + if (hide_locked_threads) { + $('img.icon[title="Locked"]').each(function() { + hideLockedThread(getThreadFromIcon($(this))); + }); + localStorage.hidelockedthreads = true; + } else { + $('img.icon[title="Locked"]').each(function() { + restoreLockedThread(getThreadFromIcon($(this))); + }); + delete localStorage.hidelockedthreads; + } + + $(this).text((hide_locked_threads ? 'Show' : 'Hide') + ' locked threads') + }); + + if (hide_locked_threads) { + $('img.icon[title="Locked"]').each(function() { + hideLockedThread(getThreadFromIcon($(this))); + }); + } +}); + |
