Skip to content

Commit b1dc5a7

Browse files
authored
Merge pull request #19 from topcoder-platform/issues-540
Issues-539, Issues-540: cleared comment form
2 parents 65d4507 + a8f8a45 commit b1dc5a7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

js/topcodereditor.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(function($) {
22
var editor;
3+
var allEditors = [];
34
$.fn.setAsEditor = function(selector) {
45
selector = selector || '.BodyBox,.js-bodybox';
56

@@ -564,7 +565,8 @@
564565

565566
// forceSync = true, need to clear form after async requests
566567
$currentEditableTextarea.closest('form').on('complete', function (frm, btn) {
567-
editor.codemirror.setValue('');
568+
var mainEditor = allEditors[0];
569+
mainEditor.codemirror.setValue('');
568570
});
569571

570572
editor.codemirror.on('change', function (cm, event) {
@@ -615,6 +617,11 @@
615617
}
616618
}
617619
});
620+
// We have only one main editor at a page which should used for quote/replyto
621+
// FIX: https://github.com/topcoder-platform/forums/issues/540
622+
if(allEditors.length == 0) {
623+
allEditors.push(editor);
624+
}
618625
}
619626
}; //editorInit
620627

@@ -646,7 +653,8 @@
646653
$(postForm).find('#Form_CategoryID').val(categoryID);
647654
}
648655
var uploads = element.attr("uploads");
649-
editor.enableUploadImages(uploads === "1");
656+
var mainEditor = allEditors[0];
657+
mainEditor.enableUploadImages(uploads === "1");
650658
});
651659

652660
// Preview mode
@@ -664,8 +672,9 @@
664672
});
665673

666674
// Comment with quotes
667-
$(document).on('ApplyQuoteText',function(ev, quoteText) {
668-
var text = editor.value();
669-
editor.value(quoteText + '\n' + text + '\n');
675+
$(document).on('ApplyQuoteText',function(ev, quoteText, ed) {
676+
var mainEditor = allEditors[0];
677+
var text = mainEditor.value();
678+
mainEditor.value(quoteText + '\n' + text + '\n');
670679
});
671680
}(jQuery));

0 commit comments

Comments
 (0)