summaryrefslogtreecommitdiff
path: root/source/features/extend-diff-expander.tsx
blob: 66ff7ca40d226d28b4cbf929448b126acc20c82f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import './extend-diff-expander.css';
import select from 'select-dom';
import delegate from 'delegate-it';
import * as pageDetect from 'github-url-detection';

import features from '.';

function expandDiff(event: delegate.Event): void {
	// Skip if the user clicked directly on the icon
	if (!(event.target as Element).closest('.js-expand')) {
		select<HTMLAnchorElement>('.js-expand', event.delegateTarget)!.click();
	}
}

function init(): void {
	delegate(document, '.diff-view .js-expandable-line', 'click', expandDiff);
}

features.add({
	id: __filebasename,
	description: 'Widens the `Expand diff` button to be clickable across the screen.',
	screenshot: 'https://user-images.githubusercontent.com/6978877/34470024-eee4f43e-ef20-11e7-9036-65094bd58960.PNG'
}, {
	include: [
		pageDetect.isPRFiles,
		pageDetect.isCommit
	],
	init
});