forked from GNUsocial/gnu-social
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
This commit is contained in:
commit
91b99863fa
84
js/util.js
84
js/util.js
@ -172,52 +172,56 @@ var SN = { // StatusNet
|
|||||||
},
|
},
|
||||||
|
|
||||||
FormNoticeXHR: function(form) {
|
FormNoticeXHR: function(form) {
|
||||||
var NDG, NLat, NLon, NLNS, NLID;
|
SN.C.I.NoticeDataGeo = {};
|
||||||
form_id = form.attr('id');
|
form_id = form.attr('id');
|
||||||
form.append('<input type="hidden" name="ajax" value="1"/>');
|
form.append('<input type="hidden" name="ajax" value="1"/>');
|
||||||
form.ajaxForm({
|
form.ajaxForm({
|
||||||
dataType: 'xml',
|
dataType: 'xml',
|
||||||
timeout: '60000',
|
timeout: '60000',
|
||||||
beforeSend: function(formData) {
|
beforeSend: function(formData) {
|
||||||
if ($('#'+form_id+' #'+SN.C.S.NoticeDataText)[0].value.length === 0) {
|
if (form.find('#'+SN.C.S.NoticeDataText)[0].value.length === 0) {
|
||||||
form.addClass(SN.C.S.Warning);
|
form.addClass(SN.C.S.Warning);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
form.addClass(SN.C.S.Processing);
|
form
|
||||||
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled);
|
.addClass(SN.C.S.Processing)
|
||||||
$('#'+form_id+' #'+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();
|
SN.C.I.NoticeDataGeo.NLat = $('#'+SN.C.S.NoticeLat).val();
|
||||||
NLon = $('#'+SN.C.S.NoticeLon).val();
|
SN.C.I.NoticeDataGeo.NLon = $('#'+SN.C.S.NoticeLon).val();
|
||||||
NLNS = $('#'+SN.C.S.NoticeLocationNs).val();
|
SN.C.I.NoticeDataGeo.NLNS = $('#'+SN.C.S.NoticeLocationNs).val();
|
||||||
NLID = $('#'+SN.C.S.NoticeLocationId).val();
|
SN.C.I.NoticeDataGeo.NLID = $('#'+SN.C.S.NoticeLocationId).val();
|
||||||
NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked');
|
SN.C.I.NoticeDataGeo.NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked');
|
||||||
|
|
||||||
cookieValue = $.cookie(SN.C.S.NoticeDataGeoCookie);
|
cookieValue = $.cookie(SN.C.S.NoticeDataGeoCookie);
|
||||||
|
|
||||||
if (cookieValue !== null && cookieValue != 'disabled') {
|
if (cookieValue !== null && cookieValue != 'disabled') {
|
||||||
cookieValue = JSON.parse(cookieValue);
|
cookieValue = JSON.parse(cookieValue);
|
||||||
NLat = $('#'+SN.C.S.NoticeLat).val(cookieValue.NLat).val();
|
SN.C.I.NoticeDataGeo.NLat = $('#'+SN.C.S.NoticeLat).val(cookieValue.NLat).val();
|
||||||
NLon = $('#'+SN.C.S.NoticeLon).val(cookieValue.NLon).val();
|
SN.C.I.NoticeDataGeo.NLon = $('#'+SN.C.S.NoticeLon).val(cookieValue.NLon).val();
|
||||||
if ($('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS)) {
|
if ($('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS)) {
|
||||||
NLNS = $('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS).val();
|
SN.C.I.NoticeDataGeo.NLNS = $('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS).val();
|
||||||
NLID = $('#'+SN.C.S.NoticeLocationId).val(cookieValue.NLID).val();
|
SN.C.I.NoticeDataGeo.NLID = $('#'+SN.C.S.NoticeLocationId).val(cookieValue.NLID).val();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cookieValue == 'disabled') {
|
if (cookieValue == 'disabled') {
|
||||||
NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked', false).attr('checked');
|
SN.C.I.NoticeDataGeo.NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked', false).attr('checked');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked', true).attr('checked');
|
SN.C.I.NoticeDataGeo.NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked', true).attr('checked');
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
error: function (xhr, textStatus, errorThrown) {
|
error: function (xhr, textStatus, errorThrown) {
|
||||||
form.removeClass(SN.C.S.Processing);
|
form
|
||||||
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled);
|
.removeClass(SN.C.S.Processing)
|
||||||
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled, SN.C.S.Disabled);
|
.find('#'+SN.C.S.NoticeActionSubmit)
|
||||||
$('#'+form_id+' .form_response').remove();
|
.removeClass(SN.C.S.Disabled)
|
||||||
|
.removeAttr(SN.C.S.Disabled, SN.C.S.Disabled);
|
||||||
|
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>');
|
||||||
}
|
}
|
||||||
@ -227,9 +231,10 @@ 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_id).resetForm();
|
form
|
||||||
$('#'+form_id+' #'+SN.C.S.NoticeDataAttachSelected).remove();
|
.resetForm()
|
||||||
SN.U.FormNoticeEnhancements($('#'+form_id));
|
.find('#'+SN.C.S.NoticeDataAttachSelected).remove();
|
||||||
|
SN.U.FormNoticeEnhancements(form);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
form.append('<p class="form_response error">(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.</p>');
|
form.append('<p class="form_response error">(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.</p>');
|
||||||
@ -238,7 +243,7 @@ var SN = { // StatusNet
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
success: function(data, textStatus) {
|
success: function(data, textStatus) {
|
||||||
$('#'+form_id+' .form_response').remove();
|
form.find('.form_response').remove();
|
||||||
var result;
|
var result;
|
||||||
if ($('#'+SN.C.S.Error, data).length > 0) {
|
if ($('#'+SN.C.S.Error, data).length > 0) {
|
||||||
result = document._importNode($('p', data)[0], true);
|
result = document._importNode($('p', data)[0], true);
|
||||||
@ -271,8 +276,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));
|
||||||
}
|
}
|
||||||
@ -283,24 +289,26 @@ var SN = { // StatusNet
|
|||||||
form.append('<p class="form_response success">'+result_title+'</p>');
|
form.append('<p class="form_response success">'+result_title+'</p>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('#'+form_id).resetForm();
|
form.resetForm();
|
||||||
$('#'+form_id+' #'+SN.C.S.NoticeInReplyTo).val('');
|
form.find('#'+SN.C.S.NoticeInReplyTo).val('');
|
||||||
$('#'+form_id+' #'+SN.C.S.NoticeDataAttachSelected).remove();
|
form.find('#'+SN.C.S.NoticeDataAttachSelected).remove();
|
||||||
SN.U.FormNoticeEnhancements($('#'+form_id));
|
SN.U.FormNoticeEnhancements(form);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
complete: function(xhr, textStatus) {
|
complete: function(xhr, textStatus) {
|
||||||
form.removeClass(SN.C.S.Processing);
|
form
|
||||||
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled);
|
.removeClass(SN.C.S.Processing)
|
||||||
$('#'+form_id+' #'+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(SN.C.I.NoticeDataGeo.NLat);
|
||||||
$('#'+SN.C.S.NoticeLon).val(NLon);
|
$('#'+SN.C.S.NoticeLon).val(SN.C.I.NoticeDataGeo.NLon);
|
||||||
if ($('#'+SN.C.S.NoticeLocationNs)) {
|
if ($('#'+SN.C.S.NoticeLocationNs)) {
|
||||||
$('#'+SN.C.S.NoticeLocationNs).val(NLNS);
|
$('#'+SN.C.S.NoticeLocationNs).val(SN.C.I.NoticeDataGeo.NLNS);
|
||||||
$('#'+SN.C.S.NoticeLocationId).val(NLID);
|
$('#'+SN.C.S.NoticeLocationId).val(SN.C.I.NoticeDataGeo.NLID);
|
||||||
}
|
}
|
||||||
$('#'+SN.C.S.NoticeDataGeo).attr('checked', NDG);
|
$('#'+SN.C.S.NoticeDataGeo).attr('checked', SN.C.I.NoticeDataGeo.NDG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user