From eb9514120a882aacae38f8b85a1f431852b44b89 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 5 Jan 2010 01:15:08 +0000 Subject: Retain the geo data when FormNoticeXHR is complete because form gets reset --- js/util.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index a2212cac2..d84d21582 100644 --- a/js/util.js +++ b/js/util.js @@ -178,12 +178,13 @@ var SN = { // StatusNet }, FormNoticeXHR: function(form) { + var NDG, NLat, NLon, NLNS, NLID; form_id = form.attr('id'); form.append(''); form.ajaxForm({ dataType: 'xml', timeout: '60000', - beforeSend: function(xhr) { + beforeSend: function(formData) { if ($('#'+form_id+' #'+SN.C.S.NoticeDataText)[0].value.length === 0) { form.addClass(SN.C.S.Warning); return false; @@ -191,6 +192,13 @@ var SN = { // StatusNet form.addClass(SN.C.S.Processing); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).attr(SN.C.S.Disabled, SN.C.S.Disabled); + + NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked'); + NLat = $('#'+SN.C.S.NoticeLat).val(); + NLon = $('#'+SN.C.S.NoticeLon).val(); + NLNS = $('#'+SN.C.S.NoticeLocationNs).val(); + NLID = $('#'+SN.C.S.NoticeLocationId).val(); + return true; }, error: function (xhr, textStatus, errorThrown) { @@ -273,6 +281,12 @@ var SN = { // StatusNet form.removeClass(SN.C.S.Processing); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled); + + $('#'+SN.C.S.NoticeDataGeo).attr('checked', NDG); + $('#'+SN.C.S.NoticeLat).val(NLat); + $('#'+SN.C.S.NoticeLon).val(NLon); + $('#'+SN.C.S.NoticeLocationNs).val(NLNS); + $('#'+SN.C.S.NoticeLocationId).val(NLID); } }); }, @@ -444,6 +458,8 @@ var SN = { // StatusNet NoticeLocationAttach: function() { var NLat = $('#'+SN.C.S.NoticeLat).val(); var NLon = $('#'+SN.C.S.NoticeLon).val(); + var NLNS = $('#'+SN.C.S.NoticeLocationNs).val(); + var NLID = $('#'+SN.C.S.NoticeLocationId).val(); function removeNoticeDataGeo() { $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); -- cgit v1.2.3-54-g00ecf