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
914bb05d
Commit
914bb05d
authored
Jul 01, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving up common html data attributes
parent
e065f484
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
13 deletions
+20
-13
app/assets/javascripts/files_comment_button.js.coffee
app/assets/javascripts/files_comment_button.js.coffee
+13
-7
app/views/projects/diffs/_line.html.haml
app/views/projects/diffs/_line.html.haml
+2
-2
app/views/projects/diffs/_parallel_view.html.haml
app/views/projects/diffs/_parallel_view.html.haml
+3
-3
app/views/projects/diffs/_text_file.html.haml
app/views/projects/diffs/_text_file.html.haml
+2
-1
No files found.
app/assets/javascripts/files_comment_button.js.coffee
View file @
914bb05d
...
@@ -9,6 +9,7 @@ class @FilesCommentButton
...
@@ -9,6 +9,7 @@ class @FilesCommentButton
@
LINE_NUMBER_CLASS
=
'diff-line-num'
@
LINE_NUMBER_CLASS
=
'diff-line-num'
@
LINE_CONTENT_CLASS
=
'line_content'
@
LINE_CONTENT_CLASS
=
'line_content'
@
LINE_COLUMN_CLASSES
=
".
#{
@
LINE_NUMBER_CLASS
}
, .line_content"
@
LINE_COLUMN_CLASSES
=
".
#{
@
LINE_NUMBER_CLASS
}
, .line_content"
@
TEXT_FILE_SELECTOR
=
'.text-file'
@
DEBOUNCE_TIMEOUT_DURATION
=
150
@
DEBOUNCE_TIMEOUT_DURATION
=
150
...
@@ -24,21 +25,23 @@ class @FilesCommentButton
...
@@ -24,21 +25,23 @@ class @FilesCommentButton
return
return
render
:
(
e
)
->
render
:
(
e
)
->
lineHolderElement
=
@
getLineHolder
(
$
(
e
.
currentTarget
))
currentTarget
=
$
(
e
.
currentTarget
)
lineContentElement
=
@
getLineContent
(
$
(
e
.
currentTarget
))
textFileElement
=
@
getTextFileElement
(
currentTarget
)
lineNumElement
=
@
getLineNum
(
$
(
e
.
currentTarget
))
lineHolderElement
=
@
getLineHolder
(
currentTarget
)
lineContentElement
=
@
getLineContent
(
currentTarget
)
lineNumElement
=
@
getLineNum
(
currentTarget
)
buttonParentElement
=
lineNumElement
buttonParentElement
=
lineNumElement
return
if
not
@
shouldRender
e
,
buttonParentElement
return
if
not
@
shouldRender
e
,
buttonParentElement
buttonParentElement
.
append
@
buildButton
buttonParentElement
.
append
@
buildButton
id
:
id
:
noteable
:
lineHolder
Element
.
attr
'data-noteable-id'
noteable
:
textFile
Element
.
attr
'data-noteable-id'
commit
:
lineHolder
Element
.
attr
'data-commit-id'
commit
:
textFile
Element
.
attr
'data-commit-id'
discussion
:
lineContentElement
.
attr
(
'data-discussion-id'
)
||
lineHolderElement
.
attr
(
'data-discussion-id'
)
discussion
:
lineContentElement
.
attr
(
'data-discussion-id'
)
||
lineHolderElement
.
attr
(
'data-discussion-id'
)
type
:
type
:
noteable
:
lineHolder
Element
.
attr
'data-noteable-type'
noteable
:
textFile
Element
.
attr
'data-noteable-type'
note
:
lineHolder
Element
.
attr
'data-note-type'
note
:
textFile
Element
.
attr
'data-note-type'
line
:
lineContentElement
.
attr
'data-line-type'
line
:
lineContentElement
.
attr
'data-line-type'
code
:
code
:
line
:
lineContentElement
.
attr
(
'data-line-code'
)
||
lineHolderElement
.
attr
(
'id'
)
line
:
lineContentElement
.
attr
(
'data-line-code'
)
||
lineHolderElement
.
attr
(
'id'
)
...
@@ -59,6 +62,9 @@ class @FilesCommentButton
...
@@ -59,6 +62,9 @@ class @FilesCommentButton
'data-note-type'
:
buttonAttributes
.
type
.
note
'data-note-type'
:
buttonAttributes
.
type
.
note
'data-line-code'
:
buttonAttributes
.
code
.
line
'data-line-code'
:
buttonAttributes
.
code
.
line
getTextFileElement
:
(
hoveredElement
)
->
$
(
hoveredElement
.
closest
(
@
TEXT_FILE_SELECTOR
))
getLineHolder
:
(
hoveredElement
)
->
getLineHolder
:
(
hoveredElement
)
->
return
hoveredElement
if
hoveredElement
.
hasClass
@
LINE_HOLDER_CLASS
return
hoveredElement
if
hoveredElement
.
hasClass
@
LINE_HOLDER_CLASS
$
(
hoveredElement
.
parent
())
$
(
hoveredElement
.
parent
())
...
...
app/views/projects/diffs/_line.html.haml
View file @
914bb05d
-
type
=
line
.
type
-
type
=
line
.
type
-
holder_data
=
@comments_target
.
any?
?
{
data:
{
noteable_id:
@comments_target
[
:noteable_id
],
noteable_type:
@comments_target
[
:noteable_type
],
commit_id:
@comments_target
[
:commit_id
],
discussion_id:
discussion_id
(
line_code
),
note_type:
LegacyDiffNote
.
name
}
}
:
{}
-
line_data
=
@comments_target
.
any?
?
{
data:
{
discussion_id:
discussion_id
(
line_code
)
}
}
:
{}
%tr
.line_holder
{
holder
_data
,
id:
line_code
,
class:
type
}
%tr
.line_holder
{
line
_data
,
id:
line_code
,
class:
type
}
-
case
type
-
case
type
-
when
'match'
-
when
'match'
=
render
"projects/diffs/match_line"
,
{
line:
line
.
text
,
=
render
"projects/diffs/match_line"
,
{
line:
line
.
text
,
...
...
app/views/projects/diffs/_parallel_view.html.haml
View file @
914bb05d
/ Side-by-side diff view
/ Side-by-side diff view
%div
.text-file.diff-wrap-lines.code.file-content.js-syntax-highlight
-
text_file_data
=
@comments_target
.
any?
?
{
data:
{
noteable_id:
@comments_target
[
:noteable_id
],
noteable_type:
@comments_target
[
:noteable_type
],
commit_id:
@comments_target
[
:commit_id
],
note_type:
LegacyDiffNote
.
name
}
}
:
{}
%div
.text-file.diff-wrap-lines.code.file-content.js-syntax-highlight
{
text_file_data
}
%table
%table
-
diff_file
.
parallel_diff_lines
.
each
do
|
line
|
-
diff_file
.
parallel_diff_lines
.
each
do
|
line
|
-
left
=
line
[
:left
]
-
left
=
line
[
:left
]
-
right
=
line
[
:right
]
-
right
=
line
[
:right
]
-
holder_data
=
@comments_target
.
any?
?
{
data:
{
noteable_id:
@comments_target
[
:noteable_id
],
noteable_type:
@comments_target
[
:noteable_type
],
commit_id:
@comments_target
[
:commit_id
],
note_type:
LegacyDiffNote
.
name
}
}
:
{}
%tr
.line_holder.parallel
%tr
.line_holder.parallel
{
holder_data
}
-
if
left
[
:type
]
==
'match'
-
if
left
[
:type
]
==
'match'
=
render
"projects/diffs/match_line_parallel"
,
{
line:
left
[
:text
]
}
=
render
"projects/diffs/match_line_parallel"
,
{
line:
left
[
:text
]
}
-
elsif
left
[
:type
]
==
'nonewline'
-
elsif
left
[
:type
]
==
'nonewline'
...
...
app/views/projects/diffs/_text_file.html.haml
View file @
914bb05d
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
.suppressed-container
.suppressed-container
%a
.show-suppressed-diff.js-show-suppressed-diff
Changes suppressed. Click to show.
%a
.show-suppressed-diff.js-show-suppressed-diff
Changes suppressed. Click to show.
%table
.text-file.code.js-syntax-highlight
{
class:
too_big
?
'hide'
:
''
}
-
text_file_data
=
@comments_target
.
any?
?
{
data:
{
noteable_id:
@comments_target
[
:noteable_id
],
noteable_type:
@comments_target
[
:noteable_type
],
commit_id:
@comments_target
[
:commit_id
],
note_type:
LegacyDiffNote
.
name
}
}
:
{}
%table
.text-file.code.js-syntax-highlight
{
text_file_data
,
class:
too_big
?
'hide'
:
''
}
-
last_line
=
0
-
last_line
=
0
-
diff_file
.
highlighted_diff_lines
.
each_with_index
do
|
line
,
index
|
-
diff_file
.
highlighted_diff_lines
.
each_with_index
do
|
line
,
index
|
...
...
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