summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2016-07-08 01:33:33 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2016-07-08 01:35:29 +0100
commitec37d9553274e3bca58e4de44b932cdc72a37325 (patch)
treeb8f787748ef7699de0215df3416fa9a707a40e2e /app
parentd1d74814e35cbff4234fceb1f9333ba76cc91f30 (diff)
downloadgitlab-ce-ec37d9553274e3bca58e4de44b932cdc72a37325.tar.gz
Refactored .prev and .next methods
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/files_comment_button.js.coffee10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/assets/javascripts/files_comment_button.js.coffee b/app/assets/javascripts/files_comment_button.js.coffee
index 2b9dc6419d5..db0bf7082a9 100644
--- a/app/assets/javascripts/files_comment_button.js.coffee
+++ b/app/assets/javascripts/files_comment_button.js.coffee
@@ -7,6 +7,7 @@ class @FilesCommentButton
UNFOLDABLE_LINE_CLASS = 'js-unfold'
EMPTY_CELL_CLASS = 'empty-cell'
OLD_LINE_CLASS = 'old_line'
+ NEW_CLASS = 'new'
LINE_COLUMN_CLASSES = ".#{LINE_NUMBER_CLASS}, .line_content"
TEXT_FILE_SELECTOR = '.text-file'
DEBOUNCE_TIMEOUT_DURATION = 100
@@ -63,17 +64,20 @@ class @FilesCommentButton
getLineContent: (hoveredElement) ->
return hoveredElement if hoveredElement.hasClass LINE_CONTENT_CLASS
- $(hoveredElement).next ".#{LINE_CONTENT_CLASS}"
+ $(".#{LINE_CONTENT_CLASS + @diffTypeClass hoveredElement}", hoveredElement.parent())
getButtonParent: (hoveredElement) ->
if @VIEW_TYPE is 'inline'
return hoveredElement if hoveredElement.hasClass OLD_LINE_CLASS
- hoveredElement.parent().find ".#{OLD_LINE_CLASS}"
+ $(".#{OLD_LINE_CLASS}", hoveredElement.parent())
else
return hoveredElement if hoveredElement.hasClass LINE_NUMBER_CLASS
- $(hoveredElement).prev ".#{LINE_NUMBER_CLASS}"
+ $(".#{LINE_NUMBER_CLASS + @diffTypeClass hoveredElement}", hoveredElement.parent())
+
+ diffTypeClass: (hoveredElement) ->
+ if hoveredElement.hasClass(NEW_CLASS) then '.new' else '.old'
isMovingToSameType: (e) ->
newButtonParent = @getButtonParent $(e.toElement)