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
Léo-Paul Géneau
gitlab-ce
Commits
6c978994
Commit
6c978994
authored
Oct 25, 2016
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix diff line highlighting by moving method from the MergeRequestTabs class to the Diff class.
parent
2de245c7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
42 deletions
+48
-42
app/assets/javascripts/diff.js
app/assets/javascripts/diff.js
+37
-7
app/assets/javascripts/merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+11
-35
No files found.
app/assets/javascripts/diff.js
View file @
6c978994
...
@@ -11,21 +11,21 @@
...
@@ -11,21 +11,21 @@
if
(
this
.
diffViewType
()
===
'
parallel
'
)
{
if
(
this
.
diffViewType
()
===
'
parallel
'
)
{
$
(
'
.content-wrapper .container-fluid
'
).
removeClass
(
'
container-limited
'
);
$
(
'
.content-wrapper .container-fluid
'
).
removeClass
(
'
container-limited
'
);
}
}
$
(
document
)
.
off
(
'
click
'
,
'
.js-unfold
'
);
$
(
document
)
$
(
document
).
on
(
'
click
'
,
'
.js-unfold
'
,
(
function
(
_this
)
{
.
off
(
'
click
'
,
'
.js-unfold
'
)
return
function
(
event
)
{
.
on
(
'
click
'
,
'
.js-unfold
'
,
(
function
(
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
'
);
unfold
=
true
;
unfold
=
true
;
ref
=
_
this
.
lineNumbers
(
target
.
parent
()),
old_line
=
ref
[
0
],
line_number
=
ref
[
1
];
ref
=
this
.
lineNumbers
(
target
.
parent
()),
old_line
=
ref
[
0
],
line_number
=
ref
[
1
];
offset
=
line_number
-
old_line
;
offset
=
line_number
-
old_line
;
if
(
unfoldBottom
)
{
if
(
unfoldBottom
)
{
line_number
+=
1
;
line_number
+=
1
;
since
=
line_number
;
since
=
line_number
;
to
=
line_number
+
UNFOLD_COUNT
;
to
=
line_number
+
UNFOLD_COUNT
;
}
else
{
}
else
{
ref1
=
_
this
.
lineNumbers
(
target
.
parent
().
prev
()),
prev_old_line
=
ref1
[
0
],
prev_new_line
=
ref1
[
1
];
ref1
=
this
.
lineNumbers
(
target
.
parent
().
prev
()),
prev_old_line
=
ref1
[
0
],
prev_new_line
=
ref1
[
1
];
line_number
-=
1
;
line_number
-=
1
;
to
=
line_number
;
to
=
line_number
;
if
(
line_number
-
UNFOLD_COUNT
>
prev_new_line
+
1
)
{
if
(
line_number
-
UNFOLD_COUNT
>
prev_new_line
+
1
)
{
...
@@ -48,8 +48,22 @@
...
@@ -48,8 +48,22 @@
return
$
.
get
(
link
,
params
,
function
(
response
)
{
return
$
.
get
(
link
,
params
,
function
(
response
)
{
return
target
.
parent
().
replaceWith
(
response
);
return
target
.
parent
().
replaceWith
(
response
);
});
});
};
}).
bind
(
this
));
})(
this
));
$
(
document
)
.
off
(
'
click
'
,
'
.diff-line-num a
'
)
.
on
(
'
click
'
,
'
.diff-line-num a
'
,
(
function
(
e
)
{
var
hash
=
$
(
e
.
currentTarget
).
attr
(
'
href
'
);
e
.
preventDefault
();
if
(
history
.
pushState
)
{
history
.
pushState
(
null
,
null
,
hash
);
}
else
{
window
.
location
.
hash
=
hash
;
}
this
.
highlighSelectedLine
();
}).
bind
(
this
));
this
.
highlighSelectedLine
();
}
}
Diff
.
prototype
.
diffViewType
=
function
()
{
Diff
.
prototype
.
diffViewType
=
function
()
{
...
@@ -66,6 +80,22 @@
...
@@ -66,6 +80,22 @@
});
});
};
};
Diff
.
prototype
.
highlighSelectedLine
=
function
()
{
var
$diffLine
,
dataLineString
,
locationHash
;
$
(
'
.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
;
return
Diff
;
})();
})();
...
...
app/assets/javascripts/merge_request_tabs.js
View file @
6c978994
...
@@ -76,14 +76,16 @@
...
@@ -76,14 +76,16 @@
}
}
MergeRequestTabs
.
prototype
.
bindEvents
=
function
()
{
MergeRequestTabs
.
prototype
.
bindEvents
=
function
()
{
$
(
document
).
on
(
'
shown.bs.tab
'
,
'
.merge-request-tabs a[data-toggle="tab"]
'
,
this
.
tabShown
);
$
(
document
)
$
(
document
).
on
(
'
click
'
,
'
.js-show-tab
'
,
this
.
showTab
);
.
on
(
'
shown.bs.tab
'
,
'
.merge-request-tabs a[data-toggle="tab"]
'
,
this
.
tabShown
)
};
.
on
(
'
click
'
,
'
.js-show-tab
'
,
this
.
showTab
);
}
MergeRequestTabs
.
prototype
.
unbindEvents
=
function
()
{
MergeRequestTabs
.
prototype
.
unbindEvents
=
function
()
{
$
(
document
).
off
(
'
shown.bs.tab
'
,
'
.merge-request-tabs a[data-toggle="tab"]
'
,
this
.
tabShown
);
$
(
document
)
$
(
document
).
off
(
'
click
'
,
'
.js-show-tab
'
,
this
.
showTab
);
.
off
(
'
shown.bs.tab
'
,
'
.merge-request-tabs a[data-toggle="tab"]
'
,
this
.
tabShown
)
};
.
off
(
'
click
'
,
'
.js-show-tab
'
,
this
.
showTab
);
}
MergeRequestTabs
.
prototype
.
showTab
=
function
(
event
)
{
MergeRequestTabs
.
prototype
.
showTab
=
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
...
@@ -235,45 +237,19 @@
...
@@ -235,45 +237,19 @@
gl
.
utils
.
localTimeAgo
(
$
(
'
.js-timeago
'
,
'
div#diffs
'
));
gl
.
utils
.
localTimeAgo
(
$
(
'
.js-timeago
'
,
'
div#diffs
'
));
$
(
'
#diffs .js-syntax-highlight
'
).
syntaxHighlight
();
$
(
'
#diffs .js-syntax-highlight
'
).
syntaxHighlight
();
$
(
'
#diffs .diff-file
'
).
singleFileDiff
();
if
(
_this
.
diffViewType
()
===
'
parallel
'
&&
(
_this
.
isDiffAction
(
_this
.
currentAction
))
)
{
if
(
_this
.
diffViewType
()
===
'
parallel
'
&&
(
_this
.
isDiffAction
(
_this
.
currentAction
))
)
{
_this
.
expandViewContainer
();
_this
.
expandViewContainer
();
}
}
_this
.
diffsLoaded
=
true
;
_this
.
diffsLoaded
=
true
;
_this
.
scrollToElement
(
"
#diffs
"
);
_this
.
scrollToElement
(
"
#diffs
"
);
_this
.
highlighSelectedLine
();
_this
.
filesCommentButton
=
$
(
'
.files .diff-file
'
).
filesCommentButton
();
new
Diff
();
return
$
(
document
).
off
(
'
click
'
,
'
.diff-line-num a
'
).
on
(
'
click
'
,
'
.diff-line-num a
'
,
function
(
e
)
{
e
.
preventDefault
();
window
.
location
.
hash
=
$
(
e
.
currentTarget
).
attr
(
'
href
'
);
_this
.
highlighSelectedLine
();
return
_this
.
scrollToElement
(
"
#diffs
"
);
});
};
};
})(
this
)
})(
this
)
});
});
};
};
MergeRequestTabs
.
prototype
.
highlighSelectedLine
=
function
()
{
var
$diffLine
,
diffLineTop
,
hashClassString
,
locationHash
,
navBarHeight
;
$
(
'
.hll
'
).
removeClass
(
'
hll
'
);
locationHash
=
window
.
location
.
hash
;
if
(
locationHash
!==
''
)
{
dataLineString
=
'
[data-line-code="
'
+
locationHash
.
replace
(
'
#
'
,
''
)
+
'
"]
'
;
$diffLine
=
$
(
locationHash
+
"
:not(.match)
"
,
$
(
'
#diffs
'
));
if
(
!
$diffLine
.
is
(
'
tr
'
))
{
$diffLine
=
$
(
'
#diffs
'
).
find
(
"
td
"
+
locationHash
+
"
, td
"
+
dataLineString
);
}
else
{
$diffLine
=
$diffLine
.
find
(
'
td
'
);
}
if
(
$diffLine
.
length
)
{
$diffLine
.
addClass
(
'
hll
'
);
diffLineTop
=
$diffLine
.
offset
().
top
;
return
navBarHeight
=
$
(
'
.navbar-gitlab
'
).
outerHeight
();
}
}
};
MergeRequestTabs
.
prototype
.
loadBuilds
=
function
(
source
)
{
MergeRequestTabs
.
prototype
.
loadBuilds
=
function
(
source
)
{
if
(
this
.
buildsLoaded
)
{
if
(
this
.
buildsLoaded
)
{
return
;
return
;
...
...
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