-
Notifications
You must be signed in to change notification settings - Fork 24
/
expander.js
34 lines (28 loc) · 1.05 KB
/
expander.js
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
30
31
32
33
34
// TODO This isn't working
$(window).on('popstate pjax:success', load);
function load() {
if (!$('.file-header').length || $('.omnibox-collapse').length)
return;
var $toggler = $('<a class="octicon-btn tooltipped tooltipped-nw omnibox-collapse" href="#expand-collapse" aria-label="Expand / Collapse"> \
<span class="octicon octicon-unfold"></span> \
</a>').on('click', function(event){
event.preventDefault();
var $data = $(this).closest('.file-header').next();
if (event.shiftKey) {
$('.data').not($data).hide();
$data.show();
} else {
$data.slideToggle(200);
}
});
$('.file-actions').append($toggler);
var visible = true;
$toggler = $('<a class="octicon-btn tooltipped tooltipped-nw right omnibox-collapse" href="#expand-collapse-all" aria-label="Expand / Collapse All"> \
<span class="octicon octicon-unfold"></span> \
</a>').on('click', function(event){
event.preventDefault();
$('.data').toggle(visible = !visible);
});
$('.table-of-contents .btn-group').before($toggler);
}
load();