Using jQuery chaining in FormNoticeXHR

This commit is contained in:
Sarven Capadisli 2010-01-30 15:19:13 +01:00
parent bb0bf635d8
commit aa3170cf34
1 changed files with 21 additions and 13 deletions

View File

@ -189,9 +189,11 @@ var SN = { // StatusNet
form.addClass(SN.C.S.Warning); form.addClass(SN.C.S.Warning);
return false; return false;
} }
form.addClass(SN.C.S.Processing); form
form.find('#'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled); .addClass(SN.C.S.Processing)
form.find('#'+SN.C.S.NoticeActionSubmit).attr(SN.C.S.Disabled, SN.C.S.Disabled); .find('#'+SN.C.S.NoticeActionSubmit)
.addClass(SN.C.S.Disabled)
.attr(SN.C.S.Disabled, SN.C.S.Disabled);
NLat = $('#'+SN.C.S.NoticeLat).val(); NLat = $('#'+SN.C.S.NoticeLat).val();
NLon = $('#'+SN.C.S.NoticeLon).val(); NLon = $('#'+SN.C.S.NoticeLon).val();
@ -220,9 +222,11 @@ var SN = { // StatusNet
return true; return true;
}, },
error: function (xhr, textStatus, errorThrown) { error: function (xhr, textStatus, errorThrown) {
form.removeClass(SN.C.S.Processing); form
form.find('#'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled); .removeClass(SN.C.S.Processing)
form.find('#'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled, SN.C.S.Disabled); .find('#'+SN.C.S.NoticeActionSubmit)
.removeClass(SN.C.S.Disabled)
.removeAttr(SN.C.S.Disabled, SN.C.S.Disabled);
form.find('.form_response').remove(); form.find('.form_response').remove();
if (textStatus == 'timeout') { if (textStatus == 'timeout') {
form.append('<p class="form_response error">Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.</p>'); form.append('<p class="form_response error">Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.</p>');
@ -233,8 +237,9 @@ var SN = { // StatusNet
} }
else { else {
if (parseInt(xhr.status) === 0 || jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) >= 0) { if (parseInt(xhr.status) === 0 || jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) >= 0) {
form.resetForm(); form
form.find('#'+SN.C.S.NoticeDataAttachSelected).remove(); .resetForm()
.find('#'+SN.C.S.NoticeDataAttachSelected).remove();
SN.U.FormNoticeEnhancements(form); SN.U.FormNoticeEnhancements(form);
} }
else { else {
@ -277,8 +282,9 @@ var SN = { // StatusNet
else { else {
notices.prepend(notice); notices.prepend(notice);
} }
$('#'+notice.id).css({display:'none'}); $('#'+notice.id)
$('#'+notice.id).fadeIn(2500); .css({display:'none'})
.fadeIn(2500);
SN.U.NoticeWithAttachment($('#'+notice.id)); SN.U.NoticeWithAttachment($('#'+notice.id));
SN.U.NoticeReplyTo($('#'+notice.id)); SN.U.NoticeReplyTo($('#'+notice.id));
SN.U.FormXHR($('#'+notice.id+' .form_favor')); SN.U.FormXHR($('#'+notice.id+' .form_favor'));
@ -297,9 +303,11 @@ var SN = { // StatusNet
} }
}, },
complete: function(xhr, textStatus) { complete: function(xhr, textStatus) {
form.removeClass(SN.C.S.Processing); form
form.find('#'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled); .removeClass(SN.C.S.Processing)
form.find('#'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled); .find('#'+SN.C.S.NoticeActionSubmit)
.removeAttr(SN.C.S.Disabled)
.removeClass(SN.C.S.Disabled);
$('#'+SN.C.S.NoticeLat).val(NLat); $('#'+SN.C.S.NoticeLat).val(NLat);
$('#'+SN.C.S.NoticeLon).val(NLon); $('#'+SN.C.S.NoticeLon).val(NLon);