Browse Source

Close #67 PR: Add collapsible file diffs to compare and commit views. Fixes #58, Fixes #59, Fixes #59

master
Haralan Dobrev 9 years ago
committed by Sindre Sorhus
parent
commit
a74b31a6b5
  1. 4
      extension/content.css
  2. 10
      extension/content.js

4
extension/content.css

@ -190,10 +190,10 @@
.btn-group.refined-github-btn-group {
margin-right: 25px;
}
.file-header, .file-header .file-info * {
.file-header[data-path], .file-header[data-path] .diffstat {
cursor: zoom-out !important;
}
.refined-github-minimized .file-header, .refined-github-minimized .file-header .file-info * {
.refined-github-minimized .file-header[data-path], .refined-github-minimized .file-header[data-path] .diffstat {
cursor: zoom-in !important;
}

10
extension/content.js

@ -3,9 +3,11 @@
const path = location.pathname;
const isDashboard = path === '/' || /(^\/(dashboard))/.test(path) || /(^\/(orgs)\/)(\w|-)+\/(dashboard)/.test(path);
const isRepo = /^\/[^/]+\/[^/]+/.test(path);
const isCompare = /^\/[^/]+\/[^/]+\/compare/.test(path);
const ownerName = path.split('/')[1];
const repoName = path.split('/')[2];
const isPR = () => /^\/[^/]+\/[^/]+\/pull\/\d+/.test(location.pathname);
const isCommit = () => /^\/[^/]+\/[^/]+\/commit/.test(path);
const isIssue = () => /^\/[^/]+\/[^/]+\/issues\/\d+$/.test(location.pathname);
const isReleases = () => isRepo && /^\/[^/]+\/[^/]+\/(releases|tags)/.test(location.pathname);
const isBlame = () => isRepo && /^\/[^/]+\/[^/]+\/blame\//.test(location.pathname);
@ -288,7 +290,6 @@ document.addEventListener('DOMContentLoaded', () => {
if (isRepo) {
const isRepoRoot = location.pathname.replace(/\/$/, '') === `/${ownerName}/${repoName}` || /(\/tree\/)(\w|\d|\.)+(\/$|$)/.test(location.href);
const isCommit = path.split('/')[3] === 'commit';
gitHubInjection(window, () => {
addReleasesTab();
@ -296,7 +297,6 @@ document.addEventListener('DOMContentLoaded', () => {
if (isPR()) {
linkifyBranchRefs();
addDeleteForkLink();
addMinimizeMaximize();
}
if (isPR() || isIssue()) {
@ -304,6 +304,10 @@ document.addEventListener('DOMContentLoaded', () => {
linkifyIssuesInTitles();
}
if (isPR() || isCommit() || isCompare) {
addMinimizeMaximize();
}
if (isBlame()) {
addBlameParentLinks();
}
@ -312,7 +316,7 @@ document.addEventListener('DOMContentLoaded', () => {
addReadmeEditButton();
}
if (isCommit) {
if (isCommit()) {
addPatchDiffLinks();
}
});

Loading…
Cancel
Save