summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bennett <lukeeeebennettplus@gmail.com>2016-08-05 13:02:08 +0100
committerLuke Bennett <lukeeeebennettplus@gmail.com>2016-08-23 15:13:01 +0100
commit7d654c0e1810f2023a1deaeddd542c5c92d20f42 (patch)
treeb189117ca86ce1cef5b540b8e7b6d6b08b48484d
parent9b079219730516ae971a4cdc0d68f75b99ff4de1 (diff)
downloadgitlab-ce-7d654c0e1810f2023a1deaeddd542c5c92d20f42.tar.gz
Added addtional 'renderable' validator to check 'data-note-type' attr exists
-rw-r--r--app/assets/javascripts/files_comment_button.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/assets/javascripts/files_comment_button.js b/app/assets/javascripts/files_comment_button.js
index b2e49b71fec..817d38ea86e 100644
--- a/app/assets/javascripts/files_comment_button.js
+++ b/app/assets/javascripts/files_comment_button.js
@@ -39,12 +39,13 @@
FilesCommentButton.prototype.render = function(e) {
var $currentTarget, buttonParentElement, lineContentElement, textFileElement;
$currentTarget = $(e.currentTarget);
+
buttonParentElement = this.getButtonParent($currentTarget);
- if (!this.shouldRender(e, buttonParentElement)) {
- return;
- }
- textFileElement = this.getTextFileElement($currentTarget);
+ if (!this.validateButtonParent(buttonParentElement)) return;
lineContentElement = this.getLineContent($currentTarget);
+ if (!this.validateLineContent(lineContentElement)) return;
+
+ textFileElement = this.getTextFileElement($currentTarget);
buttonParentElement.append(this.buildButton({
noteableType: textFileElement.attr('data-noteable-type'),
noteableID: textFileElement.attr('data-noteable-id'),
@@ -119,10 +120,14 @@
return newButtonParent.is(this.getButtonParent($(e.currentTarget)));
};
- FilesCommentButton.prototype.shouldRender = function(e, buttonParentElement) {
+ FilesCommentButton.prototype.validateButtonParent = function(buttonParentElement) {
return !buttonParentElement.hasClass(EMPTY_CELL_CLASS) && !buttonParentElement.hasClass(UNFOLDABLE_LINE_CLASS) && $(COMMENT_BUTTON_CLASS, buttonParentElement).length === 0;
};
+ FilesCommentButton.prototype.validateLineContent = function(lineContentElement) {
+ return lineContentElement.attr('data-note-type') && lineContentElement.attr('data-note-type') !== '';
+ };
+
return FilesCommentButton;
})();