Commit 914bb05d authored by Paco Guzman's avatar Paco Guzman

Moving up common html data attributes

parent e065f484
......@@ -9,6 +9,7 @@ class @FilesCommentButton
@LINE_NUMBER_CLASS = 'diff-line-num'
@LINE_CONTENT_CLASS = 'line_content'
@LINE_COLUMN_CLASSES = ".#{@LINE_NUMBER_CLASS}, .line_content"
@TEXT_FILE_SELECTOR = '.text-file'
@DEBOUNCE_TIMEOUT_DURATION = 150
......@@ -24,21 +25,23 @@ class @FilesCommentButton
return
render: (e) ->
lineHolderElement = @getLineHolder($(e.currentTarget))
lineContentElement = @getLineContent($(e.currentTarget))
lineNumElement = @getLineNum($(e.currentTarget))
currentTarget = $(e.currentTarget)
textFileElement = @getTextFileElement(currentTarget)
lineHolderElement = @getLineHolder(currentTarget)
lineContentElement = @getLineContent(currentTarget)
lineNumElement = @getLineNum(currentTarget)
buttonParentElement = lineNumElement
return if not @shouldRender e, buttonParentElement
buttonParentElement.append @buildButton
id:
noteable: lineHolderElement.attr 'data-noteable-id'
commit: lineHolderElement.attr 'data-commit-id'
noteable: textFileElement.attr 'data-noteable-id'
commit: textFileElement.attr 'data-commit-id'
discussion: lineContentElement.attr('data-discussion-id') || lineHolderElement.attr('data-discussion-id')
type:
noteable: lineHolderElement.attr 'data-noteable-type'
note: lineHolderElement.attr 'data-note-type'
noteable: textFileElement.attr 'data-noteable-type'
note: textFileElement.attr 'data-note-type'
line: lineContentElement.attr 'data-line-type'
code:
line: lineContentElement.attr('data-line-code') || lineHolderElement.attr('id')
......@@ -59,6 +62,9 @@ class @FilesCommentButton
'data-note-type': buttonAttributes.type.note
'data-line-code': buttonAttributes.code.line
getTextFileElement: (hoveredElement) ->
$(hoveredElement.closest(@TEXT_FILE_SELECTOR))
getLineHolder: (hoveredElement) ->
return hoveredElement if hoveredElement.hasClass @LINE_HOLDER_CLASS
$(hoveredElement.parent())
......
- 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 } } : {}
%tr.line_holder{ holder_data, id: line_code, class: type }
- line_data = @comments_target.any? ? { data: { discussion_id: discussion_id(line_code) } } : {}
%tr.line_holder{ line_data, id: line_code, class: type }
- case type
- when 'match'
= render "projects/diffs/match_line", { line: line.text,
......
/ 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
- diff_file.parallel_diff_lines.each do |line|
- left = line[:left]
- 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{ holder_data }
%tr.line_holder.parallel
- if left[:type] == 'match'
= render "projects/diffs/match_line_parallel", { line: left[:text] }
- elsif left[:type] == 'nonewline'
......
......@@ -3,7 +3,8 @@
.suppressed-container
%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
- diff_file.highlighted_diff_lines.each_with_index do |line, index|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment