Commit c6abeffe authored by Paco Guzman's avatar Paco Guzman

Add the comment diff button where it should be

parent 40398d56
...@@ -35,8 +35,7 @@ class @FilesCommentButton ...@@ -35,8 +35,7 @@ class @FilesCommentButton
textFileElement = @getTextFileElement(currentTarget) textFileElement = @getTextFileElement(currentTarget)
lineHolderElement = @getLineHolder(currentTarget) lineHolderElement = @getLineHolder(currentTarget)
lineContentElement = @getLineContent(currentTarget) lineContentElement = @getLineContent(currentTarget)
lineNumElement = @getLineNum(currentTarget) buttonParentElement = @getButtonParent(currentTarget)
buttonParentElement = lineNumElement
return if not @shouldRender e, buttonParentElement return if not @shouldRender e, buttonParentElement
...@@ -55,7 +54,7 @@ class @FilesCommentButton ...@@ -55,7 +54,7 @@ class @FilesCommentButton
destroy: (e) => destroy: (e) =>
return if @isMovingToSameType e return if @isMovingToSameType e
$(@COMMENT_BUTTON_CLASS, @getLineNum $(e.currentTarget)).remove() $(@COMMENT_BUTTON_CLASS, @getButtonParent $(e.currentTarget)).remove()
return return
buildButton: (buttonAttributes) -> buildButton: (buttonAttributes) ->
...@@ -75,23 +74,25 @@ class @FilesCommentButton ...@@ -75,23 +74,25 @@ class @FilesCommentButton
return hoveredElement if hoveredElement.hasClass @LINE_HOLDER_CLASS return hoveredElement if hoveredElement.hasClass @LINE_HOLDER_CLASS
$(hoveredElement.parent()) $(hoveredElement.parent())
getLineNum: (hoveredElement) ->
if @VIEW_TYPE is 'inline' and hoveredElement.hasClass @OLD_LINE_CLASS
$(hoveredElement).next ".#{@LINE_NUMBER_CLASS}"
else if hoveredElement.hasClass @LINE_NUMBER_CLASS
hoveredElement
else
$(hoveredElement).prev ".#{@LINE_NUMBER_CLASS}"
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) ->
if @VIEW_TYPE is 'inline'
return hoveredElement if hoveredElement.hasClass @OLD_LINE_CLASS
$(hoveredElement).parent().find ".#{@OLD_LINE_CLASS}"
else
return hoveredElement if hoveredElement.hasClass @LINE_NUMBER_CLASS
$(hoveredElement).prev ".#{@LINE_NUMBER_CLASS}"
isMovingToSameType: (e) -> isMovingToSameType: (e) ->
newLineNum = @getLineNum($(e.toElement)) newButtonParent = @getButtonParent($(e.toElement))
return false unless newLineNum return false unless newButtonParent
(newLineNum).is @getLineNum($(e.currentTarget)) (newButtonParent).is @getButtonParent($(e.currentTarget))
shouldRender: (e, buttonParentElement) -> shouldRender: (e, buttonParentElement) ->
(!buttonParentElement.hasClass(@EMPTY_CELL_CLASS) and \ (!buttonParentElement.hasClass(@EMPTY_CELL_CLASS) and \
......
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