Make inline reply forms close when clicking outside them if there's no text again.

(That went away when we switched to reusing the main notice form)
This commit is contained in:
Brion Vibber 2011-03-10 16:06:01 -08:00
parent ac880bd6ea
commit 6b5b6d072b
2 changed files with 23 additions and 1 deletions

View File

@ -640,6 +640,7 @@ var SN = { // StatusNet
'</li>');
placeholder.click(function() {
SN.U.NoticeInlineReplyTrigger(notice);
return false;
});
placeholder.find('input').val(SN.msg('reply_placeholder'));
list.append(placeholder);
@ -1309,6 +1310,27 @@ var SN = { // StatusNet
var form = $(this);
SN.Init.NoticeFormSetup(form);
});
// Make inline reply forms self-close when clicking out.
$('body').bind('click', function(e) {
var openReplies = $('li.notice-reply');
if (openReplies.length > 0) {
var target = $(e.target).closest('li.notice-reply');
if (target.length == 0) {
// There are inline replies open, and we
// clicked outside of one...
openReplies.each(function() {
var replyItem = $(this);
// Only close if there's been no edit.
if (replyItem.find('.notice_data-text:first').val() == '') {
var parentNotice = replyItem.closest('li.notice');
replyItem.remove();
SN.U.NoticeInlineReplyPlaceholder(parentNotice);
}
});
}
}
});
}
},

2
js/util.min.js vendored

File diff suppressed because one or more lines are too long