Fix comments form for new results [SCI-2877]

This commit is contained in:
Oleksii Kriuchykhin 2018-11-21 23:48:43 +01:00
parent afe5db5cf3
commit 6cd033767c
3 changed files with 2 additions and 33 deletions

View file

@ -22,7 +22,6 @@ var Comments = (function() {
beforeSend: animateSpinner(that, true) }) beforeSend: animateSpinner(that, true) })
.done(function(data) { .done(function(data) {
that.html(data.html); that.html(data.html);
}) })
.always(function() { .always(function() {
animateSpinner(that, false); animateSpinner(that, false);
@ -51,7 +50,7 @@ var Comments = (function() {
// Initialize show more comments link. // Initialize show more comments link.
function initCommentsLink($el) { function initCommentsLink($el) {
$el.find('.btn-more-comments') $el.find('.btn-more-comments').off()
.on('ajax:success', function (e, data) { .on('ajax:success', function (e, data) {
if (data.html) { if (data.html) {
var list = $(this).parents('ul'); var list = $(this).parents('ul');
@ -92,7 +91,7 @@ var Comments = (function() {
$('.help-block', $form).addClass('hide'); $('.help-block', $form).addClass('hide');
$form.on('ajax:send', function () { $form.off().on('ajax:send', function () {
$('#comment_message', $form).attr('readonly', true); $('#comment_message', $form).attr('readonly', true);
}) })
.on('ajax:success', function (e, data) { .on('ajax:success', function (e, data) {
@ -164,33 +163,6 @@ var Comments = (function() {
}); });
} }
// restore comments after update or when new element is created
function bindCommentInitializerToNewElement() {
if( document.getElementById('steps') !== null ) {
$('#steps')
.change(function() {
$('.step-save')
.on('click', function() {
$(document)
.on('ajax:success', function(){
initializeComments();
});
});
});
} else if ( document.getElementById('results') !== null ) {
$('#results')
.change(function() {
$('.save-result')
.on('click', function() {
$(document)
.on('ajax:success', function(){
initializeComments();
});
});
});
}
}
function initCommentOptions(scrollableContainer, useParentOffset) { function initCommentOptions(scrollableContainer, useParentOffset) {
if ( ! _.isUndefined(useParentOffset) ) { if ( ! _.isUndefined(useParentOffset) ) {
useParentOffset = useParentOffset; useParentOffset = useParentOffset;
@ -377,7 +349,6 @@ var Comments = (function() {
scrollBottom: scrollBottom, scrollBottom: scrollBottom,
moreComments: initCommentsLink, moreComments: initCommentsLink,
form: initCommentForm, form: initCommentForm,
bindNewElement: bindCommentInitializerToNewElement,
initCommentOptions: initCommentOptions, initCommentOptions: initCommentOptions,
initDeleteComments: initDeleteComments, initDeleteComments: initDeleteComments,
initEditComments: initEditComments initEditComments: initEditComments

View file

@ -16,7 +16,6 @@ function init() {
initLoadFromRepository(); initLoadFromRepository();
initRefreshStatusBar(); initRefreshStatusBar();
initImport(); initImport();
Comments.bindNewElement();
setupAssetsLoading(); setupAssetsLoading();
} }

View file

@ -17,7 +17,6 @@
_expandAllResults(); _expandAllResults();
applyCollapseLinkCallBack(); applyCollapseLinkCallBack();
Comments.bindNewElement();
Comments.initialize(); Comments.initialize();
Comments.initCommentOptions('ul.content-comments'); Comments.initCommentOptions('ul.content-comments');