X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Futil.js;h=c22802651a1f270eae9ba4a7714f0ceabf04e239;hb=1b25b75b538224e53c50e2362cbe63910a636eb4;hp=844a5adb8dfab8ee294a924f95696c07643f2883;hpb=f47027abbefe35d17df50c67eec7cd1156a5e39a;p=quix0rs-gnu-social.git diff --git a/js/util.js b/js/util.js index 844a5adb8d..c22802651a 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 @@ -609,8 +616,7 @@ var SN = { // StatusNet $('#content .notice_reply').live('click', function(e) { e.preventDefault(); var notice = $(this).closest('li.notice'); - var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid'); - SN.U.NoticeInlineReplyTrigger(notice, '@' + nickname.text()); + SN.U.NoticeInlineReplyTrigger(notice); return false; }); }, @@ -632,29 +638,51 @@ var SN = { // StatusNet // Find the notice we're replying to... var id = $($('.notice_id', notice)[0]).text(); var parentNotice = notice; + var stripForm = true; // strip a couple things out of reply forms that are inline // Find the threaded replies view we'll be adding to... var list = notice.closest('.notices'); - if (list.hasClass('threaded-replies')) { + if (list.closest('.old-school').length) { + // We're replying to an old-school conversation thread; + // use the old-style ping into the top form. + SN.U.switchInputFormTab("status") + replyForm = $('#input_form_status').find('form'); + stripForm = false; + } else if (list.hasClass('threaded-replies')) { // We're replying to a reply; use reply form on the end of this list. // We'll add our form at the end of this; grab the root notice. parentNotice = list.closest('.notice'); + + // See if the form's already open... + var replyForm = $('.notice-reply-form', list); } else { // We're replying to a parent notice; pull its threaded list // and we'll add on the end of it. Will add if needed. list = $('ul.threaded-replies', notice); if (list.length == 0) { - list = $(''); - notice.append(list); + 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); + } } - } - // See if the form's already open... - var replyForm = $('.notice-reply-form', list); + // See if the form's already open... + var replyForm = $('.notice-reply-form', list); + } var nextStep = function() { // Override...? replyForm.find('input[name=inreplyto]').val(id); + if (stripForm) { + // Don't do this for old-school reply form, as they don't come back! + replyForm.find('#notice_to').attr('disabled', 'disabled').hide(); + replyForm.find('#notice_private').attr('disabled', 'disabled').hide(); + replyForm.find('label[for=notice_to]').hide(); + replyForm.find('label[for=notice_private]').hide(); + } // Set focus... var text = replyForm.find('textarea'); @@ -714,8 +742,13 @@ var SN = { // StatusNet NoticeInlineReplyPlaceholder: function(notice) { var list = notice.find('ul.threaded-replies'); + if (list.length == 0) { + list = $(''); + notice.append(list); + list = notice.find('ul.threaded-replies'); + } var placeholder = $('
  • ' + - '' + + '' + '
  • '); placeholder.find('input') .val(SN.msg('reply_placeholder')); @@ -756,6 +789,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) { @@ -1385,6 +1419,14 @@ var SN = { // StatusNet $('#input_form_nav_'+tag).addClass('current'); } + // Don't remove 'current' if we also have the "nonav" class. + // An example would be the message input form. removing + // 'current' will cause the form to vanish from the page. + var nonav = $('.input_form.current.nonav'); + if (nonav.length > 0) { + return; + } + $('.input_form.current').removeClass('current'); $('#input_form_'+tag) .addClass('current') @@ -1392,8 +1434,16 @@ var SN = { // StatusNet var form = $(this); SN.Init.NoticeFormSetup(form); }) - .find('textarea:first').focus(); - } + .find('.notice_data-text').focus(); + }, + + showMoreMenuItems: function(menuid) { + $('#'+menuid+' .more_link').remove(); + var selector = '#'+menuid+' .extended_menu'; + var extended = $(selector); + extended.removeClass('extended_menu'); + return void(0); + } }, Init: { @@ -1451,6 +1501,10 @@ var SN = { // StatusNet }); } }); + + // Infield labels for notice form inputs. + $('.input_forms fieldset fieldset label').inFieldLabels({ fadeOpacity:0 }); + } },