User:Robyn Grayson/common.js

if ($('.hidden').length) { switch (wgCanonicalNamespace) { case 'User': case 'User_talk': $('.UserProfileActionButton .wikia-menu-button').before(               $(' ', { class: 'wikia-menu-button', id: 'toggle-hidden', title: 'Show all hiddens on page', text: 'Show Hiddens', css: {'padding': '0 6px', 'margin-right': '5px'}, })           );            break; }   $('', {        class: 'wds-is-squished wds-button',        id: 'toggle-hidden',        title: 'Show all hiddens on page',        text: 'Show Spoilers',        css: {'margin-right': '10px'},    }).insertBefore($('#ca-ve-edit.wds-is-squished.wds-button').exists ? '#ca-ve-edit.wds-is-squished.wds-button' : '#ca-edit.wds-is-squished.wds-button'); } $('#toggle-hidden').click(function {   if ($('.hidden.on, .hidden.off').length) {        $('.hidden').attr('class', 'hidden').removeAttr('title');        $('.wds-button#toggle-hidden').attr('title', 'Hide all hiddens on the page').html('Hide Spoilers');    } else {        $('.hidden').attr('class', 'hidden on').attr('title', 'click to show the hiddens');        $('.wds-button#toggle-hidden').attr('title', 'Show all hiddens on page').html('Show Spoilers');    } }); var hiddenConfig = function(i, el) { var $el = $(el); $el.attr('title', 'Click to show the hiddens'); $el.click(function {       var $this = $(this);        if ($this.hasClass('on'))            $this.attr('class', 'hidden off').removeAttr('title');        else            $this.attr('class', 'hidden on').attr('title', 'Click to show the hiddens');    }); }; $('.hidden.on').each(hiddenConfig);