Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
1d3b7768
Commit
1d3b7768
authored
Oct 25, 2016
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor Diff class event bindings
parent
4f107f3f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
48 deletions
+48
-48
app/assets/javascripts/diff.js.es6
app/assets/javascripts/diff.js.es6
+48
-48
No files found.
app/assets/javascripts/diff.js.es6
View file @
1d3b7768
...
@@ -11,58 +11,58 @@
...
@@ -11,58 +11,58 @@
if (this.diffViewType() === 'parallel') {
if (this.diffViewType() === 'parallel') {
$('.content-wrapper .container-fluid').removeClass('container-limited');
$('.content-wrapper .container-fluid').removeClass('container-limited');
}
}
$(document)
$(document)
.off('click', '.js-unfold')
.off('click', '.js-unfold, .diff-line-num a')
.on('click', '.js-unfold', (event) => {
.on('click', '.js-unfold', this.handleClickUnfold.bind(this))
var line_number, link, file, offset, old_line, params, prev_new_line, prev_old_line, ref, ref1, since, target, to, unfold, unfoldBottom;
.on('click', '.diff-line-num a', this.handleClickLineNum.bind(this));
target = $(event.target);
unfoldBottom = target.hasClass('js-unfold-bottom');
this.highlighSelectedLine();
unfold = true;
}
ref = this.lineNumbers(target.parent()), old_line = ref[0], line_number = ref[1];
offset = line_number - old_line;
handleClickUnfold(event) {
if (unfoldBottom) {
const $target = $(event.target);
line_number += 1;
const [oldLineNumber, newLineNumber] = this.lineNumbers($target.parent());
since = line_number;
const offset = newLineNumber - oldLineNumber;
to = line_number + UNFOLD_COUNT;
const bottom = $target.hasClass('js-unfold-bottom');
} else {
let since, to;
ref1 = this.lineNumbers(target.parent().prev()), prev_old_line = ref1[0], prev_new_line = ref1[1];
let unfold = true;
line_number -= 1;
to = line_number;
if (bottom) {
if (line_number - UNFOLD_COUNT > prev_new_line + 1) {
const lineNumber = newLineNumber + 1;
since = line_number - UNFOLD_COUNT;
since = lineNumber;
to = lineNumber + UNFOLD_COUNT;
} else {
} else {
since = prev_new_line + 1;
const lineNumber = newLineNumber - 1;
since = lineNumber - UNFOLD_COUNT;
to = lineNumber;
// make sure we aren't loading more than we need
const [prevOldLine, prevNewLine] = this.lineNumbers($target.parent().prev());
if (since <= prevNewLine + 1) {
since = prevNewLine + 1;
unfold = false;
unfold = false;
}
}
}
}
file = target.parents('.diff-file');
link = file.data('blob-diff-path');
const file = $target.parents('.diff-file');
params = {
const link = file.data('blob-diff-path');
since: since,
const view = file.data('view');
to: to,
bottom: unfoldBottom,
const params = { since, to, bottom, offset, unfold, view };
offset: offset,
$.get(link, params, (response) => $target.parent().replaceWith(response));
unfold: unfold,
}
view: file.data('view')
};
handleClickLineNum(event) {
return $.get(link, params, function(response) {
const hash = $(event.currentTarget).attr('href');
return target.parent().replaceWith(response);
});
})
.off('click', '.diff-line-num a')
.on('click', '.diff-line-num a', (event) => {
var hash = $(event.currentTarget).attr('href');
event.preventDefault();
event.preventDefault();
if ( history.pushState
) {
if (history.pushState
) {
history.pushState(null, null, hash);
history.pushState(null, null, hash);
} else {
} else {
window.location.hash = hash;
window.location.hash = hash;
}
}
this.highlighSelectedLine();
this.highlighSelectedLine();
});
};
this.highlighSelectedLine();
}
diffViewType() {
diffViewType() {
return $('.inline-parallel-buttons a.active').data('view-type');
return $('.inline-parallel-buttons a.active').data('view-type');
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment