Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions routers/repo/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ func FileHistory(ctx *context.Context) {
func Diff(ctx *context.Context) {
ctx.Data["PageIsDiff"] = true
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireSimpleMDE"] = true
ctx.Data["RequireTribute"] = true

userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/diff/box.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</div>
{{else}}
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
<h4 class="ui top attached normal header">
<h4 class="diff-file-header ui top attached normal header">
{{$isImage := false}}
{{if $file.IsDeleted}}
{{$isImage = (call $.IsImageFileInBase $file.Name)}}
Expand Down Expand Up @@ -111,7 +111,7 @@
{{end}}
{{end}}
</h4>
<div class="ui attached unstackable table segment">
<div class="diff-file-body ui attached unstackable table segment">
{{if ne $file.Type 4}}
<div class="file-body file-code code-view has-context-menu code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
<table>
Expand Down
18 changes: 7 additions & 11 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* exported toggleDeadlineForm, setDeadline, updateDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */

import './publicPath.js';
import './polyfills.js';
import './gitGraphLoader.js';
import './semanticDropdown.js';
import initContextPopups from './features/contextPopup';
Expand Down Expand Up @@ -2109,17 +2110,12 @@ function initCodeView() {
}
}).trigger('hashchange');
}
$('.ui.fold-code').on('click', (e) => {
const $foldButton = $(e.target);
if ($foldButton.hasClass('fa-chevron-down')) {
$(e.target).parent().next().slideUp('fast', () => {
$foldButton.removeClass('fa-chevron-down').addClass('fa-chevron-right');
});
} else {
$(e.target).parent().next().slideDown('fast', () => {
$foldButton.removeClass('fa-chevron-right').addClass('fa-chevron-down');
});
}
$('.fold-code').on('click', ({ target }) => {
const box = target.closest('.file-content');
const folded = box.dataset.folded !== 'true';
target.classList.add(`fa-chevron-${folded ? 'right' : 'down'}`);
target.classList.remove(`fa-chevron-${folded ? 'down' : 'right'}`);
box.dataset.folded = String(folded);
});
function insertBlobExcerpt(e) {
const $blob = $(e.target);
Expand Down
17 changes: 17 additions & 0 deletions web_src/js/polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// compat: IE11
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}

// compat: IE11
if (!Element.prototype.closest) {
Element.prototype.closest = function (s) {
let el = this;

do {
if (el.matches(s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
8 changes: 8 additions & 0 deletions web_src/less/_repository.less
Original file line number Diff line number Diff line change
Expand Up @@ -2524,3 +2524,11 @@ td.blob-excerpt {
.title_wip_desc {
margin-top: 1em;
}

.diff-file-box[data-folded="true"] .diff-file-body {
visibility: hidden;
}

.diff-file-box[data-folded="true"] .diff-file-header {
border-radius: 0.28571429rem !important;
}