X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=js%2Futil.js;h=6a67da4bcd25ac82bac1cc13a1854b59dd1c0129;hb=e0da39380024c3d4e7eb9a3ae0c5808ca7dcfb74;hp=d62adf33a7fa85c1332fe42866d14baff9ca7907;hpb=cfeb1bfa419e886a1b60dfcbd4260d2f5de0515b;p=quix0rs-gnu-social.git diff --git a/js/util.js b/js/util.js index d62adf33a7..6a67da4bcd 100644 --- a/js/util.js +++ b/js/util.js @@ -30,8 +30,7 @@ var SN = { // StatusNet CounterBlackout: false, MaxLength: 140, PatternUsername: /^[0-9a-zA-Z\-_.]*$/, - HTTP20x30x: [200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307], - UploadCounter: 0 + HTTP20x30x: [200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307] }, S: { // Selector @@ -85,7 +84,7 @@ var SN = { // StatusNet form.find('#'+SN.C.S.NoticeTextCount).text(jQuery.data(form[0], 'ElementData').MaxLength); } - if ($('body')[0].id != 'conversation' && window.location.hash.length === 0) { + if ($('body')[0].id != 'conversation' && window.location.hash.length === 0 && $(window).scrollTop() == 0) { form.find('textarea').focus(); } }, @@ -173,7 +172,6 @@ var SN = { // StatusNet FormNoticeXHR: function(form) { SN.C.I.NoticeDataGeo = {}; form.append(''); - form.ajaxForm({ dataType: 'xml', timeout: '60000', @@ -230,10 +228,9 @@ var SN = { // StatusNet } else { if (parseInt(xhr.status) === 0 || jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) >= 0) { - form.resetForm(); - SN.U.NoticeClearAttachments(form); - SN.C.I.UploadCounter = 0; - SN.U.NoticeNewAttachment($('fieldset', form)); + form + .resetForm() + .find('#'+SN.C.S.NoticeDataAttachSelected).remove(); SN.U.FormNoticeEnhancements(form); } else { @@ -261,9 +258,10 @@ var SN = { // StatusNet form.append('
'+result+'
'); } 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'); - if (notices.length > 0) { - var notice = document._importNode($('li', data)[0], true); + if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) { if ($('#'+notice.id).length === 0) { var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val(); var notice_irt = '#notices_primary #notice-'+notice_irt_value; @@ -284,15 +282,16 @@ var SN = { // StatusNet } } else { + // Not on a timeline that this belongs on? + // Just show a success message. result = document._importNode($('title', data)[0], true); result_title = result.textContent || result.innerHTML; form.append(''+result_title+'
'); } } form.resetForm(); - SN.U.NoticeClearAttachments(form); - SN.C.I.UploadCounter = 0; - SN.U.NoticeNewAttachment($('fieldset', form)); + form.find('#'+SN.C.S.NoticeInReplyTo).val(''); + form.find('#'+SN.C.S.NoticeDataAttachSelected).remove(); SN.U.FormNoticeEnhancements(form); } }, @@ -313,11 +312,6 @@ var SN = { // StatusNet } }); }, - - NoticeClearAttachments: function(form) { - $('input:file', form).remove(); - $('div[class=' + SN.C.S.Success + ']', form).remove(); - }, NoticeReply: function() { if ($('#'+SN.C.S.NoticeDataText).length > 0 && $('#content .notice_reply').length > 0) { @@ -477,31 +471,25 @@ var SN = { // StatusNet } }, - NoticeDataAttach: function(NDANum) { - NDA = $('#'+SN.C.S.NoticeDataAttach+NDANum); + NoticeDataAttach: function() { + NDA = $('#'+SN.C.S.NoticeDataAttach); NDA.change(function() { - S = ''+$(this).val()+'
'+$(this).val()+'