From f5820d2aae45f60b6e6998b9ec2997c68a66fbf6 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 20 Sep 2014 22:10:44 +0200 Subject: [PATCH] move a few options to a general tab in options panel --- js/forced-anon.js | 29 ++++++++++++++++++++++++----- js/no-animated-gif.js | 25 ++++++++++++++++++++----- js/options/general.js | 7 +++++++ js/toggle-images.js | 27 +++++++++++++++++++++++---- js/toggle-locked-threads.js | 32 +++++++++++++++++++++++++------- 5 files changed, 99 insertions(+), 21 deletions(-) diff --git a/js/forced-anon.js b/js/forced-anon.js index 8f10274d..5ea68199 100644 --- a/js/forced-anon.js +++ b/js/forced-anon.js @@ -8,11 +8,14 @@ * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; + * //$config['additional_javascript'][] = 'js/options.js'; + * //$config['additional_javascript'][] = 'js/style-select.js'; + * //$config['additional_javascript'][] = 'js/options/general.js'; * $config['additional_javascript'][] = 'js/forced-anon.js'; * */ -if (active_page == 'ukko' || active_page == 'thread' || active_page == 'index') +if (active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || (window.Options && Options.get_tab('general'))) $(document).ready(function() { var force_anon = function() { if($(this).children('a.capcode').length == 0) { @@ -56,11 +59,22 @@ $(document).ready(function() { old_info = {}; forced_anon = localStorage['forcedanon'] ? true : false; + + var selector, event; + if (window.Options && Options.get_tab('general')) { + selector = '#forced-anon'; + event = 'change'; + Options.extend_tab("general", ""); + } + else { + selector = '#forced-anon'; + event = 'click'; + $('hr:first').before('
-
'); + $('div#forced-anon a').text(_('Forced anonymity')+' (' + (forced_anon ? _('enabled') : _('disabled')) + ')'); + } - $('hr:first').before('
-
'); - $('div#forced-anon a').text(_('Forced anonymity')+' (' + (forced_anon ? _('enabled') : _('disabled')) + ')'); - $('div#forced-anon a').click(function() { + $(selector).on(event, function() { forced_anon = !forced_anon; if(forced_anon) { @@ -76,8 +90,13 @@ $(document).ready(function() { return false; }); - if(forced_anon) + if(forced_anon) { enable_fa(); + + if (window.Options && Options.get_tab('general')) { + $('#toggle-locked-threads>input').prop('checked', true); + } + } $(document).on('new_post', function(e, post) { if(forced_anon) diff --git a/js/no-animated-gif.js b/js/no-animated-gif.js index 5d21704f..7e777d87 100644 --- a/js/no-animated-gif.js +++ b/js/no-animated-gif.js @@ -2,9 +2,13 @@ * no-animated-gif.js - Toggle GIF animated thumbnails when gifsicle is enabled * * Copyright (c) 2014 Fredrick Brennan + * Copyright (c) 2014 Marcin Ɓabanowski * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; + * //$config['additional_javascript'][] = 'js/options.js'; + * //$config['additional_javascript'][] = 'js/style-select.js'; + * //$config['additional_javascript'][] = 'js/options/general.js'; * $config['additional_javascript'][] = 'js/no-animated-gif.js'; */ @@ -31,6 +35,7 @@ function no_animated_gif() { var anim_gifs = $('img.post-image[src$=".gif"]'); localStorage.no_animated_gif = true; $('#no-animated-gif>a').text(_('Animate GIFs')); + $('#no-animated-gif>input').prop('checked', true); $.each(anim_gifs, function(i, e) {unanimate_gif(e)} ); } @@ -40,14 +45,24 @@ function animated_gif() { $('img.post-image').removeClass("unanimated").show(); localStorage.no_animated_gif = false; $('#no-animated-gif>a').text(_('Unanimate GIFs')); - + $('#no-animated-gif>input').prop('checked', false); } if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko') { - onready(function(){ - $('hr:first').before('') + $(function(){ + var selector, event; + if (window.Options && Options.get_tab('general')) { + selector = '#no-animated-gif>input'; + event = 'change'; + Options.extend_tab("general", ""); + } + else { + selector = '#no-animated-gif'; + event = 'click'; + $('hr:first').before('') + } - $('#no-animated-gif').on('click', function() { + $(selector).on(event, function() { if (localStorage.no_animated_gif === 'true') { animated_gif(); } else { @@ -56,6 +71,6 @@ if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko') }); if (localStorage.no_animated_gif === 'true') - $(document).ready(no_animated_gif); + no_animated_gif(); }); } diff --git a/js/options/general.js b/js/options/general.js index f95ba04f..c0652269 100644 --- a/js/options/general.js +++ b/js/options/general.js @@ -37,6 +37,13 @@ $(function(){ document.location.reload(); }); + $("").appendTo(stor).on("click", function() { + if (confirm(_("Are you sure you want to erase your storage? This involves your hidden threads, watched threads, post password and many more."))) { + localStorage.clear(); + document.location.reload(); + } + }); + $("#style-select").detach().css({float:"none","margin-bottom":0}).appendTo(tab.content); }); diff --git a/js/toggle-images.js b/js/toggle-images.js index 1455329c..20940ccf 100644 --- a/js/toggle-images.js +++ b/js/toggle-images.js @@ -7,6 +7,9 @@ * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; + * //$config['additional_javascript'][] = 'js/options.js'; + * //$config['additional_javascript'][] = 'js/style-select.js'; + * //$config['additional_javascript'][] = 'js/options/general.js'; * $config['additional_javascript'][] = 'js/toggle-images.js'; * */ @@ -53,10 +56,22 @@ $(document).ready(function(){ } }; - $('hr:first').before(''); - $('div#toggle-images a') - .text(hide_images ? _('Show images') : _('Hide images')) - .click(function() { + var selector, event; + if (window.Options && Options.get_tab('general')) { + selector = '#toggle-images>input'; + event = 'change'; + Options.extend_tab("general", ""); + } + else { + selector = '#toggle-images a'; + event = 'click'; + $('hr:first').before(''); + $('div#toggle-images a') + .text(hide_images ? _('Show images') : _('Hide images')); + } + + $(selector) + .on(event, function() { hide_images = !hide_images; if (hide_images) { $('img.post-image, .theme-catalog .thread>a>img').each(hideImage); @@ -74,6 +89,10 @@ $(document).ready(function(){ if (hide_images) { $('img.post-image, .theme-catalog .thread>a>img').each(hideImage); show_hide_hide_images_buttons(); + + if (window.Options && Options.get_tab('general')) { + $('#toggle-images>input').prop('checked', true); + } } $(document).on('new_post', function(e, post) { diff --git a/js/toggle-locked-threads.js b/js/toggle-locked-threads.js index 20a288ed..d0ad6df4 100644 --- a/js/toggle-locked-threads.js +++ b/js/toggle-locked-threads.js @@ -7,20 +7,21 @@ * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; + * //$config['additional_javascript'][] = 'js/options.js'; + * //$config['additional_javascript'][] = 'js/style-select.js'; + * //$config['additional_javascript'][] = 'js/options/general.js'; * $config['additional_javascript'][] = 'js/toggle-locked-threads.js'; * */ -if (active_page == 'ukko' || active_page == 'index') +if (active_page == 'ukko' || active_page == 'index' || (window.Options && Options.get_tab('general'))) $(document).ready(function(){ - if($('div.banner').length != 0) - return; // not index - var hide_locked_threads = localStorage['hidelockedthreads'] ? true : false; $('').appendTo($('head')); var hideLockedThread = function($thread) { + if (active_page == 'ukko' || active_page == 'index') $thread .hide() .addClass('hidden'); @@ -35,11 +36,24 @@ $(document).ready(function(){ var getThreadFromIcon = function($icon) { return $icon.parent().parent().parent() }; + + var selector, event; + if (window.Options && Options.get_tab('general')) { + selector = '#toggle-locked-threads>input'; + event = 'change'; + Options.extend_tab("general", ""); + } + else { + selector = '#toggle-locked-threads a'; + event = 'click'; + $('hr:first').before(''); + } - $('hr:first').before(''); $('div#toggle-locked-threads a') - .text(hide_locked_threads ? _('Show locked threads') : _('Hide locked threads')) - .click(function() { + .text(hide_locked_threads ? _('Show locked threads') : _('Hide locked threads')); + + $(selector) + .on(event, function() { hide_locked_threads = !hide_locked_threads; if (hide_locked_threads) { $('img.icon[title="Locked"], i.fa-lock.fa').each(function() { @@ -60,6 +74,10 @@ $(document).ready(function(){ $('img.icon[title="Locked"], i.fa-lock.fa').each(function() { hideLockedThread(getThreadFromIcon($(this))); }); + + if (window.Options && Options.get_tab('general')) { + $('#toggle-locked-threads>input').prop('checked', true); + } } $(document).on('new_post', function(e, post) { if (hide_locked_threads) {