From: Brion Vibber Date: Fri, 4 Mar 2011 22:58:30 +0000 (-0800) Subject: Work in progress: inline reply form reusing the main reply form now inserts the succe... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a1002cc1078593f899db6c2c2559e0f42f01d725;p=quix0rs-gnu-social.git Work in progress: inline reply form reusing the main reply form now inserts the successful result more or less right --- diff --git a/js/util.js b/js/util.js index 1bd011cb0d..09ab23344b 100644 --- a/js/util.js +++ b/js/util.js @@ -387,7 +387,22 @@ var SN = { // StatusNet // New notice post was successful. If on our timeline, show it! var notice = document._importNode($('li', data)[0], true); var notices = $('#notices_primary .notices:first'); - if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) { + var replyItem = form.closest('li.notice-reply'); + + if (replyItem.length > 0) { + // If this is an inline reply, insert it in place. + var id = $(notice).attr('id'); + if ($("#"+id).length == 0) { + var parentNotice = replyItem.closest('li.notice'); + replyItem.replaceWith(notice); + SN.U.NoticeInlineReplyPlaceholder(parentNotice); + } else { + // Realtime came through before us... + replyItem.remove(); + } + } else if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) { + // Not a reply. If on our timeline, show it at the top! + if ($('#'+notice.id).length === 0) { var notice_irt_value = form.find('[name=inreplyto]').val(); var notice_irt = '#notices_primary #notice-'+notice_irt_value; @@ -406,10 +421,10 @@ var SN = { // StatusNet SN.U.NoticeWithAttachment($('#'+notice.id)); SN.U.NoticeReplyTo($('#'+notice.id)); } - } - else { + } else { // Not on a timeline that this belongs on? // Just show a success message. + // @fixme inline showFeedback('success', $('title', data).text()); } }