MediaWiki:Gadget-Tabs.js

Fonte: Wikinotícias

Nota: Depois de publicar, deve limpar o cachê do seu navegador para ver as alterações.

  • Firefox e Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Internet Explorer e Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
  • Opera: Pressione Ctrl-F5.
$(document).ready(function() {
  var hiddenIndices = $.cookie('hiddenIndices');
  if (hiddenIndices) {
    hiddenIndices = JSON.parse(hiddenIndices);
    $('.tab-button').each(function(index) {
      if (hiddenIndices.indexOf(index) !== -1) {
        $(this).hide();
      }
    });
  }
  
  $('.tab-button').each(function(index) {
    var hideButton = $(this).find('.hide-button');
    hideButton.click(function(event) {
      event.stopPropagation();
      $(this).parent().hide();
      
      if (hiddenIndices === undefined) {
        hiddenIndices = [];
      }
      hiddenIndices.push(index);
      $.cookie('hiddenIndices', JSON.stringify(hiddenIndices));
    });
  });
  
  $('.tab-button').click(function() {
    $('.tab-button').removeClass('tab-active');
    $(this).addClass('tab-active');
    var tab_id = $(this).index();
    $('.tab-content').removeClass('tab-active');
    $('.tab-content').eq(tab_id).addClass('tab-active');
  });
  
  $('.show-all-button').click(function() {
    $('.tab-button').show();
    $.removeCookie('hiddenIndices');
  });
});