Updated diff toggle targets and added icon
This commit is contained in:
parent
2aaab34b67
commit
ffdccaa0a8
|
@ -10,12 +10,13 @@
|
||||||
|
|
||||||
ERROR_HTML = '<div class="nothing-here-block"><i class="fa fa-warning"></i> Could not load diff</div>';
|
ERROR_HTML = '<div class="nothing-here-block"><i class="fa fa-warning"></i> Could not load diff</div>';
|
||||||
|
|
||||||
COLLAPSED_HTML = '<div class="nothing-here-block diff-collapsed">This diff is collapsed. Click to expand it.</div>';
|
COLLAPSED_HTML = '<div class="nothing-here-block diff-collapsed">This diff is collapsed. <a class="click-to-expand">Click to expand it.</a></div>';
|
||||||
|
|
||||||
function SingleFileDiff(file) {
|
function SingleFileDiff(file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.toggleDiff = bind(this.toggleDiff, this);
|
this.toggleDiff = bind(this.toggleDiff, this);
|
||||||
this.content = $('.diff-content', this.file);
|
this.content = $('.diff-content', this.file);
|
||||||
|
this.$toggleIcon = $('.diff-toggle-caret', this.file);
|
||||||
this.diffForPath = this.content.find('[data-diff-for-path]').data('diff-for-path');
|
this.diffForPath = this.content.find('[data-diff-for-path]').data('diff-for-path');
|
||||||
this.isOpen = !this.diffForPath;
|
this.isOpen = !this.diffForPath;
|
||||||
if (this.diffForPath) {
|
if (this.diffForPath) {
|
||||||
|
@ -23,18 +24,22 @@
|
||||||
this.loadingContent = $(WRAPPER).addClass('loading').html(LOADING_HTML).hide();
|
this.loadingContent = $(WRAPPER).addClass('loading').html(LOADING_HTML).hide();
|
||||||
this.content = null;
|
this.content = null;
|
||||||
this.collapsedContent.after(this.loadingContent);
|
this.collapsedContent.after(this.loadingContent);
|
||||||
|
this.$toggleIcon.addClass('fa-caret-right');
|
||||||
} else {
|
} else {
|
||||||
this.collapsedContent = $(WRAPPER).html(COLLAPSED_HTML).hide();
|
this.collapsedContent = $(WRAPPER).html(COLLAPSED_HTML).hide();
|
||||||
this.content.after(this.collapsedContent);
|
this.content.after(this.collapsedContent);
|
||||||
|
this.$toggleIcon.addClass('fa-caret-down');
|
||||||
}
|
}
|
||||||
this.collapsedContent.on('click', this.toggleDiff);
|
$('.file-title, .click-to-expand', this.file).on('click', this.toggleDiff);
|
||||||
$('.file-title > a', this.file).on('click', this.toggleDiff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleFileDiff.prototype.toggleDiff = function(e) {
|
SingleFileDiff.prototype.toggleDiff = function(e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
if (!$target.hasClass('file-title') && !$target.hasClass('click-to-expand') && !$target.hasClass('diff-toggle-caret')) return;
|
||||||
this.isOpen = !this.isOpen;
|
this.isOpen = !this.isOpen;
|
||||||
if (!this.isOpen && !this.hasError) {
|
if (!this.isOpen && !this.hasError) {
|
||||||
this.content.hide();
|
this.content.hide();
|
||||||
|
this.$toggleIcon.addClass('fa-caret-right').removeClass('fa-caret-down');
|
||||||
this.collapsedContent.show();
|
this.collapsedContent.show();
|
||||||
if (typeof DiffNotesApp !== 'undefined') {
|
if (typeof DiffNotesApp !== 'undefined') {
|
||||||
DiffNotesApp.compileComponents();
|
DiffNotesApp.compileComponents();
|
||||||
|
@ -42,10 +47,12 @@
|
||||||
} else if (this.content) {
|
} else if (this.content) {
|
||||||
this.collapsedContent.hide();
|
this.collapsedContent.hide();
|
||||||
this.content.show();
|
this.content.show();
|
||||||
|
this.$toggleIcon.addClass('fa-caret-down').removeClass('fa-caret-right');
|
||||||
if (typeof DiffNotesApp !== 'undefined') {
|
if (typeof DiffNotesApp !== 'undefined') {
|
||||||
DiffNotesApp.compileComponents();
|
DiffNotesApp.compileComponents();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.$toggleIcon.addClass('fa-caret-down').removeClass('fa-caret-right');
|
||||||
return this.getContentHTML();
|
return this.getContentHTML();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,10 +19,8 @@
|
||||||
|
|
||||||
&.diff-collapsed {
|
&.diff-collapsed {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
.click-to-expand {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: $row-hover;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,15 @@
|
||||||
padding: 10px $gl-padding;
|
padding: 10px $gl-padding;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
border-radius: 3px 3px 0 0;
|
border-radius: 3px 3px 0 0;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $dark-background-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.diff-toggle-caret {
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
&.file-title-clear {
|
&.file-title-clear {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
- elsif diff_file.collapsed?
|
- elsif diff_file.collapsed?
|
||||||
- url = url_for(params.merge(action: :diff_for_path, old_path: diff_file.old_path, new_path: diff_file.new_path))
|
- url = url_for(params.merge(action: :diff_for_path, old_path: diff_file.old_path, new_path: diff_file.new_path))
|
||||||
.nothing-here-block.diff-collapsed{data: { diff_for_path: url } }
|
.nothing-here-block.diff-collapsed{data: { diff_for_path: url } }
|
||||||
This diff is collapsed. Click to expand it.
|
This diff is collapsed.
|
||||||
|
%a.click-to-expand
|
||||||
|
Click to expand it.
|
||||||
- elsif diff_file.diff_lines.length > 0
|
- elsif diff_file.diff_lines.length > 0
|
||||||
- if diff_view == :parallel
|
- if diff_view == :parallel
|
||||||
= render "projects/diffs/parallel_view", diff_file: diff_file, project: project, blob: blob
|
= render "projects/diffs/parallel_view", diff_file: diff_file, project: project, blob: blob
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
%i.fa.diff-toggle-caret
|
||||||
- if defined?(blob) && blob && diff_file.submodule?
|
- if defined?(blob) && blob && diff_file.submodule?
|
||||||
%span
|
%span
|
||||||
= icon('archive fw')
|
= icon('archive fw')
|
||||||
|
|
Loading…
Reference in New Issue