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
Jérome Perrin
gitlab-ce
Commits
4f107f3f
Commit
4f107f3f
authored
Oct 25, 2016
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor Diff to es6 class syntax
parent
6cbc305d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
42 deletions
+35
-42
app/assets/javascripts/diff.js.es6
app/assets/javascripts/diff.js.es6
+29
-36
app/assets/javascripts/dispatcher.js.es6
app/assets/javascripts/dispatcher.js.es6
+5
-5
app/assets/javascripts/merge_request_tabs.js.es6
app/assets/javascripts/merge_request_tabs.js.es6
+1
-1
No files found.
app/assets/javascripts/diff.js
→
app/assets/javascripts/diff.js
.es6
View file @
4f107f3f
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, max-len, one-var, camelcase, one-var-declaration-per-line, no-unused-vars, no-unused-expressions, no-sequences, object-shorthand, comma-dangle, prefer-arrow-callback, semi, radix, padded-blocks, max-len */
/* eslint-disable */
(
function
()
{
this
.
Diff
=
(
function
()
{
var
UNFOLD_COUNT
;
UNFOLD_COUNT
=
20
;
((global) => {
const UNFOLD_COUNT = 20;
function
Diff
()
{
class Diff {
constructor() {
$('.files .diff-file').singleFileDiff();
$('.files .diff-file').singleFileDiff();
this
.
filesCommentButton
=
$
(
'
.files .diff-file
'
).
filesCommentButton
();
$('.files .diff-file').filesCommentButton();
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')
.
on
(
'
click
'
,
'
.js-unfold
'
,
(
function
(
event
)
{
.on('click', '.js-unfold', (
event) =>
{
var line_number, link, file, offset, old_line, params, prev_new_line, prev_old_line, ref, ref1, since, target, to, unfold, unfoldBottom;
var line_number, link, file, offset, old_line, params, prev_new_line, prev_old_line, ref, ref1, since, target, to, unfold, unfoldBottom;
target = $(event.target);
target = $(event.target);
unfoldBottom = target.hasClass('js-unfold-bottom');
unfoldBottom = target.hasClass('js-unfold-bottom');
...
@@ -48,29 +48,27 @@
...
@@ -48,29 +48,27 @@
return $.get(link, params, function(response) {
return $.get(link, params, function(response) {
return target.parent().replaceWith(response);
return target.parent().replaceWith(response);
});
});
}).
bind
(
this
));
})
$
(
document
)
.off('click', '.diff-line-num a')
.off('click', '.diff-line-num a')
.
on
(
'
click
'
,
'
.diff-line-num a
'
,
(
function
(
e
)
{
.on('click', '.diff-line-num a', (
event) =>
{
var
hash
=
$
(
e
.
currentTarget
).
attr
(
'
href
'
);
var hash = $(e
vent
.currentTarget).attr('href');
e
.
preventDefault
();
e
vent
.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();
})
.
bind
(
this
))
;
});
this.highlighSelectedLine();
this.highlighSelectedLine();
}
}
Diff
.
prototype
.
diffViewType
=
function
()
{
diffViewType
() {
return $('.inline-parallel-buttons a.active').data('view-type');
return $('.inline-parallel-buttons a.active').data('view-type');
}
}
Diff
.
prototype
.
lineNumbers
=
function
(
line
)
{
lineNumbers
(line) {
if (!line.children().length) {
if (!line.children().length) {
return [0, 0];
return [0, 0];
}
}
...
@@ -78,26 +76,21 @@
...
@@ -78,26 +76,21 @@
return line.find('.diff-line-num').map(function() {
return line.find('.diff-line-num').map(function() {
return parseInt($(this).data('linenumber'));
return parseInt($(this).data('linenumber'));
});
});
}
;
}
Diff
.
prototype
.
highlighSelectedLine
=
function
()
{
highlighSelectedLine() {
var
$diffLine
,
dataLineString
,
locationHash
;
const $diffFiles = $('.diff-file');
$
(
'
.hll
'
).
removeClass
(
'
hll
'
);
$diffFiles.find('.hll').removeClass('hll');
locationHash
=
window
.
location
.
hash
;
if
(
locationHash
!==
''
)
{
dataLineString
=
'
[data-line-code="
'
+
locationHash
.
replace
(
'
#
'
,
''
)
+
'
"]
'
;
$diffLine
=
$
(
"
.diff-file
"
+
locationHash
+
"
:not(.match)
"
);
if
(
!
$diffLine
.
is
(
'
tr
'
))
{
$diffLine
=
$
(
"
.diff-file td
"
+
locationHash
+
"
, .diff-file td
"
+
dataLineString
);
}
else
{
$diffLine
=
$diffLine
.
find
(
'
td
'
);
}
$diffLine
.
addClass
(
'
hll
'
);
}
};
return
Diff
;
if (window.location.hash !== '') {
const hash = window.location.hash.replace('#', '');
$diffFiles
.find(`tr#${hash}:not(.match) td, td#${hash}, td[data-line-code="${hash}"]`)
.addClass('hll');
}
}
}
})()
;
global.Diff = Diff
;
})
.
call
(
this
);
})
(window.gl || (window.gl = {})
);
app/assets/javascripts/dispatcher.js.es6
View file @
4f107f3f
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
new ZenMode();
new ZenMode();
break;
break;
case 'projects:compare:show':
case 'projects:compare:show':
new Diff();
new
gl.
Diff();
break;
break;
case 'projects:issues:new':
case 'projects:issues:new':
case 'projects:issues:edit':
case 'projects:issues:edit':
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
break;
break;
case 'projects:merge_requests:new':
case 'projects:merge_requests:new':
case 'projects:merge_requests:edit':
case 'projects:merge_requests:edit':
new Diff();
new
gl.
Diff();
shortcut_handler = new ShortcutsNavigation();
shortcut_handler = new ShortcutsNavigation();
new GLForm($('.merge-request-form'));
new GLForm($('.merge-request-form'));
new IssuableForm($('.merge-request-form'));
new IssuableForm($('.merge-request-form'));
...
@@ -91,7 +91,7 @@
...
@@ -91,7 +91,7 @@
new GLForm($('.release-form'));
new GLForm($('.release-form'));
break;
break;
case 'projects:merge_requests:show':
case 'projects:merge_requests:show':
new Diff();
new
gl.
Diff();
shortcut_handler = new ShortcutsIssuable(true);
shortcut_handler = new ShortcutsIssuable(true);
new ZenMode();
new ZenMode();
new MergedButtons();
new MergedButtons();
...
@@ -101,7 +101,7 @@
...
@@ -101,7 +101,7 @@
new MergedButtons();
new MergedButtons();
break;
break;
case "projects:merge_requests:diffs":
case "projects:merge_requests:diffs":
new Diff();
new
gl.
Diff();
new ZenMode();
new ZenMode();
new MergedButtons();
new MergedButtons();
break;
break;
...
@@ -117,7 +117,7 @@
...
@@ -117,7 +117,7 @@
break;
break;
case 'projects:commit:show':
case 'projects:commit:show':
new Commit();
new Commit();
new Diff();
new
gl.
Diff();
new ZenMode();
new ZenMode();
shortcut_handler = new ShortcutsNavigation();
shortcut_handler = new ShortcutsNavigation();
break;
break;
...
...
app/assets/javascripts/merge_request_tabs.js.es6
View file @
4f107f3f
...
@@ -239,7 +239,7 @@
...
@@ -239,7 +239,7 @@
this.diffsLoaded = true;
this.diffsLoaded = true;
this.scrollToElement("#diffs");
this.scrollToElement("#diffs");
new Diff();
new
gl.
Diff();
}
}
});
});
}
}
...
...
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