GitHub - Make PRs easier

Collapsing Headers on diffs

Stan na 22-09-2015. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         GitHub - Make PRs easier
// @namespace    http://adamwknox.com
// @version      0.6
// @description  Collapsing Headers on diffs
// @author       DrKnoxy
// @include      https://github.com/*
// @grant        none
// ==/UserScript==

var blobSelector = '.blob-wrapper, .render-wrapper, .file-header + .empty';
function monitorHeaderToggle() {
  $(document).on('click', '.file-header', function(e){
    $(this).next(blobSelector).toggle();
  });
}

var toggleID = 'js-blob-collapser';
function addToggle() {
  if (!$('#'+toggleID).length){
    $('#toc .btn-group').before('<a id="'+toggleID+'" class="btn btn-sm right" style="margin-left:4px;">Collapse</a>');
  }
}

var allVisible = true;
function monitorToggle() {
  $(document).on('click', '#'+toggleID, function(e) {
    e.preventDefault();
    if (allVisible) {
      $(this).addClass('selected');
      $(blobSelector).hide();
    } else {
      $(this).removeClass('selected');
      $(blobSelector).show();
    }

    allVisible = !allVisible;
  });
}

$(function(){
  // Toggling with the header
  monitorHeaderToggle();

  // Collapsing all
  addToggle();
  monitorToggle();

  $(document).on('pjax:complete pjax:popstate', function(e){
    addToggle();
  });
});