Inline replies: drop the box if tabbing out and no text

This commit is contained in:
Brion Vibber 2011-03-01 14:24:06 -08:00
parent c0dcd73379
commit e6c972ebcb
2 changed files with 14 additions and 3 deletions

View File

@ -616,6 +616,15 @@ var SN = { // StatusNet
replyForm.find('input[type="submit"]').val(SN.msg('reply_submit'));
list.append(replyItem);
replyForm.find('textarea').blur(function() {
var textarea = $(this);
var txt = $.trim(textarea.val());
if (txt == '' || txt == textarea.data('initialText')) {
// Nothing to say? Begone!
replyItem.remove();
SN.U.NoticeInlineReplyPlaceholder(parentNotice);
}
});
replyForm.submit(function(event) {
var form = replyForm;
$.ajax({
@ -660,10 +669,12 @@ var SN = { // StatusNet
if (text.length == 0) {
throw "No textarea";
}
var replyto = '';
if (initialText) {
var replyto = initialText + ' ';
text.val(replyto + text.val().replace(RegExp(replyto, 'i'), ''));
replyto = initialText + ' ';
}
text.val(replyto + text.val().replace(RegExp(replyto, 'i'), ''));
text.data('initialText', $.trim(initialText + ''));
text.focus();
if (text[0].setSelectionRange) {
var len = text.val().length;

2
js/util.min.js vendored

File diff suppressed because one or more lines are too long