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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
1f73afd0
Commit
1f73afd0
authored
Jul 08, 2016
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Registered FilesCommentButton as a jQuery plugin and made review changes
parent
71e4175f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
64 deletions
+62
-64
app/assets/javascripts/diff.js.coffee
app/assets/javascripts/diff.js.coffee
+1
-1
app/assets/javascripts/files_comment_button.js.coffee
app/assets/javascripts/files_comment_button.js.coffee
+58
-60
app/assets/javascripts/merge_request_tabs.js.coffee
app/assets/javascripts/merge_request_tabs.js.coffee
+1
-1
app/views/projects/diffs/_parallel_view.html.haml
app/views/projects/diffs/_parallel_view.html.haml
+2
-2
No files found.
app/assets/javascripts/diff.js.coffee
View file @
1f73afd0
class
@
Diff
class
@
Diff
UNFOLD_COUNT
=
20
UNFOLD_COUNT
=
20
constructor
:
->
constructor
:
->
@
filesCommentButton
=
new
FilesCommentButton
(
$
(
'.files'
)
)
@
filesCommentButton
=
$
(
'.files .diff-file'
).
filesCommentButton
(
)
$
(
document
).
off
(
'click'
,
'.js-unfold'
)
$
(
document
).
off
(
'click'
,
'.js-unfold'
)
$
(
document
).
on
(
'click'
,
'.js-unfold'
,
(
event
)
=>
$
(
document
).
on
(
'click'
,
'.js-unfold'
,
(
event
)
=>
...
...
app/assets/javascripts/files_comment_button.js.coffee
View file @
1f73afd0
class
@
FilesCommentButton
class
@
FilesCommentButton
constructor
:
(
@
filesContainerElement
)
->
COMMENT_BUTTON_CLASS
=
'.add-diff-note'
return
unless
@
filesContainerElement
COMMENT_BUTTON_TEMPLATE
=
_
.
template
'<button name="button" type="submit" class="btn <%- COMMENT_BUTTON_CLASS %> js-add-diff-note-button" title="Add a comment to this line"><i class="fa fa-comment-o"></i></button>'
return
if
_
.
isUndefined
@
filesContainerElement
.
data
'can-create-note'
LINE_HOLDER_CLASS
=
'.line_holder'
LINE_NUMBER_CLASS
=
'diff-line-num'
@
COMMENT_BUTTON_CLASS
=
'.add-diff-note'
LINE_CONTENT_CLASS
=
'line_content'
@
COMMENT_BUTTON_TEMPLATE
=
_
.
template
'<button name="button" type="submit" class="btn <%- COMMENT_BUTTON_CLASS %> js-add-diff-note-button" title="Add a comment to this line"><i class="fa fa-comment-o"></i></button>'
UNFOLDABLE_LINE_CLASS
=
'js-unfold'
EMPTY_CELL_CLASS
=
'empty-cell'
@
LINE_NUMBER_CLASS
=
'diff-line-num'
OLD_LINE_CLASS
=
'old_line'
@
LINE_CONTENT_CLASS
=
'line_content'
LINE_COLUMN_CLASSES
=
".
#{
LINE_NUMBER_CLASS
}
, .line_content"
@
UNFOLDABLE_LINE_CLASS
=
'js-unfold'
TEXT_FILE_SELECTOR
=
'.text-file'
@
EMPTY_CELL_CLASS
=
'empty-cell'
DEBOUNCE_TIMEOUT_DURATION
=
100
@
OLD_LINE_CLASS
=
'old_line'
@
LINE_COLUMN_CLASSES
=
".
#{
@
LINE_NUMBER_CLASS
}
, .line_content"
@
TEXT_FILE_SELECTOR
=
'.text-file'
@
DEBOUNCE_TIMEOUT_DURATION
=
150
constructor
:
(
@
filesContainerElement
)
->
@
VIEW_TYPE
=
$
(
'input#view[type=hidden]'
).
val
()
@
VIEW_TYPE
=
$
(
'input#view[type=hidden]'
).
val
()
$
(
document
)
debounce
=
_
.
debounce
@
render
,
DEBOUNCE_TIMEOUT_DURATION
.
on
'mouseover'
,
@
LINE_COLUMN_CLASSES
,
@
debounceRender
.
on
'mouseleave'
,
@
LINE_COLUMN_CLASSES
,
@
destroy
debounceRender
:
(
e
)
=>
clearTimeout
@
debounceTimeout
if
@
debounceTimeout
@
debounceTimeout
=
setTimeout
=>
@
render
e
,
@
DEBOUNCE_TIMEOUT_DURATION
return
render
:
(
e
)
->
$
(
document
)
currentTarget
=
$
(
e
.
currentTarget
)
.
on
'mouseover'
,
LINE_COLUMN_CLASSES
,
debounce
textFileElement
=
@
getTextFileElement
(
currentTarget
)
.
on
'mouseleave'
,
LINE_COLUMN_CLASSES
,
@
destroy
lineContentElement
=
@
getLineContent
(
currentTarget
)
buttonParentElement
=
@
getButtonParent
(
currentTarget
)
render
:
(
e
)
=>
$currentTarget
=
$
(
e
.
currentTarget
)
buttonParentElement
=
@
getButtonParent
$currentTarget
return
unless
@
shouldRender
e
,
buttonParentElement
return
unless
@
shouldRender
e
,
buttonParentElement
textFileElement
=
@
getTextFileElement
$currentTarget
lineContentElement
=
@
getLineContent
$currentTarget
buttonParentElement
.
append
@
buildButton
buttonParentElement
.
append
@
buildButton
noteable
_t
ype
:
textFileElement
.
attr
'data-noteable-type'
noteable
T
ype
:
textFileElement
.
attr
'data-noteable-type'
noteable
_id
:
textFileElement
.
attr
'data-noteable-id'
noteable
ID
:
textFileElement
.
attr
'data-noteable-id'
commit
_id
:
textFileElement
.
attr
'data-commit-id'
commit
ID
:
textFileElement
.
attr
'data-commit-id'
note
_t
ype
:
lineContentElement
.
attr
'data-note-type'
note
T
ype
:
lineContentElement
.
attr
'data-note-type'
position
:
lineContentElement
.
attr
'data-position'
position
:
lineContentElement
.
attr
'data-position'
line
_t
ype
:
lineContentElement
.
attr
'data-line-type'
line
T
ype
:
lineContentElement
.
attr
'data-line-type'
discussion
_id
:
lineContentElement
.
attr
'data-discussion-id'
discussion
ID
:
lineContentElement
.
attr
'data-discussion-id'
line
_c
ode
:
lineContentElement
.
attr
'data-line-code'
line
C
ode
:
lineContentElement
.
attr
'data-line-code'
return
return
destroy
:
(
e
)
=>
destroy
:
(
e
)
=>
return
if
@
isMovingToSameType
e
return
if
@
isMovingToSameType
e
$
(
@
COMMENT_BUTTON_CLASS
,
@
getButtonParent
$
(
e
.
currentTarget
)).
remove
()
$
(
COMMENT_BUTTON_CLASS
,
@
getButtonParent
$
(
e
.
currentTarget
)).
remove
()
return
return
buildButton
:
(
buttonAttributes
)
->
buildButton
:
(
buttonAttributes
)
->
initializedButtonTemplate
=
@
COMMENT_BUTTON_TEMPLATE
initializedButtonTemplate
=
COMMENT_BUTTON_TEMPLATE
COMMENT_BUTTON_CLASS
:
@
COMMENT_BUTTON_CLASS
.
substr
1
COMMENT_BUTTON_CLASS
:
COMMENT_BUTTON_CLASS
.
substr
1
$
(
initializedButtonTemplate
).
attr
$
(
initializedButtonTemplate
).
attr
'data-noteable-type'
:
buttonAttributes
.
noteable
_t
ype
'data-noteable-type'
:
buttonAttributes
.
noteable
T
ype
'data-noteable-id'
:
buttonAttributes
.
noteable
_id
'data-noteable-id'
:
buttonAttributes
.
noteable
ID
'data-commit-id'
:
buttonAttributes
.
commit
_id
'data-commit-id'
:
buttonAttributes
.
commit
ID
'data-note-type'
:
buttonAttributes
.
note
_t
ype
'data-note-type'
:
buttonAttributes
.
note
T
ype
'data-line-code'
:
buttonAttributes
.
line
_c
ode
'data-line-code'
:
buttonAttributes
.
line
C
ode
'data-position'
:
buttonAttributes
.
position
'data-position'
:
buttonAttributes
.
position
'data-discussion-id'
:
buttonAttributes
.
discussion
_id
'data-discussion-id'
:
buttonAttributes
.
discussion
ID
'data-line-type'
:
buttonAttributes
.
line
_t
ype
'data-line-type'
:
buttonAttributes
.
line
T
ype
getTextFileElement
:
(
hoveredElement
)
->
getTextFileElement
:
(
hoveredElement
)
->
$
(
hoveredElement
.
closest
(
@
TEXT_FILE_SELECTOR
)
)
$
(
hoveredElement
.
closest
TEXT_FILE_SELECTOR
)
getLineContent
:
(
hoveredElement
)
->
getLineContent
:
(
hoveredElement
)
->
return
hoveredElement
if
hoveredElement
.
hasClass
@
LINE_CONTENT_CLASS
return
hoveredElement
if
hoveredElement
.
hasClass
LINE_CONTENT_CLASS
$
(
hoveredElement
).
next
".
#{
@
LINE_CONTENT_CLASS
}
"
$
(
hoveredElement
).
next
".
#{
LINE_CONTENT_CLASS
}
"
getButtonParent
:
(
hoveredElement
)
->
getButtonParent
:
(
hoveredElement
)
->
if
@
VIEW_TYPE
is
'inline'
if
@
VIEW_TYPE
is
'inline'
return
hoveredElement
if
hoveredElement
.
hasClass
@
OLD_LINE_CLASS
return
hoveredElement
if
hoveredElement
.
hasClass
OLD_LINE_CLASS
$
(
hoveredElement
).
parent
().
find
".
#{
@
OLD_LINE_CLASS
}
"
hoveredElement
.
parent
().
find
".
#{
OLD_LINE_CLASS
}
"
else
else
return
hoveredElement
if
hoveredElement
.
hasClass
@
LINE_NUMBER_CLASS
return
hoveredElement
if
hoveredElement
.
hasClass
LINE_NUMBER_CLASS
$
(
hoveredElement
).
prev
".
#{
@
LINE_NUMBER_CLASS
}
"
$
(
hoveredElement
).
prev
".
#{
LINE_NUMBER_CLASS
}
"
isMovingToSameType
:
(
e
)
->
isMovingToSameType
:
(
e
)
->
newButtonParent
=
@
getButtonParent
(
$
(
e
.
toElement
)
)
newButtonParent
=
@
getButtonParent
$
(
e
.
toElement
)
return
false
unless
newButtonParent
return
false
unless
newButtonParent
(
newButtonParent
).
is
@
getButtonParent
(
$
(
e
.
currentTarget
)
)
newButtonParent
.
is
@
getButtonParent
$
(
e
.
currentTarget
)
shouldRender
:
(
e
,
buttonParentElement
)
->
shouldRender
:
(
e
,
buttonParentElement
)
->
(
!
buttonParentElement
.
hasClass
(
@
EMPTY_CELL_CLASS
)
and
\
(
not
buttonParentElement
.
hasClass
(
EMPTY_CELL_CLASS
)
and
\
!
buttonParentElement
.
hasClass
(
@
UNFOLDABLE_LINE_CLASS
)
and
\
not
buttonParentElement
.
hasClass
(
UNFOLDABLE_LINE_CLASS
)
and
\
$
(
@
COMMENT_BUTTON_CLASS
,
buttonParentElement
).
length
is
0
)
$
(
COMMENT_BUTTON_CLASS
,
buttonParentElement
).
length
is
0
)
$
.
fn
.
filesCommentButton
=
->
return
unless
this
and
@
parent
().
data
(
'can-create-note'
)
?
@
each
->
unless
$
.
data
this
,
'filesCommentButton'
$
.
data
this
,
'filesCommentButton'
,
new
FilesCommentButton
$
(
this
)
app/assets/javascripts/merge_request_tabs.js.coffee
View file @
1f73afd0
...
@@ -163,7 +163,7 @@ class @MergeRequestTabs
...
@@ -163,7 +163,7 @@ class @MergeRequestTabs
@
diffsLoaded
=
true
@
diffsLoaded
=
true
@
scrollToElement
(
"#diffs"
)
@
scrollToElement
(
"#diffs"
)
@
highlighSelectedLine
()
@
highlighSelectedLine
()
@
filesCommentButton
=
new
FilesCommentButton
(
$
(
'.files'
)
)
@
filesCommentButton
=
$
(
'.files .diff-file'
).
filesCommentButton
(
)
$
(
document
)
$
(
document
)
.
off
'click'
,
'.diff-line-num a'
.
off
'click'
,
'.diff-line-num a'
...
...
app/views/projects/diffs/_parallel_view.html.haml
View file @
1f73afd0
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
-
else
-
else
%td
.old_line.diff-line-num
{
id:
left
[
:line_code
],
class:
[
left
[
:type
],
(
'empty-cell'
unless
left
[
:number
])],
data:
{
linenumber:
left
[
:number
]
}}
%td
.old_line.diff-line-num
{
id:
left
[
:line_code
],
class:
[
left
[
:type
],
(
'empty-cell'
unless
left
[
:number
])],
data:
{
linenumber:
left
[
:number
]
}}
%a
{
href:
"##{left[:line_code]}"
}=
raw
(
left
[
:number
])
%a
{
href:
"##{left[:line_code]}"
}=
raw
(
left
[
:number
])
%td
.line_content.parallel.noteable_line
{
class:
[
left
[
:type
],
(
'empty-cell'
if
left
[
:text
].
empty?
)],
data:
diff_view_line_data
(
left
[
:line_code
],
left
[
:position
],
left
[
:type
]
)}=
diff_line_content
(
left
[
:text
])
%td
.line_content.parallel.noteable_line
{
class:
[
left
[
:type
],
(
'empty-cell'
if
left
[
:text
].
empty?
)],
data:
diff_view_line_data
(
left
[
:line_code
],
left
[
:position
],
'old'
)}=
diff_line_content
(
left
[
:text
])
-
if
right
[
:type
]
==
'new'
-
if
right
[
:type
]
==
'new'
-
new_line_type
=
'new'
-
new_line_type
=
'new'
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
%td
.new_line.diff-line-num
{
id:
new_line_code
,
class:
[
new_line_type
,
(
'empty-cell'
unless
right
[
:number
])],
data:
{
linenumber:
right
[
:number
]
}}
%td
.new_line.diff-line-num
{
id:
new_line_code
,
class:
[
new_line_type
,
(
'empty-cell'
unless
right
[
:number
])],
data:
{
linenumber:
right
[
:number
]
}}
%a
{
href:
"##{new_line_code}"
}=
raw
(
right
[
:number
])
%a
{
href:
"##{new_line_code}"
}=
raw
(
right
[
:number
])
%td
.line_content.parallel.noteable_line
{
class:
[
new_line_type
,
(
'empty-cell'
if
right
[
:text
].
empty?
)],
data:
diff_view_line_data
(
new_line_code
,
new_position
,
new_line_type
)}=
diff_line_content
(
right
[
:text
])
%td
.line_content.parallel.noteable_line
{
class:
[
new_line_type
,
(
'empty-cell'
if
right
[
:text
].
empty?
)],
data:
diff_view_line_data
(
new_line_code
,
new_position
,
'new'
)}=
diff_line_content
(
right
[
:text
])
-
unless
@diff_notes_disabled
-
unless
@diff_notes_disabled
-
notes_left
,
notes_right
=
organize_comments
(
left
,
right
)
-
notes_left
,
notes_right
=
organize_comments
(
left
,
right
)
...
...
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