+ E: { /* Events */
+ /* SN.E.ajaxNoticePosted, called when a notice has been posted successfully via an AJAX form
+ @param form the originating form element
+ @param data data from success() callback
+ @param textStatus textStatus from success() callback
+ */
+ ajaxNoticePosted: function (form, data, textStatus) {
+ var commandResult = $('#' + SN.C.S.CommandResult, data);
+ if (commandResult.length > 0) {
+ SN.U.showFeedback(form, 'success', commandResult.text());
+ } else {
+ // 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');
+ var replyItem = form.closest('li.notice-reply');
+
+ if (replyItem.length > 0) {
+ // If this is an inline reply, remove the form...
+ var list = form.closest('.threaded-replies');
+
+ var id = $(notice).attr('id');
+ if ($('#' + id).length == 0) {
+ $(notice).insertBefore(replyItem);
+ } // 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;
+ if ($('body')[0].id == 'conversation') {
+ if (notice_irt_value.length > 0 && $(notice_irt + ' .notices').length < 1) {
+ $(notice_irt).append('<ul class="notices"></ul>');
+ }
+ $($(notice_irt + ' .notices')[0]).append(notice);
+ } else {
+ notices.prepend(notice);
+ }
+ $('#' + notice.id)
+ .css({display: 'none'})
+ .fadeIn(2500);
+ SN.U.NoticeWithAttachment($('#' + notice.id));
+ SN.U.switchInputFormTab(null);
+ }
+ } else {
+ // Not on a timeline that this belongs on?
+ // Just show a success message.
+ // @fixme inline
+ SN.U.showFeedback(form, 'success', $('title', data).text());
+ }
+ }
+ form.resetForm();
+ form.find('[name=inreplyto]').val('');
+ form.find('.attach-status').remove();
+ SN.U.FormNoticeEnhancements(form);
+
+ SN.U.runCallbacks('notice_posted', {"notice": notice});
+ },
+ },
+
+