Skip to content

Commit fcdf9fe

Browse files
author
Martii
committed
Clear reply box on hide
* Use the value instead of the textContent to create the Re: * Clear reply box on hide * Everyone can still use accumulated Re:'s provided they don't cancel the comment reply box * Set focus on initial pop-up and after each click on Reply * Scoot some comments around Closes #153
1 parent 5c3d597 commit fcdf9fe

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

views/includes/scripts/commentReplyScript.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
<script type="text/javascript">
22
(function () {
3-
// Show spacer div
43
$('#reply-control').on('show.bs.collapse', function () {
4+
// Show spacer div
55
$('#show-reply-form-when-visible').css({
66
height: '{{#paginationRendered}}210{{/paginationRendered}}{{^paginationRendered}}268{{/paginationRendered}}px'
77
});
88
});
99

10-
// Hide spacer div
1110
$('#reply-control').on('hide.bs.collapse', function () {
11+
// Hide spacer div
1212
$('#show-reply-form-when-visible').css({
1313
height: '0'
1414
});
15+
16+
// Clear text value from reply box
17+
$('#reply-control textarea[name="comment-content"]').val('');
1518
});
1619

1720
$('.btn-comment-reply').click(function (aE) {
@@ -23,14 +26,15 @@
2326

2427
document.location.hash = $comment.attr('id');
2528

26-
var text = $replyTextarea.text();
27-
if (!/^\s*$/.test(text)) {
28-
text += '\n\n'; // Add linebreak if reply already started.
29+
var value = $replyTextarea.val();
30+
if (!/^\s*$/.test(value)) {
31+
value += '\n\n'; // Add linebreaks if reply already started.
2932
}
30-
text += '[Re](' + document.location.href.replace(/\(/g, '%28').replace(/\)/g, '%29') + '): ';
31-
text += '[@' + $author.text() + '](' + $author.attr('href') + '): ';
32-
text += ' \n';
33-
$replyTextarea.text(text);
33+
value += '[Re](' + document.location.href.replace(/\(/g, '%28').replace(/\)/g, '%29') + '): ';
34+
value += '[@' + $author.text() + '](' + $author.attr('href') + '): ';
35+
value += ' \n';
36+
$replyTextarea.val(value);
37+
$replyTextarea.focus();
3438
});
3539

3640
function isElementInViewport(aEl) {
@@ -53,6 +57,8 @@
5357
if (!hasShownReplyForm) {
5458
$('#reply-control').collapse('show');
5559
hasShownReplyForm = true;
60+
61+
$('#reply-control textarea[name="comment-content"]').focus();
5662
}
5763
}
5864

0 commit comments

Comments
 (0)