X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Futil.js;h=979415c639829187bda3809823bbbf8bbfe42f2c;hb=b7aacc08183bad5eb6f1eb4ce3d964aa56338f3c;hp=55f2920cd5f4a9e25a13bb9c92ce2304b3e25266;hpb=82577a9dc2d98bbc7702a177f2c52c1f0e406c84;p=quix0rs-gnu-social.git diff --git a/js/util.js b/js/util.js index 55f2920cd5..979415c639 100644 --- a/js/util.js +++ b/js/util.js @@ -236,10 +236,11 @@ var SN = { // StatusNet * @fixme can't submit file uploads * * @param {jQuery} form: jQuery object whose first element is a form + * @param function onSuccess: something extra to do on success * * @access public */ - FormXHR: function(form) { + FormXHR: function(form, onSuccess) { $.ajax({ type: 'POST', dataType: 'xml', @@ -261,7 +262,7 @@ var SN = { // StatusNet errorReported = $('#error', xhr.responseXML).text(); } alert(errorReported || errorThrown || textStatus); - + // Restore the form to original state. // Hopefully. :D form @@ -274,9 +275,15 @@ var SN = { // StatusNet if (typeof($('form', data)[0]) != 'undefined') { form_new = document._importNode($('form', data)[0], true); form.replaceWith(form_new); + if (onSuccess) { + onSuccess(); + } } else if (typeof($('p', data)[0]) != 'undefined') { form.replaceWith(document._importNode($('p', data)[0], true)); + if (onSuccess) { + onSuccess(); + } } else { alert('Unknown error.'); @@ -499,7 +506,7 @@ var SN = { // StatusNet results_placeholder.replaceWith(list); } else { - var _error = $('
  • ').append(document._importNode($('p', data)[0], true)); + var _error = $('
  • ').append(document._importNode($('p', data)[0], true)); results_placeholder.html(_error); } form @@ -645,6 +652,11 @@ var SN = { // StatusNet if (list.length == 0) { SN.U.NoticeInlineReplyPlaceholder(notice); list = $('ul.threaded-replies', notice); + } else { + var placeholder = $('li.notice-reply-placeholder', notice); + if (placeholder.length == 0) { + SN.U.NoticeInlineReplyPlaceholder(notice); + } } } @@ -723,7 +735,7 @@ var SN = { // StatusNet list = notice.find('ul.threaded-replies'); } var placeholder = $('
  • ' + - '' + + '' + '
  • '); placeholder.find('input') .val(SN.msg('reply_placeholder')); @@ -764,6 +776,7 @@ var SN = { // StatusNet * popout before submitting. * * Uses 'live' rather than 'bind', so applies to future as well as present items. + * */ NoticeRepeat: function() { $('.form_repeat').live('click', function(e) { @@ -1408,7 +1421,7 @@ var SN = { // StatusNet var form = $(this); SN.Init.NoticeFormSetup(form); }) - .find('textarea:first').focus(); + .find('.notice_data-text').focus(); } }, @@ -1467,6 +1480,10 @@ var SN = { // StatusNet }); } }); + + // Infield labels for notice form inputs. + $('.input_forms fieldset fieldset label').inFieldLabels({ fadeOpacity:0 }); + } },